Examples of CosDpValueUnion


Examples of tcg.scada.cos.CosDpValueUnion

    }

    // validation: inUpdateTimestamp
    // none

    CosDpValueUnion value = createCosDpValueUnion(this
        .getInternalDataType());

    // perform value translation first if necessary. This simplifies the
    // next calculations.
    if (copy(value, inValue) < 0)
View Full Code Here

Examples of tcg.scada.cos.CosDpValueUnion

    if (inValue == null)
    {
      return -1;
    }

    CosDpValueUnion value = createCosDpValueUnion(this
        .getInternalDataType());
    int status = 0;

    // perform value translation first if necessary. This simplifies the
    // next calculations.
View Full Code Here

Examples of tcg.scada.cos.CosDpValueUnion

    int retval = 0;
    IDataPoint datapoint = null;
    Object value = null;

    CosDpQualityEnum expressionQuality = CosDpQualityEnum.QualityGood;
    CosDpValueUnion expressionValue = null;

    // update the value of expression parameters
    for (int i = 0; i < expressionParams.size(); i++)
    {
      datapoint = expressionParams.get(i);
View Full Code Here

Examples of tcg.scada.cos.CosDpValueUnion

      int eqptId = 0;
      boolean isEqptDatapoint = false;

      boolean isInhibit, isOverride, isAlarmInhibit, isAlarmNotAck, isAlarmNotNorm;
      CosDpValueUnion sourceValue = null;
      CosDpValueUnion outputValue = null;

      String str = "";
      while (rs.next())
      {
        // add logging context
View Full Code Here

Examples of tcg.scada.cos.CosDpValueUnion

    }

    // validation: inStr
    // none. validation is performed as part of the conversion

    CosDpValueUnion value = new CosDpValueUnion();

    switch (inType.value())
    {
      case CosDpValueTypeEnum._TypeBoolean:
        if (inStr != null && inStr.compareToIgnoreCase("1") == 0)
        {
          value.boolValue(true);
        }
        else
        {
          value.boolValue(false);
        }
        break;
      case CosDpValueTypeEnum._TypeNumber:
        value.longValue(parseInt(inStr));
        break;
      case CosDpValueTypeEnum._TypeUnsigned:
        value.unsignedValue(parseInt(inStr));
        break;
      case CosDpValueTypeEnum._TypeDouble:
        value.dblValue(parseDbl(inStr));
        break;
      case CosDpValueTypeEnum._TypeString:
        value.charValue(inStr);
        break;
      default:
        value.longValue(0);
    }

    return value;
  }
View Full Code Here

Examples of tcg.scada.cos.CosDpValueUnion

  public void testSetSourceValueCosDpValueStruct()
  {
    int keyId = 1;

    CosDpValueStruct value = new CosDpValueStruct();
    value.value = new CosDpValueUnion();
    value.quality = CosDpQualityEnum.QualityGood;
    DataPointImpl datapoint = null;
    int status = 0;
    long updateTs = Calendar.getInstance().getTimeInMillis();
View Full Code Here

Examples of tcg.scada.cos.CosDpValueUnion

   */
  public void testSetValue()
  {
    int keyId = 1;

    CosDpValueUnion value = new CosDpValueUnion();
    DataPointImpl datapoint = null;
    int status = 0;

    // TODO: check for datastore notification!

    // set with null value
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeBoolean);
    datapoint.keyId = keyId++;
    datapoint.name = "real-boolean";
    Assert.assertEquals(false, datapoint.getValue().boolValue());
    status = datapoint.setValue(null);
    Assert.assertEquals(-1, status);
    Assert.assertEquals(false, datapoint.getValue().boolValue());

    // REAL datapoint

    // real-boolean datapoint
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeBoolean);
    datapoint.keyId = keyId++;
    datapoint.name = "real-boolean";
    // initial value
    Assert.assertEquals(false, datapoint.getValue().boolValue());
    // set with new value
    value.boolValue(true);
    status = datapoint.setValue(value);
    Assert.assertEquals(-1, status);
    Assert.assertEquals(false, datapoint.getValue().boolValue());

    // real-number datapoint
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeNumber);
    datapoint.keyId = keyId++;
    datapoint.name = "real-number";
    // initial value
    Assert.assertEquals(0, datapoint.getValue().longValue());
    // set with new value
    value.longValue(10);
    status = datapoint.setValue(value);
    Assert.assertEquals(-1, status);
    Assert.assertEquals(0, datapoint.getValue().longValue());

    // real-unsigned datapoint
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeUnsigned);
    datapoint.keyId = keyId++;
    datapoint.name = "real-unsigned";
    // initial value
    Assert.assertEquals(0, datapoint.getValue().unsignedValue());
    // set with new value
    value.unsignedValue(10);
    status = datapoint.setValue(value);
    Assert.assertEquals(-1, status);
    Assert.assertEquals(0, datapoint.getValue().unsignedValue());

    // real-double datapoint
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeDouble);
    datapoint.keyId = keyId++;
    datapoint.name = "real-double";
    // initial value
    Assert.assertEquals(0.0, datapoint.getValue().dblValue());
    // set with new value
    value.dblValue(10);
    status = datapoint.setValue(value);
    Assert.assertEquals(-1, status);
    Assert.assertEquals(0.0, datapoint.getValue().dblValue());

    // real-string datapoint
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeString);
    datapoint.keyId = keyId++;
    datapoint.name = "real-string";
    // initial value
    Assert.assertTrue(datapoint.getValue().charValue().compareTo("") == 0);
    // set with new value
    value.charValue("Test");
    status = datapoint.setValue(value);
    Assert.assertEquals(-1, status);
    Assert.assertTrue(datapoint.getValue().charValue().compareTo("") == 0);

  }
View Full Code Here

Examples of tcg.scada.cos.CosDpValueUnion

   */
  public void testSetValue()
  {
    int keyId = 1;

    CosDpValueUnion value = new CosDpValueUnion();
    DataPointImpl datapoint = null;
    int status = 0;
    long timestamp = Calendar.getInstance().getTimeInMillis();

    // TODO: check for datastore notification!

    // set with null value
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeBoolean);
    datapoint.keyId = keyId++;
    datapoint.name = "real-boolean";
    Assert.assertEquals(false, datapoint.getValue().boolValue());
    status = datapoint.setValue(null);
    Assert.assertEquals(-1, status);
    Assert.assertEquals(false, datapoint.getValue().boolValue());

    // VIRTUAL datapoint
    // virtual-boolean datapoint
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeBoolean);
    datapoint.keyId = keyId++;
    datapoint.name = "real-boolean";

    // initial value
    Assert.assertEquals(false, datapoint.getValue().boolValue());
    Assert.assertEquals(0, datapoint.getTimestamp());

    timestamp = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // set value (new value)
    value.boolValue(true);
    status = datapoint.setValue(value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(true, datapoint.getValue().boolValue());
    Assert.assertTrue(datapoint.getTimestamp() > timestamp);

    timestamp = datapoint.getTimestamp();
    sleep(1);
   
    // set value (the same value)
    status = datapoint.setValue(value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(true, datapoint.getValue().boolValue());
    Assert.assertTrue(datapoint.getTimestamp() == timestamp);

    // virtual-number datapoint
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeNumber);
    datapoint.keyId = keyId++;
    datapoint.name = "virtual-number";

    // initial state
    Assert.assertEquals(0, datapoint.getValue().longValue());
    Assert.assertEquals(0, datapoint.getTimestamp());

    timestamp = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // set value (new value)
    value.longValue(10);
    status = datapoint.setValue(value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(10, datapoint.getValue().longValue());
    Assert.assertTrue(datapoint.getTimestamp() > timestamp);

    timestamp = datapoint.getTimestamp();
    sleep(1);
   
    // set value (the same value)
    status = datapoint.setValue(value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(10, datapoint.getValue().longValue());
    Assert.assertTrue(datapoint.getTimestamp() == timestamp);

    // virtual-unsigned datapoint
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeUnsigned);
    datapoint.keyId = keyId++;
    datapoint.name = "real-unsigned";
   
    // initial state
    Assert.assertEquals(0, datapoint.getValue().unsignedValue());
    Assert.assertEquals(0, datapoint.getTimestamp());
   
    timestamp = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // set value (new value)
    value.unsignedValue(10);
    status = datapoint.setValue(value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(10, datapoint.getValue().unsignedValue());
    Assert.assertTrue(datapoint.getTimestamp() > timestamp);

    timestamp = datapoint.getTimestamp();
    sleep(1);
   
    // set value (the same value)
    status = datapoint.setValue(value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(10, datapoint.getValue().unsignedValue());
    Assert.assertTrue(datapoint.getTimestamp() == timestamp);

    // virtual-double datapoint
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeDouble);
    datapoint.keyId = keyId++;
    datapoint.name = "real-double";

    // initial state
    Assert.assertEquals(0.0, datapoint.getValue().dblValue());
    Assert.assertEquals(0, datapoint.getTimestamp());

    timestamp = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // set value (new value)
    value.dblValue(10.0);
    status = datapoint.setValue(value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(10.0, datapoint.getValue().dblValue());
    Assert.assertTrue(datapoint.getTimestamp() > timestamp);

    timestamp = datapoint.getTimestamp();
    sleep(1);
   
    // set value (the same value)
    status = datapoint.setValue(value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(10.0, datapoint.getValue().dblValue());
    Assert.assertTrue(datapoint.getTimestamp() == timestamp);

    // virtual-string datapoint
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeString);
    datapoint.keyId = keyId++;
    datapoint.name = "real-string";

    // initial state
    Assert.assertTrue(datapoint.getValue().charValue().compareTo("") == 0);
    Assert.assertEquals(0, datapoint.getTimestamp());

    timestamp = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // set value (new value)
    value.charValue("Test");
    status = datapoint.setValue(value);
    Assert.assertEquals(1, status);
    Assert
        .assertTrue(datapoint.getValue().charValue().compareTo("Test") == 0);
    Assert.assertTrue(datapoint.getTimestamp() > timestamp);
View Full Code Here

Examples of tcg.scada.cos.CosDpValueUnion

    DataPointImpl datapoint = null;
    boolean boolStatus = false;
    long updateTs = Calendar.getInstance().getTimeInMillis();
    long sourceTs = updateTs;
    long outputTs = updateTs;
    CosDpValueUnion value = new CosDpValueUnion();
    //int intStatus = 0;
   
    // TODO: check for datastore notification!

    // create source datapoint
    VirtualDataPoint source = new VirtualDataPoint(
        CosDpValueTypeEnum.TypeBoolean);
    source.keyId = keyId++;
    source.name = "source-datapoint";

    // create list of datapoint
    DataPointList dpList = new DataPointList();
    dpList.add(source);

    // calculated-boolean datapoint
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeBoolean);
    datapoint.keyId = keyId++;
    datapoint.name = "calculated-boolean";

    // initial value
    Assert.assertEquals(false, datapoint.isInhibit());
    Assert.assertEquals(false, datapoint.getSourceValue().boolValue());
    Assert.assertEquals(0, datapoint.getSourceTimestamp());
    Assert.assertEquals(CosDpQualityEnum.QualityBad, datapoint
        .getSourceQuality());
    Assert.assertEquals(false, datapoint.getValue().boolValue());
    Assert.assertEquals(0, datapoint.getTimestamp());
    Assert.assertEquals(CosDpQualityEnum.QualityBad, datapoint
        .getQuality());
    Assert.assertEquals(0, datapoint.getUpdateTimestamp());

    sourceTs = datapoint.getSourceTimestamp();
    outputTs = datapoint.getTimestamp();
    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // set calculated expression
    boolStatus = datapoint.setExpression("{{source-datapoint}}", dpList);
    Assert.assertEquals(true, boolStatus);
    // source quality is set to good, source timestamp is set to current
    // time
    Assert.assertTrue(datapoint.getSourceTimestamp() > updateTs);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    Assert.assertEquals(false, datapoint.getSourceValue().boolValue());
    // output quality/output timestamp is synchronized
    Assert.assertEquals(datapoint.getSourceTimestamp(), datapoint
        .getTimestamp());
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getQuality());
    Assert.assertEquals(false, datapoint.getValue().boolValue());
    // update-time is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);

    sourceTs = datapoint.getSourceTimestamp();
    outputTs = datapoint.getTimestamp();
    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // set the inhibit flag
    boolStatus = datapoint.setInhibit();
    Assert.assertEquals(true, boolStatus);
    // inhibit flag is set
    Assert.assertEquals(true, datapoint.isInhibit());
    // no update on source value/quality/timestamp
    Assert.assertEquals(false, datapoint.getSourceValue().boolValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() == sourceTs);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    // output quality is set to QualityInhibit,
    // output timestamp is set to current time
    Assert.assertEquals(false, datapoint.getValue().boolValue());
    Assert.assertTrue(datapoint.getTimestamp() > updateTs);
    Assert.assertEquals(CosDpQualityEnum.QualityInhibit, datapoint
        .getQuality());
    // update-timestamp is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);
    // TODO: check for datapoint notification

    sourceTs = datapoint.getSourceTimestamp();
    outputTs = datapoint.getTimestamp();
    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // set the source datapoint with new value (this will trigger the update
    // in the calculated point)
    source.setBooleanValue(true);
    // source value is updated, source timestamp is updated to current time
    Assert.assertEquals(true, datapoint.getSourceValue().boolValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() > updateTs);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    // no update on output value/quality/timestamp
    Assert.assertEquals(false, datapoint.getValue().boolValue());
    Assert.assertTrue(datapoint.getTimestamp() == outputTs);
    Assert.assertEquals(CosDpQualityEnum.QualityInhibit, datapoint
        .getQuality());
    // update timestamp is updated to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);
    // TODO: check for datapoint notification

    sourceTs = datapoint.getSourceTimestamp();
    outputTs = datapoint.getTimestamp();
    updateTs = datapoint.getUpdateTimestamp();
    sleep(1);

    // re-inhibit (fail)
    boolStatus = datapoint.setAlarmInhibit();
    Assert.assertEquals(false, boolStatus);
    // no update on source value/quality/timestamp
    Assert.assertEquals(true, datapoint.getSourceValue().boolValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() == sourceTs);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    // no update on output value/quality/timestamp
    Assert.assertEquals(false, datapoint.getValue().boolValue());
    Assert.assertTrue(datapoint.getTimestamp() == outputTs);
    Assert.assertEquals(CosDpQualityEnum.QualityInhibit, datapoint
        .getQuality());
    // update-timestamp is not updated
    Assert.assertTrue(datapoint.getUpdateTimestamp() == updateTs);
    // TODO: check for datapoint notification

    sourceTs = datapoint.getSourceTimestamp();
    outputTs = datapoint.getTimestamp();
    updateTs = datapoint.getUpdateTimestamp();
    sleep(1);

    // set override (mutually exclusive)
    value.boolValue(true);
    datapoint.setOverride(value);
    Assert.assertEquals(false, boolStatus);
    Assert.assertEquals(true, datapoint.isInhibit());
    Assert.assertEquals(false, datapoint.isOverride());
    // inhibit and override state is mutually exclusive
View Full Code Here

Examples of tcg.scada.cos.CosDpValueUnion

    boolean boolStatus = false;
    int intStatus = 0;
    long updateTs = Calendar.getInstance().getTimeInMillis();
    long outputTs = updateTs;
    long sourceTs = updateTs;
    CosDpValueUnion value = new CosDpValueUnion();

    // TODO: check for datastore notification!

    // create source datapoint
    RealDataPoint source = new RealDataPoint(CosDpValueTypeEnum.TypeNumber);
    source.keyId = keyId++;
    source.name = "source-datapoint";

    // set source point quality to good
    intStatus = source.setSourceQuality(CosDpQualityEnum.QualityGood, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, source.getSourceQuality());
    Assert.assertEquals(CosDpQualityEnum.QualityGood, source.getQuality());
   
    // create list of datapoint
    DataPointList dpList = new DataPointList();
    dpList.add(source);

    // real-boolean datapoint
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeNumber);
    datapoint.keyId = keyId++;
    datapoint.name = "real-number";

    // initial value
    Assert.assertEquals(false, datapoint.isOverride());
    Assert.assertEquals(0, datapoint.getSourceValue().longValue());
    Assert.assertEquals(0, datapoint.getSourceTimestamp());
    Assert.assertEquals(CosDpQualityEnum.QualityBad, datapoint
        .getSourceQuality());
    Assert.assertEquals(0, datapoint.getValue().longValue());
    Assert.assertEquals(0, datapoint.getTimestamp());
    Assert.assertEquals(CosDpQualityEnum.QualityBad, datapoint
        .getQuality());
    Assert.assertEquals(0, datapoint.getUpdateTimestamp());

    sourceTs = datapoint.getSourceTimestamp();
    outputTs = datapoint.getTimestamp();
    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // set calculated expression
    boolStatus = datapoint.setExpression("{{source-datapoint}}", dpList);
    Assert.assertEquals(true, boolStatus);
    // source quality is set to good,
    // source timestamp is set to current time
    Assert.assertTrue(datapoint.getSourceTimestamp() > updateTs);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    Assert.assertEquals(0, datapoint.getSourceValue().longValue());
    // output quality/output timestamp is synchronized
    Assert.assertEquals(datapoint.getSourceTimestamp(), datapoint
        .getTimestamp());
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getQuality());
    Assert.assertEquals(0, datapoint.getValue().longValue());
    // update-time is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);

    sourceTs = datapoint.getSourceTimestamp();
    updateTs = datapoint.getTimestamp();
    outputTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // set override (bool value)
    value.longValue(10);
    boolStatus = datapoint.setOverride(value);
    Assert.assertEquals(true, boolStatus);
    // override flag is set
    Assert.assertEquals(true, datapoint.isOverride());
    // no update on source value/quality/timestamp
    Assert.assertEquals(0, datapoint.getSourceValue().longValue());
    Assert.assertEquals(sourceTs, datapoint.getSourceTimestamp());
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    // output quality is set to QualityOverride, output value set to
    // override value
    // output timestamp set to current time
    Assert.assertEquals(10, datapoint.getValue().longValue());
    Assert.assertTrue(datapoint.getTimestamp() > updateTs);
    Assert.assertEquals(CosDpQualityEnum.QualityOverride, datapoint
        .getQuality());
    // update-timestamp is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);
    // TODO: check for datapoint notification

    sourceTs = datapoint.getSourceTimestamp();
    outputTs = datapoint.getTimestamp();
    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // set source value (this will trigger updates on the calculated point)
    intStatus = source.setNumberSourceValue(-20, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(-20, source.getValue().longValue());
    // source value is updated, source timestamp is updated to current time
    Assert.assertEquals(-20, datapoint.getSourceValue().longValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() > updateTs);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    // no update on output value/quality/timestamp
    Assert.assertEquals(10, datapoint.getValue().longValue());
    Assert.assertTrue(datapoint.getTimestamp() == outputTs);
    Assert.assertEquals(CosDpQualityEnum.QualityOverride, datapoint
        .getQuality());
    // update timestamp is updated to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);
    // TODO: check for datapoint notification

    sourceTs = datapoint.getSourceTimestamp();
    outputTs = datapoint.getTimestamp();
    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // re-override with new value (succed with override value updated)
    value.longValue(110);
    boolStatus = datapoint.setOverride(value);
    Assert.assertEquals(true, boolStatus);
    // no update on source value/quality/timestamp
    Assert.assertEquals(-20, datapoint.getSourceValue().longValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() == sourceTs);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.