Examples of RealDataPoint


Examples of tcg.scada.da.RealDataPoint

    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 the source datapoint
    intStatus = source.setNumberSourceValue(250, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(250, source.getValue().longValue());

    // 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);
View Full Code Here

Examples of tcg.scada.da.RealDataPoint

    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 the source datapoint' value
    intStatus = source.setNumberSourceValue(250, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(250, source.getValue().longValue());

    // 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";

    // set reading rollover and datapoint rollover to understandable value
    intStatus = datapoint.setReadingRollOver(1000);
    Assert.assertEquals(1000, intStatus);
    Assert.assertEquals(1000, datapoint.getReadingRollOver());

    intStatus = datapoint.setDataPointRollOver(1500);
    Assert.assertEquals(1500, intStatus);
    Assert.assertEquals(1500, datapoint.getDataPointRollOver());

    // set initial state
    value.longValue(53);
    datapoint.setInitialValue(value, value);
    datapoint.setLastMeterReading(200);

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

    sourceTs = Calendar.getInstance().getTimeInMillis();
    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // set meter source point (reading value = 250)
    // (meter value = 250 - 200 + 53 = 103)
    boolStatus = datapoint.setMeterSourcePoint(source);
    Assert.assertEquals(true, boolStatus);
    // source quality is set to good, source timestamp is set to current
    // time
    Assert.assertTrue(datapoint.getSourceTimestamp() > sourceTs);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    Assert.assertEquals(103, datapoint.getSourceValue().longValue());
    // output quality/output timestamp is synchronized
    Assert.assertEquals(datapoint.getSourceTimestamp(), datapoint
        .getTimestamp());
    Assert.assertEquals(datapoint.getSourceQuality(), datapoint
        .getQuality());
    Assert.assertEquals(datapoint.getSourceValue().longValue(), datapoint
        .getValue().longValue());
    // update-time is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);
    // TODO: check for datapoint notification

    sourceTs = Calendar.getInstance().getTimeInMillis();
    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // set source value (reading value = 30 -> reading rollover)
    // (meter value = 30 + 1000 - 250 + 103 = 883)
    intStatus = source.setNumberSourceValue(30, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(30, source.getValue().longValue());
    // source quality is set to good, source timestamp is set to current
    // time
    Assert.assertTrue(datapoint.getSourceTimestamp() > sourceTs);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    Assert.assertEquals(883, datapoint.getSourceValue().longValue());
    // output quality/output timestamp is synchronized
    Assert.assertEquals(datapoint.getSourceTimestamp(), datapoint
        .getTimestamp());
    Assert.assertEquals(datapoint.getSourceQuality(), datapoint
        .getQuality());
    Assert.assertEquals(datapoint.getSourceValue().longValue(), datapoint
        .getValue().longValue());
    // update-time is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);
    // TODO: check for datapoint notification

    sourceTs = Calendar.getInstance().getTimeInMillis();
    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // set new quality with timestamp update
    intStatus = source.setSourceQuality(CosDpQualityEnum.QualityBad, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(CosDpQualityEnum.QualityBad, source.getQuality());
    // source quality is updated, source timestamp is updated to current
    // time
    Assert.assertEquals(883, datapoint.getSourceValue().longValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() > sourceTs);
    Assert.assertEquals(CosDpQualityEnum.QualityBad, datapoint
        .getSourceQuality());
    // output value/quality/timestamp is synchronized
    Assert.assertEquals(datapoint.getSourceTimestamp(), datapoint
        .getTimestamp());
    Assert.assertEquals(datapoint.getSourceQuality(), datapoint
        .getQuality());
    Assert.assertEquals(datapoint.getSourceValue().longValue(), datapoint
        .getValue().longValue());
    // update timestamp is updated to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);
    // TODO: check for datapoint notification

    sourceTs = Calendar.getInstance().getTimeInMillis();
    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // set source value (reading value = 830 -> datapoint rollover)
    // (meter value = (830 - 30 + 883) - 1500 = (1683) - 1500 = 183)
    intStatus = source.setNumberSourceValue(830, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(830, source.getValue().longValue());
    // source quality is set to good, source timestamp is set to current
    // time
    Assert.assertTrue(datapoint.getSourceTimestamp() > sourceTs);
    Assert.assertEquals(CosDpQualityEnum.QualityBad, datapoint
        .getSourceQuality());
View Full Code Here

Examples of tcg.scada.da.RealDataPoint

    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 the source datapoint's value
    intStatus = source.setNumberSourceValue(100, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(100, source.getValue().longValue());

    // 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";

    // set reading rollover to understandable value
    intStatus = datapoint.setReadingRollOver(1000);
    Assert.assertEquals(1000, intStatus);
    Assert.assertEquals(1000, datapoint.getReadingRollOver());

    // 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());
    // last meter reading
    Assert.assertEquals(0, datapoint.getLastMeterReading());
    Assert.assertEquals(0, datapoint.getUpdateTimestamp());

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

    // set meter source point
    boolStatus = datapoint.setMeterSourcePoint(source);
    Assert.assertEquals(true, boolStatus);
    // source quality is set to good, source timestamp is set to current
    // time
    Assert.assertTrue(datapoint.getSourceTimestamp() > sourceTs);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    Assert.assertEquals(100, datapoint.getSourceValue().longValue());
    // output quality/output timestamp is synchronized
    Assert.assertEquals(datapoint.getSourceTimestamp(), datapoint
        .getTimestamp());
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getQuality());
    Assert.assertEquals(100, datapoint.getValue().longValue());
    // 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 inhibit (bool value)
    boolStatus = datapoint.setInhibit();
    Assert.assertEquals(true, boolStatus);
    // override flag is set
    Assert.assertEquals(true, datapoint.isInhibit());
    // no update on source value/quality/timestamp
    Assert.assertEquals(100, datapoint.getSourceValue().longValue());
    Assert.assertEquals(sourceTs, datapoint.getSourceTimestamp());
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    // output quality is set to inhibit, output time set to current time
    Assert.assertEquals(100, datapoint.getValue().longValue());
    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 = Calendar.getInstance().getTimeInMillis();
    updateTs = Calendar.getInstance().getTimeInMillis();
    outputTs = datapoint.getTimestamp();
    sleep(1);

    // set source value with timestamp update (this will trigger updates on
    // the meter point)
    intStatus = source.setNumberSourceValue(50, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(50, source.getValue().longValue());
    // source value is updated, source timestamp is updated to current time
    Assert.assertEquals(1050, datapoint.getSourceValue().longValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() > sourceTs);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    // no update on output value/quality/timestamp
    Assert.assertEquals(100, datapoint.getValue().longValue());
    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 = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // re-inhibit (succeed but output value not updated with current value)
    boolStatus = datapoint.setInhibit();
    Assert.assertEquals(true, boolStatus);
    // no update on source value/quality/timestamp
    Assert.assertEquals(1050, datapoint.getSourceValue().longValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() == sourceTs);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    // no update on output value/quality/timestamp
    Assert.assertEquals(100, datapoint.getValue().longValue());
    Assert.assertTrue(datapoint.getTimestamp() == outputTs);
    Assert.assertEquals(CosDpQualityEnum.QualityInhibit, datapoint
        .getQuality());
    // no update on update timestamp
    Assert.assertTrue(datapoint.getUpdateTimestamp() == updateTs);
    // TODO: check for datapoint notification

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

    // set new quality with timestamp update
    intStatus = source.setSourceQuality(CosDpQualityEnum.QualityBad, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(CosDpQualityEnum.QualityBad, source.getQuality());
    // source quality is updated, source timestamp is updated to current
    // time
    Assert.assertEquals(1050, datapoint.getSourceValue().longValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() > sourceTs);
    Assert.assertEquals(CosDpQualityEnum.QualityBad, datapoint
View Full Code Here

Examples of tcg.scada.da.RealDataPoint

    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 the source datapoint's value
    intStatus = source.setNumberSourceValue(100, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(100, source.getValue().longValue());

    // 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";

    // set reading rollover to understandable value
    intStatus = datapoint.setReadingRollOver(1000);
    Assert.assertEquals(1000, intStatus);
    Assert.assertEquals(1000, datapoint.getReadingRollOver());

    // 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());
    // last meter reading
    Assert.assertEquals(0, datapoint.getLastMeterReading());
    Assert.assertEquals(0, datapoint.getUpdateTimestamp());

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

    // set meter source point
    boolStatus = datapoint.setMeterSourcePoint(source);
    Assert.assertEquals(true, boolStatus);
    // source quality is set to good, source timestamp is set to current
    // time
    Assert.assertTrue(datapoint.getSourceTimestamp() > sourceTs);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    Assert.assertEquals(100, datapoint.getSourceValue().longValue());
    // output quality/output timestamp is synchronized
    Assert.assertEquals(datapoint.getSourceTimestamp(), datapoint
        .getTimestamp());
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getQuality());
    Assert.assertEquals(100, datapoint.getValue().longValue());
    // update-time is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);

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

    // set new reading value (normal accumulation)
    intStatus = source.setNumberSourceValue(130, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(130, source.getValue().longValue());
    // source quality is set to good, source timestamp is set to current
    // time
    Assert.assertTrue(datapoint.getSourceTimestamp() > sourceTs);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    Assert.assertEquals(130, datapoint.getSourceValue().longValue());
    // output quality/output timestamp is synchronized
    Assert.assertEquals(datapoint.getSourceTimestamp(), datapoint
        .getTimestamp());
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getQuality());
    Assert.assertEquals(130, datapoint.getValue().longValue());
    // update-time is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);

    sourceTs = datapoint.getSourceTimestamp();
    updateTs = Calendar.getInstance().getTimeInMillis();
    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(130, 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() > outputTs);
    Assert.assertEquals(CosDpQualityEnum.QualityOverride, datapoint
        .getQuality());
    // update-timestamp is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);
    // TODO: check for datapoint notification

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

    // set source value (rollover value)
    intStatus = source.setNumberSourceValue(50, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(50, source.getValue().longValue());
    // source value is updated, source timestamp is updated to current time
    Assert.assertEquals(1050, datapoint.getSourceValue().longValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() > sourceTs);
    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();
    updateTs = Calendar.getInstance().getTimeInMillis();
    outputTs = 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(1050, datapoint.getSourceValue().longValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() == sourceTs);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    // output value is updated with new override value, output timestamp is
    // set to current time
    Assert.assertEquals(110, datapoint.getValue().longValue());
    Assert.assertTrue(datapoint.getTimestamp() > outputTs);
    Assert.assertEquals(CosDpQualityEnum.QualityOverride, datapoint
        .getQuality());
    // update-timestamp is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);
    // TODO: check for datapoint notification

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

    // set new quality with timestamp update
    intStatus = source.setSourceQuality(CosDpQualityEnum.QualityBad, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(CosDpQualityEnum.QualityBad, source.getQuality());
    // source quality is updated, source timestamp is updated to current
    // time
    Assert.assertEquals(1050, datapoint.getSourceValue().longValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() > sourceTs);
    Assert.assertEquals(CosDpQualityEnum.QualityBad, datapoint
View Full Code Here

Examples of tcg.scada.da.RealDataPoint

    //       trigger bad quality in the calculated expression
    // TODO: check that source datapoint's quality is cascaded to the
    //       calculated point
   
    // 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();
    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
    // expression is evaluated and the source value is set
    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 = 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());
    // output value/quality/timestamp is synchronized
    Assert.assertEquals(datapoint.getSourceValue().longValue(), datapoint
        .getValue().longValue());
    Assert.assertEquals(datapoint.getSourceTimestamp(), datapoint
        .getTimestamp());
    Assert.assertEquals(datapoint.getSourceQuality(), datapoint
        .getQuality());
    // update timestamp is updated to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);
    // TODO: check for datapoint notification

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

    // set source quality
    intStatus = source.setSourceQuality(CosDpQualityEnum.QualityBad, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(CosDpQualityEnum.QualityBad, source.getQuality());
    // source quality is updated, source timestamp is updated to current
    // time
    Assert.assertEquals(-20, datapoint.getSourceValue().longValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() > updateTs);
    Assert.assertEquals(CosDpQualityEnum.QualityBad, datapoint
View Full Code Here

Examples of tcg.scada.da.RealDataPoint

    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);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    // output value is updated with new override value, output timestamp is
    // set to current time
    Assert.assertEquals(110, 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 quality
    intStatus = source.setSourceQuality(CosDpQualityEnum.QualityBad, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(CosDpQualityEnum.QualityBad, source.getQuality());
    // source quality is updated, source timestamp is updated to current
    // time
    Assert.assertEquals(-20, datapoint.getSourceValue().longValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() > updateTs);
    Assert.assertEquals(CosDpQualityEnum.QualityBad, datapoint
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.