Examples of VirtualDataPoint


Examples of tcg.scada.da.VirtualDataPoint

    //int intStatus = 0;
   
    // TODO: check for datastore notification!

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

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

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

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

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

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

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

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

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

    // set the source datapoint with new value (this will trigger the update
    // in the calculated point)
    source.setBooleanValue(true);
    // source value is updated, source timestamp is updated to current time
    Assert.assertEquals(true, datapoint.getSourceValue().boolValue());
    Assert.assertTrue(datapoint.getSourceTimestamp() > updateTs);
    Assert.assertEquals(CosDpQualityEnum.QualityGood, datapoint
        .getSourceQuality());
View Full Code Here

Examples of tcg.scada.da.VirtualDataPoint

   *
   */
  public void testLaunchConditionCheck()
  {
    // create LCC datapoint
    VirtualDataPoint lccDataPoint = new VirtualDataPoint(
        CosDpValueTypeEnum.TypeNumber);
    lccDataPoint.keyId = 1;
    lccDataPoint.name = "lcc-datapoint";

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

    // create output-boolean datapoint
    DataPointImpl datapoint = new DataPointImpl(
        CosDpValueTypeEnum.TypeBoolean);
    datapoint.keyId = 2;
    datapoint.name = "output-boolean";

    // set LCC expression
    boolean boolStatus = datapoint.setLaunchCondition(
        "{{lcc-datapoint}} == 4", dpList);
    Assert.assertTrue("set-lcc-expression", boolStatus);

    // set lcc datapoint to 3
    int intStatus = lccDataPoint.setNumberValue(3);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(3, lccDataPoint.getValue().longValue());

    // check for LCC (expected to fail -> 3 != 4)
    boolStatus = datapoint.checkLaunchCondition();
    Assert.assertFalse("check-lcc-expression", boolStatus);

    // set lcc datapoint to 4
    intStatus = lccDataPoint.setNumberValue(4);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(4, lccDataPoint.getValue().longValue());

    // check for LCC (expected to succeed -> 4 != 4)
    boolStatus = datapoint.checkLaunchCondition();
    Assert.assertTrue("check-lcc-expression", boolStatus);
  }
View Full Code Here

Examples of tcg.scada.da.VirtualDataPoint

   *
   */
  public void testReturnConditionCheck()
  {
    // create RCC datapoint
    VirtualDataPoint rccDataPoint = new VirtualDataPoint(
        CosDpValueTypeEnum.TypeNumber);
    rccDataPoint.keyId = 1;
    rccDataPoint.name = "rcc-datapoint";

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

    // create output-boolean datapoint
    DataPointImpl datapoint = new DataPointImpl(
        CosDpValueTypeEnum.TypeBoolean);
    datapoint.keyId = 2;
    datapoint.name = "output-boolean";

    // set RCC expression
    boolean boolStatus = datapoint.setReturnCondition(
        "{{rcc-datapoint}} == 4", dpList);
    Assert.assertTrue("set-rcc-expression", boolStatus);

    // set RCC datapoint to 3
    int intStatus = rccDataPoint.setNumberValue(3);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(3, rccDataPoint.getValue().longValue());

    // check for RCC (expected to fail -> 3 != 4)
    boolStatus = datapoint.checkReturnCondition();
    Assert.assertFalse("check-rcc-expression", boolStatus);

    // set RCC datapoint to 4
    intStatus = rccDataPoint.setNumberValue(4);
    Assert.assertEquals(1, intStatus);
    Assert.assertEquals(4, rccDataPoint.getValue().longValue());

    // check for RCC (expected to succeed -> 4 != 4)
    boolStatus = datapoint.checkReturnCondition();
    Assert.assertTrue("check-rcc-expression", boolStatus);
  }
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.