Package tcg.scada.cos

Examples of tcg.scada.cos.CosDpValueUnion


    //get the actual value
    CosDpValueStruct[] values = new CosDpValueStruct[1];
    values[0] = new CosDpValueStruct();
    values[0].quality = CosDpQualityEnum.QualityGood;
    values[0].timestamp = 0;
    values[0].value = new CosDpValueUnion();
   
    //storage for error
    CosDpErrorSeqHolder errors = new CosDpErrorSeqHolder();
   
    if (isDigitalControl)
View Full Code Here


    DataPointImpl datapoint = null;
    boolean boolStatus = false;
    int intStatus = 0;
    long updateTs = Calendar.getInstance().getTimeInMillis();
    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 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);

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

    DataPointImpl datapoint = null;
    boolean boolStatus = false;
    int intStatus = 0;
    long updateTs = Calendar.getInstance().getTimeInMillis();
    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 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());
View Full Code Here

    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 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
        .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();
    updateTs = datapoint.getUpdateTimestamp();
    outputTs = datapoint.getTimestamp();
    sleep(1);

    // set override (mutually exclusive)
    value.longValue(100);
    boolStatus = datapoint.setOverride(value);
    Assert.assertEquals(false, boolStatus);
    Assert.assertEquals(true, datapoint.isInhibit());
    Assert.assertEquals(false, datapoint.isOverride());
    // no update on source value/quality/timestamp
View Full Code Here

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

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

    // TODO: check for datastore notification!

    // REAL datapoint

    // real-boolean datapoint
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeBoolean);
    datapoint.keyId = keyId++;
    datapoint.name = "real-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());

    // set the quality to good for easier testing
    intStatus = datapoint.setSourceQuality(CosDpQualityEnum.QualityGood, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint.getSourceQuality());
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint.getQuality());
   
    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 = Calendar.getInstance().getTimeInMillis();
    outputTs = datapoint.getTimestamp();
    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);

    // set with new value with timestamp update
    intStatus = datapoint.setBooleanSourceValue(true, true);
    Assert.assertEquals(1, intStatus);
    // source value is updated, source timestamp is updated to current time
    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 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 (succeed but datapoint is not updated)
    boolStatus = datapoint.setInhibit();
    Assert.assertEquals(true, boolStatus);
    // no update on source value/quality/timestamp
    Assert.assertEquals(true, datapoint.getSourceValue().boolValue());
    Assert.assertEquals(sourceTs, datapoint.getSourceTimestamp());
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
    // no update on output value/quality/timestamp
    Assert.assertEquals(false, datapoint.getValue().boolValue());
    Assert.assertEquals(outputTs, datapoint.getTimestamp());
    Assert.assertEquals(CosDpQualityEnum.QualityInhibit, datapoint
        .getQuality());
    // update timestamp is not updated
    Assert.assertEquals(updateTs, datapoint.getUpdateTimestamp());
    // 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 = datapoint.setSourceQuality(CosDpQualityEnum.QualityBad,
        true);
    Assert.assertEquals(1, intStatus);
    // source quality is updated, source timestamp is updated to current
    // time
    Assert.assertEquals(true, datapoint.getSourceValue().boolValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() > sourceTs);
    Assert.assertEquals(CosDpQualityEnum.QualityBad, 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);

    // set override (mutually exclusive)
    value.boolValue(true);
    boolStatus = 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

    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!

    // 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());

    // set the quality to good for easier testing
    intStatus = datapoint.setSourceQuality(CosDpQualityEnum.QualityGood, false);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint.getSourceQuality());
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint.getQuality());
   
    sourceTs = Calendar.getInstance().getTimeInMillis();
    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(0, datapoint.getSourceValue().longValue());
    Assert.assertEquals(0, 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 with timestamp update
    intStatus = datapoint.setNumberSourceValue(-20, true);
    Assert.assertEquals(1, intStatus);
    // source value is updated, source timestamp is updated to current time
    Assert.assertEquals(-20, 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(-20, datapoint.getSourceValue().longValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() == sourceTs);
View Full Code Here

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

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

    // TODO: check for datastore notification!

    // set with null value
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeBoolean);
    datapoint.keyId = keyId++;
    datapoint.name = "real-boolean";
    // initial state
    Assert.assertEquals(false, datapoint.getSourceValue().boolValue());
    Assert.assertEquals(0, datapoint.getSourceTimestamp());
    Assert.assertEquals(false, datapoint.getValue().boolValue());
    Assert.assertEquals(0, datapoint.getTimestamp());
    // set without timestamp update
    status = datapoint.setSourceValue(null, false);
    Assert.assertEquals(-1, status);
    Assert.assertEquals(false, datapoint.getValue().boolValue());
    Assert.assertEquals(0, datapoint.getSourceTimestamp());
    Assert.assertEquals(false, datapoint.getValue().boolValue());
    Assert.assertEquals(0, datapoint.getTimestamp());
    // set with timestamp update
    status = datapoint.setSourceValue(null, true);
    Assert.assertEquals(-1, status);
    Assert.assertEquals(false, datapoint.getValue().boolValue());
    Assert.assertEquals(0, datapoint.getSourceTimestamp());
    Assert.assertEquals(false, datapoint.getValue().boolValue());
    Assert.assertEquals(0, datapoint.getTimestamp());

    // REAL datapoint

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

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

    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);
   
    // set without timestamp
    value.boolValue(true);
    status = datapoint.setSourceValue(value, false);
    Assert.assertEquals(1, status);
    // source value is updated, source timestamp is not updated
    Assert.assertEquals(true, datapoint.getSourceValue().boolValue());
    Assert.assertEquals(0, datapoint.getSourceTimestamp());
    // output value/timestamp is synchronized with source value/timestamp
    Assert.assertEquals(true, datapoint.getValue().boolValue());
    Assert.assertEquals(0, datapoint.getTimestamp());
    // update-time is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);

    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);
   
    // set with timestamp
    value.boolValue(false);
    status = datapoint.setSourceValue(value, true);
    Assert.assertEquals(1, status);
    // source value is updated, source timestamp is set to current time
    Assert.assertEquals(false, datapoint.getSourceValue().boolValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() > updateTs);
    // ouput value/timestamp is synchronized with source value/timestamp
    Assert.assertEquals(false, datapoint.getValue().boolValue());
    Assert.assertEquals(datapoint.getSourceTimestamp(), datapoint
        .getTimestamp());
    // update-time is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);
    // TODO: check for the same value

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

    // initial value
    Assert.assertEquals(0, datapoint.getSourceValue().longValue());
    Assert.assertEquals(0, datapoint.getSourceTimestamp());
    Assert.assertEquals(0, datapoint.getValue().longValue());
    Assert.assertEquals(0, datapoint.getTimestamp());

    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);
   
    // set without timestamp
    value.longValue(11);
    status = datapoint.setSourceValue(value, false);
    Assert.assertEquals(1, status);
    // source value is updated, source timestamp is not updated
    Assert.assertEquals(11, datapoint.getSourceValue().longValue());
    Assert.assertEquals(0, datapoint.getSourceTimestamp());
    // output value/timestamp is synchronized with source value/timestamp
    Assert.assertEquals(11, datapoint.getValue().longValue());
    Assert.assertEquals(0, datapoint.getTimestamp());
    // update-time is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);

    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);
   
    // set with timestamp
    value.longValue(15);
    status = datapoint.setSourceValue(value, true);
    Assert.assertEquals(1, status);
    // source value is updated, source timestamp is set to current time
    Assert.assertEquals(15, datapoint.getSourceValue().longValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() > updateTs);
    // output value/timestamp is synchronized with source value/timestamp
    Assert.assertEquals(15, datapoint.getValue().longValue());
    Assert.assertEquals(datapoint.getSourceTimestamp(), datapoint
        .getTimestamp());
    // update-time is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);

    // TODO: check for the same value

    // real-unsigned datapoint
    datapoint = new DataPointImpl(CosDpValueTypeEnum.TypeUnsigned);
    datapoint.keyId = keyId++;
    datapoint.name = "real-unsigned";

    // initial value
    Assert.assertEquals(0, datapoint.getSourceValue().unsignedValue());
    Assert.assertEquals(0, datapoint.getSourceTimestamp());
    Assert.assertEquals(0, datapoint.getValue().unsignedValue());
    Assert.assertEquals(0, datapoint.getTimestamp());

    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);
   
    // set without timestamp
    value.unsignedValue(11);
    status = datapoint.setSourceValue(value, false);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11, datapoint.getSourceValue().unsignedValue());
    Assert.assertEquals(0, datapoint.getSourceTimestamp());
    Assert.assertEquals(11, datapoint.getValue().unsignedValue());
    Assert.assertEquals(0, datapoint.getTimestamp());
    // update-time is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);

    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);
   
    // set with timestamp
    value.longValue(15);
    status = datapoint.setSourceValue(value, true);
    Assert.assertEquals(1, status);
    Assert.assertEquals(15, datapoint.getSourceValue().unsignedValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() > updateTs);
    Assert.assertEquals(15, datapoint.getValue().unsignedValue());
    Assert.assertEquals(datapoint.getSourceTimestamp(), datapoint
        .getTimestamp());
    // update-time is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);

    // TODO: check for the same value

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

    // initial value
    Assert.assertEquals(0.0, datapoint.getSourceValue().dblValue());
    Assert.assertEquals(0, datapoint.getSourceTimestamp());
    Assert.assertEquals(0.0, datapoint.getValue().dblValue());
    Assert.assertEquals(0, datapoint.getTimestamp());

    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);
   
    // set without timestamp
    value.dblValue(11.5);
    status = datapoint.setSourceValue(value, false);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11.5, datapoint.getSourceValue().dblValue());
    Assert.assertEquals(0, datapoint.getSourceTimestamp());
    Assert.assertEquals(11.5, datapoint.getValue().dblValue());
    Assert.assertEquals(0, datapoint.getTimestamp());
    // update-time is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);

    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);
   
    // set with timestamp
    value.dblValue(15.7);
    status = datapoint.setSourceValue(value, true);
    Assert.assertEquals(1, status);
    Assert.assertEquals(15.7, datapoint.getSourceValue().dblValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() > updateTs);
    Assert.assertEquals(15.7, datapoint.getValue().dblValue());
    Assert.assertEquals(datapoint.getSourceTimestamp(), datapoint
        .getTimestamp());
    // update-time is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);

    // TODO: check for the same value

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

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

    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);
   
    // set without timestamp
    value.charValue("Test");
    status = datapoint.setSourceValue(value, false);
    Assert.assertEquals(1, status);
    Assert.assertTrue(datapoint.getSourceValue().charValue().compareTo(
        "Test") == 0);
    Assert.assertEquals(0, datapoint.getSourceTimestamp());
    Assert
        .assertTrue(datapoint.getValue().charValue().compareTo("Test") == 0);
    Assert.assertEquals(0, datapoint.getTimestamp());
    // update-time is set to current time
    Assert.assertTrue(datapoint.getUpdateTimestamp() > updateTs);

    updateTs = Calendar.getInstance().getTimeInMillis();
    sleep(1);
   
    // set with timestamp
    value.charValue("TestTest");
    status = datapoint.setSourceValue(value, true);
    Assert.assertEquals(1, status);
    Assert.assertTrue(datapoint.getSourceValue().charValue().compareTo(
        "TestTest") == 0);
    Assert.assertTrue(datapoint.getSourceTimestamp() > updateTs);
View Full Code Here

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

    CosDpValueUnion outValue = new CosDpValueUnion();

    CosDpValueUnion in_bool_value = new CosDpValueUnion();
    in_bool_value.boolValue(false);
    CosDpValueUnion in_number_value = new CosDpValueUnion();
    in_number_value.longValue(0);
    CosDpValueUnion in_unsigned_value = new CosDpValueUnion();
    in_unsigned_value.unsignedValue(0);
    CosDpValueUnion in_double_value = new CosDpValueUnion();
    in_double_value.dblValue(0.0);
    CosDpValueUnion in_string_value = new CosDpValueUnion();
    in_string_value.charValue("");

    // BOOLEAN data type
    // copy bool to bool (new value)
    outValue.boolValue(false);
    in_bool_value.boolValue(true);
    int status = datapoint._copy(outValue, in_bool_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(outValue.boolValue(), in_bool_value.boolValue());
    // copy bool to bool (the same value)
    outValue.boolValue(false);
    in_bool_value.boolValue(false);
    status = datapoint._copy(outValue, in_bool_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(outValue.boolValue(), in_bool_value.boolValue());
    // copy number to bool (value = 0)
    outValue.boolValue(false);
    in_number_value.longValue(0);
    status = datapoint._copy(outValue, in_number_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(false, outValue.boolValue());
    // copy number to bool (value = -1)
    outValue.boolValue(false);
    in_number_value.longValue(-1);
    status = datapoint._copy(outValue, in_number_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(true, outValue.boolValue());
    // copy number to bool (value = +1)
    outValue.boolValue(false);
    in_number_value.longValue(1);
    status = datapoint._copy(outValue, in_number_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(true, outValue.boolValue());
    // copy unsigned to bool (value = 0)
    outValue.boolValue(false);
    in_unsigned_value.unsignedValue(0);
    status = datapoint._copy(outValue, in_unsigned_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(false, outValue.boolValue());
    // copy unsigned to bool (value = +1)
    outValue.boolValue(false);
    in_unsigned_value.unsignedValue(1);
    status = datapoint._copy(outValue, in_unsigned_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(true, outValue.boolValue());
    // copy double to bool (value = 0)
    outValue.boolValue(false);
    in_double_value.dblValue(0);
    status = datapoint._copy(outValue, in_double_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(false, outValue.boolValue());
    // copy double to bool (value = -1.5)
    outValue.boolValue(false);
    in_double_value.dblValue(-1.5);
    status = datapoint._copy(outValue, in_double_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(true, outValue.boolValue());
    // copy double to bool (value = -1.5)
    outValue.boolValue(false);
    in_double_value.dblValue(1.5);
    status = datapoint._copy(outValue, in_double_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(true, outValue.boolValue());
    // copy string to bool (value = "")
    outValue.boolValue(false);
    in_string_value.charValue("");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(false, outValue.boolValue());
    // copy string to bool (value = "test")
    outValue.boolValue(false);
    in_string_value.charValue("test");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(true, outValue.boolValue());
    // copy string to bool (value = null)
    outValue.boolValue(false);
    in_string_value.charValue(null);
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(false, outValue.boolValue());

    // NUMBER data type
    // copy bool to number (value = true)
    outValue.longValue(0);
    in_bool_value.boolValue(true);
    status = datapoint._copy(outValue, in_bool_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(1, outValue.longValue());
    // copy bool to number (value = false)
    outValue.longValue(0);
    in_bool_value.boolValue(false);
    status = datapoint._copy(outValue, in_bool_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0, outValue.longValue());
    // copy number to number (value = 0, the same value)
    outValue.longValue(0);
    in_number_value.longValue(0);
    status = datapoint._copy(outValue, in_number_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0, outValue.longValue());
    // copy number to number (value = 0, the different value)
    outValue.longValue(1);
    in_number_value.longValue(0);
    status = datapoint._copy(outValue, in_number_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(0, outValue.longValue());
    // copy number to number (value = -1)
    outValue.longValue(0);
    in_number_value.longValue(-11);
    status = datapoint._copy(outValue, in_number_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(-11, outValue.longValue());
    // copy number to number (value = +1)
    outValue.longValue(0);
    in_number_value.longValue(11);
    status = datapoint._copy(outValue, in_number_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11, outValue.longValue());
    // copy unsigned to number (value = 0)
    outValue.longValue(0);
    in_unsigned_value.unsignedValue(0);
    status = datapoint._copy(outValue, in_unsigned_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0, outValue.longValue());
    // copy unsigned to number (value = +1)
    outValue.longValue(0);
    in_unsigned_value.unsignedValue(11);
    status = datapoint._copy(outValue, in_unsigned_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11, outValue.longValue());
    // copy double to number (value = 0)
    outValue.longValue(0);
    in_double_value.dblValue(0);
    status = datapoint._copy(outValue, in_double_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0, outValue.longValue());
    // copy double to number (value = -11.5)
    outValue.longValue(0);
    in_double_value.dblValue(-11.5);
    status = datapoint._copy(outValue, in_double_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(-11, outValue.longValue());
    // copy double to number (value = 11.5)
    outValue.longValue(0);
    in_double_value.dblValue(11.5);
    status = datapoint._copy(outValue, in_double_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11, outValue.longValue());
    // copy string to number (value = "")
    outValue.longValue(0);
    in_string_value.charValue("");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0, outValue.longValue());
    // copy string to number (value = "test")
    outValue.longValue(0);
    in_string_value.charValue("test");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0, outValue.longValue());
    // copy string to number (value = "11")
    outValue.longValue(0);
    in_string_value.charValue("11");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11, outValue.longValue());
    // copy string to number (value = "-11")
    outValue.longValue(0);
    in_string_value.charValue("-11");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(-11, outValue.longValue());
    // copy string to number (value = null)
    outValue.longValue(0);
    in_string_value.charValue(null);
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0, outValue.longValue());

    // UNSIGNED data type
    // copy bool to unsigned (value = true)
    outValue.unsignedValue(0);
    in_bool_value.boolValue(true);
    status = datapoint._copy(outValue, in_bool_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(1, outValue.unsignedValue());
    // copy bool to unsigned (value = false)
    outValue.unsignedValue(0);
    in_bool_value.boolValue(false);
    status = datapoint._copy(outValue, in_bool_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0, outValue.unsignedValue());
    // copy number to unsigned (value = 0)
    outValue.unsignedValue(0);
    in_number_value.longValue(0);
    status = datapoint._copy(outValue, in_number_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0, outValue.unsignedValue());
    // copy number to unsigned (value = -11)
    outValue.unsignedValue(0);
    in_number_value.longValue(-11);
    status = datapoint._copy(outValue, in_number_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11, outValue.unsignedValue());
    // copy number to unsigned (value = +11)
    outValue.unsignedValue(0);
    in_number_value.longValue(11);
    status = datapoint._copy(outValue, in_number_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11, outValue.unsignedValue());
    // copy unsigned to unsigned (value = 0, the same value)
    outValue.unsignedValue(0);
    in_unsigned_value.unsignedValue(0);
    status = datapoint._copy(outValue, in_unsigned_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0, outValue.unsignedValue());
    // copy unsigned to unsigned (value = 0, the different value)
    outValue.unsignedValue(11);
    in_unsigned_value.unsignedValue(0);
    status = datapoint._copy(outValue, in_unsigned_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(0, outValue.unsignedValue());
    // copy unsigned to unsigned (value = +11)
    outValue.unsignedValue(0);
    in_unsigned_value.unsignedValue(11);
    status = datapoint._copy(outValue, in_unsigned_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11, outValue.unsignedValue());
    // copy double to unsigned (value = 0)
    outValue.unsignedValue(0);
    in_double_value.dblValue(0);
    status = datapoint._copy(outValue, in_double_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0, outValue.unsignedValue());
    // copy double to unsigned (value = -11.5)
    outValue.unsignedValue(0);
    in_double_value.dblValue(-11.5);
    status = datapoint._copy(outValue, in_double_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11, outValue.unsignedValue());
    // copy double to unsigned (value = 11.5)
    outValue.unsignedValue(0);
    in_double_value.dblValue(11.5);
    status = datapoint._copy(outValue, in_double_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11, outValue.unsignedValue());
    // copy string to unsigned (value = "")
    outValue.unsignedValue(0);
    in_string_value.charValue("");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0, outValue.unsignedValue());
    // copy string to unsigned (value = "test")
    outValue.unsignedValue(0);
    in_string_value.charValue("test");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0, outValue.unsignedValue());
    // copy string to unsigned (value = "11")
    outValue.unsignedValue(0);
    in_string_value.charValue("11");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11, outValue.unsignedValue());
    // copy string to unsigned (value = "-11")
    outValue.unsignedValue(0);
    in_string_value.charValue("-11");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11, outValue.unsignedValue());
    // copy string to unsigned (value = null)
    outValue.unsignedValue(0);
    in_string_value.charValue(null);
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0, outValue.unsignedValue());

    // DOUBLE data type
    // copy bool to double (value = true)
    outValue.dblValue(0);
    in_bool_value.boolValue(true);
    status = datapoint._copy(outValue, in_bool_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(1.0, outValue.dblValue());
    // copy bool to double (value = false)
    outValue.dblValue(0);
    in_bool_value.boolValue(false);
    status = datapoint._copy(outValue, in_bool_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0.0, outValue.dblValue());
    // copy number to double (value = 0)
    outValue.dblValue(0);
    in_number_value.longValue(0);
    status = datapoint._copy(outValue, in_number_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0.0, outValue.dblValue());
    // copy number to double (value = -11)
    outValue.dblValue(0);
    in_number_value.longValue(-11);
    status = datapoint._copy(outValue, in_number_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(-11.0, outValue.dblValue());
    // copy number to double (value = +11)
    outValue.dblValue(0);
    in_number_value.longValue(11);
    status = datapoint._copy(outValue, in_number_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11.0, outValue.dblValue());
    // copy unsigned to double (value = 0, the same value)
    outValue.dblValue(0);
    in_unsigned_value.unsignedValue(0);
    status = datapoint._copy(outValue, in_unsigned_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0.0, outValue.dblValue());
    // copy unsigned to double (value = +11)
    outValue.dblValue(0);
    in_unsigned_value.unsignedValue(11);
    status = datapoint._copy(outValue, in_unsigned_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11.0, outValue.dblValue());
    // copy double to double (value = 0, the same value)
    outValue.dblValue(0);
    in_double_value.dblValue(0);
    status = datapoint._copy(outValue, in_double_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0.0, outValue.dblValue());
    // copy double to double (value = 0, different value)
    outValue.dblValue(11);
    in_double_value.dblValue(0);
    status = datapoint._copy(outValue, in_double_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(0.0, outValue.dblValue());
    // copy double to double (value = -11.5)
    outValue.dblValue(0);
    in_double_value.dblValue(-11.5);
    status = datapoint._copy(outValue, in_double_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(-11.5, outValue.dblValue());
    // copy double to double (value = 11.5)
    outValue.dblValue(0);
    in_double_value.dblValue(11.5);
    status = datapoint._copy(outValue, in_double_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11.5, outValue.dblValue());
    // copy string to double (value = "")
    outValue.dblValue(0);
    in_string_value.charValue("");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0.0, outValue.dblValue());
    // copy string to double (value = "test")
    outValue.dblValue(0);
    in_string_value.charValue("test");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0.0, outValue.dblValue());
    // copy string to double (value = "11.5")
    outValue.dblValue(0);
    in_string_value.charValue("11.5");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(11.5, outValue.dblValue());
    // copy string to double (value = "-11.5")
    outValue.dblValue(0);
    in_string_value.charValue("-11.5");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(1, status);
    Assert.assertEquals(-11.5, outValue.dblValue());
    // copy string to double (value = null)
    outValue.dblValue(0);
    in_string_value.charValue(null);
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(0, status);
    Assert.assertEquals(0.0, outValue.dblValue());

    // STRING data type
    // copy bool to string (value = true)
    outValue.charValue("");
    in_bool_value.boolValue(true);
    status = datapoint._copy(outValue, in_bool_value);
    Assert.assertEquals(1, status);
    Assert
        .assertTrue(outValue.charValue().compareToIgnoreCase("true") == 0);
    // copy bool to string (value = false)
    outValue.charValue("");
    in_bool_value.boolValue(false);
    status = datapoint._copy(outValue, in_bool_value);
    Assert.assertEquals(1, status);
    Assert
        .assertTrue(outValue.charValue().compareToIgnoreCase("false") == 0);
    // copy number to string (value = 0)
    outValue.charValue("");
    in_number_value.longValue(0);
    status = datapoint._copy(outValue, in_number_value);
    Assert.assertEquals(1, status);
    Assert.assertTrue(outValue.charValue().compareTo("0") == 0);
    // copy number to string (value = -11)
    outValue.charValue("");
    in_number_value.longValue(-11);
    status = datapoint._copy(outValue, in_number_value);
    Assert.assertEquals(1, status);
    Assert.assertTrue(outValue.charValue().compareTo("-11") == 0);
    // copy number to string (value = +11)
    outValue.charValue("");
    in_number_value.longValue(11);
    status = datapoint._copy(outValue, in_number_value);
    Assert.assertEquals(1, status);
    Assert.assertTrue(outValue.charValue().compareTo("11") == 0);
    // copy unsigned to string (value = 0, the same value)
    outValue.charValue("");
    in_unsigned_value.unsignedValue(0);
    status = datapoint._copy(outValue, in_unsigned_value);
    Assert.assertEquals(1, status);
    Assert.assertTrue(outValue.charValue().compareTo("0") == 0);
    // copy unsigned to string (value = +11)
    outValue.charValue("");
    in_unsigned_value.unsignedValue(11);
    status = datapoint._copy(outValue, in_unsigned_value);
    Assert.assertEquals(1, status);
    Assert.assertTrue(outValue.charValue().compareTo("11") == 0);
    // copy double to string (value = 0, the same value)
    outValue.charValue("");
    in_double_value.dblValue(0);
    status = datapoint._copy(outValue, in_double_value);
    Assert.assertEquals(1, status);
    Assert.assertTrue(outValue.charValue().compareTo("0.0") == 0);
    // copy double to string (value = -11.5)
    outValue.charValue("");
    in_double_value.dblValue(-11.5);
    status = datapoint._copy(outValue, in_double_value);
    Assert.assertEquals(1, status);
    Assert.assertTrue(outValue.charValue().compareTo("-11.5") == 0);
    // copy double to string (value = 11.5)
    outValue.charValue("");
    in_double_value.dblValue(11.5);
    status = datapoint._copy(outValue, in_double_value);
    Assert.assertEquals(1, status);
    Assert.assertTrue(outValue.charValue().compareTo("11.5") == 0);
    // copy string to string (value = "")
    outValue.charValue("");
    in_string_value.charValue("");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(0, status);
    Assert.assertTrue(outValue.charValue().compareTo("") == 0);
    // copy string to string (value = "Test")
    outValue.charValue("test");
    in_string_value.charValue("Test");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(1, status);
    Assert.assertTrue(outValue.charValue().compareTo("Test") == 0);
    // copy string to string (value = "Test", the same value)
    outValue.charValue("Test");
    in_string_value.charValue("Test");
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(0, status);
    Assert.assertTrue(outValue.charValue().compareTo("Test") == 0);
    // copy string to string (value = null)
    outValue.charValue("");
    in_string_value.charValue(null);
    status = datapoint._copy(outValue, in_string_value);
    Assert.assertEquals(0, status);
    Assert.assertTrue(outValue.charValue().compareTo("") == 0);

    // copy null to string (value = null)
    outValue.charValue("Test");
    status = datapoint._copy(outValue, null);
    Assert.assertEquals(-1, status);
    Assert.assertTrue(outValue.charValue().compareTo("Test") == 0);

    // copy string to string (value = null)
    in_string_value.charValue("Test");
    status = datapoint._copy(null, in_string_value);
    Assert.assertEquals(-1, status);
  }
View Full Code Here

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

    CosDpValueUnion value1 = new CosDpValueUnion();
    CosDpValueUnion value2 = new CosDpValueUnion();

    // BOOLEAN data type
    // bool to bool (different value)
    value1.boolValue(false);
    value2.boolValue(true);
    int status = datapoint._compare(value1, value2);
    Assert.assertEquals(1, status);
    // bool to bool (the same value)
    value1.boolValue(false);
    value2.boolValue(false);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(0, status);
    // bool to number
    value1.boolValue(false);
    value2.longValue(0);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // bool to unsigned
    value1.boolValue(false);
    value2.unsignedValue(0);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // bool to double
    value1.boolValue(false);
    value2.dblValue(0);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // bool to string
    value1.boolValue(false);
    value2.charValue("");
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);

    // NUMBER data type
    // number to bool (different value)
    value1.longValue(0);
    value2.boolValue(true);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // number to number
    value1.longValue(0);
    value2.longValue(0);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(0, status);
    // number to number (right side higher)
    value1.longValue(-11);
    value2.longValue(0);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // number to number (left side higher)
    value1.longValue(11);
    value2.longValue(0);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(1, status);
    // number to unsigned
    value1.longValue(0);
    value2.unsignedValue(0);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // number to double
    value1.longValue(0);
    value2.dblValue(0);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // number to string
    value1.longValue(0);
    value2.charValue("");
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);

    // UNSIGNED data type
    // unsigned to bool (different value)
    value1.unsignedValue(0);
    value2.boolValue(true);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // unsigned to number
    value1.unsignedValue(0);
    value2.longValue(0);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // unsigned to unsigned
    value1.unsignedValue(100);
    value2.unsignedValue(100);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(0, status);
    // unsigned to unsigned (right side higher)
    value1.unsignedValue(10);
    value2.unsignedValue(100);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // unsigned to unsigned (left side higher)
    value1.unsignedValue(110);
    value2.unsignedValue(100);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(1, status);
    // unsigned to double
    value1.unsignedValue(0);
    value2.dblValue(0);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // unsigned to string
    value1.unsignedValue(0);
    value2.charValue("");
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);

    // DOUBLE data type
    // double to bool (different value)
    value1.dblValue(0);
    value2.boolValue(true);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // double to number
    value1.dblValue(0);
    value2.longValue(0);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // double to unsigned
    value1.dblValue(100);
    value2.unsignedValue(100);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // double to double
    value1.dblValue(0);
    value2.dblValue(0);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(0, status);
    // double to double (right side higher)
    value1.dblValue(-10);
    value2.dblValue(0);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // double to double (left side higher)
    value1.dblValue(10);
    value2.dblValue(0);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(1, status);
    // double to string
    value1.dblValue(0);
    value2.charValue("");
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);

    // STRING data type
    // string to bool (different value)
    value1.charValue("");
    value2.boolValue(true);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // string to number
    value1.charValue("");
    value2.longValue(0);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // string to unsigned
    value1.dblValue(100);
    value2.unsignedValue(100);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // string to double
    value1.charValue("");
    value2.dblValue(0);
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // string to string
    value1.charValue("cdcd");
    value2.charValue("cdcd");
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(0, status);
    // string to string (right side higher)
    value1.charValue("abcd");
    value2.charValue("cdcd");
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // string to string (left side higher)
    value1.charValue("efcd");
    value2.charValue("cdcd");
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(1, status);
    // string to string (small letter to capital)
    value1.charValue("cdcd");
    value2.charValue("CDCD");
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(1, status);
    // string to string (right side is longer)
    value1.charValue("cdcd");
    value2.charValue("cdcdcd");
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(-1, status);
    // string to string (left side is longer)
    value1.charValue("cdcdcd");
    value2.charValue("cdcd");
    status = datapoint._compare(value1, value2);
    Assert.assertEquals(1, status);
  }
View Full Code Here

TOP

Related Classes of tcg.scada.cos.CosDpValueUnion

Copyright © 2018 www.massapicom. 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.