Search in sources :

Example 56 with DataPointWithEventDetectors

use of com.serotonin.m2m2.vo.dataPoint.DataPointWithEventDetectors in project ma-core-public by MangoAutomation.

the class RateOfChangeDetectorTest method testOneSecondPeriodTwoInitialValuesTwoValuesOutOfRangeForOneSecondAverage.

@Test
public void testOneSecondPeriodTwoInitialValuesTwoValuesOutOfRangeForOneSecondAverage() {
    DataPointWithEventDetectors dp = createDisabledPoint(1.0, null, TimePeriods.SECONDS, false, CalculationMode.AVERAGE, 1, TimePeriods.SECONDS, ComparisonMode.GREATER_THAN, 1, TimePeriods.SECONDS);
    // Save some values
    PointValueDao dao = Common.getBean(PointValueDao.class);
    dao.savePointValueSync(dp.getDataPoint(), new PointValueTime(0.1, 0));
    dao.savePointValueSync(dp.getDataPoint(), new PointValueTime(1.101, 100));
    timer.fastForwardTo(1000);
    dp.getDataPoint().setEnabled(true);
    Common.runtimeManager.startDataPoint(dp);
    DataPointRT rt = Common.runtimeManager.getDataPoint(dp.getDataPoint().getId());
    assertEquals(0, listener.raised.size());
    ensureSetPointValue(rt, new PointValueTime(2.5, timer.currentTimeMillis()));
    timer.fastForwardTo(1500);
    assertEquals(0, listener.raised.size());
    assertEquals(0, listener.rtn.size());
    ensureSetPointValue(rt, new PointValueTime(3.6, timer.currentTimeMillis()));
    timer.fastForwardTo(2000);
    assertEquals(1, listener.raised.size());
    assertEquals(2000, listener.raised.get(0).getActiveTimestamp());
    assertEquals(0, listener.rtn.size());
    timer.fastForwardTo(3000);
    assertEquals(1, listener.raised.size());
    assertEquals(1, listener.rtn.size());
    assertEquals(2500, (long) listener.rtn.get(0).getRtnTimestamp());
}
Also used : PointValueDao(com.serotonin.m2m2.db.dao.PointValueDao) DataPointRT(com.serotonin.m2m2.rt.dataImage.DataPointRT) PointValueTime(com.serotonin.m2m2.rt.dataImage.PointValueTime) DataPointWithEventDetectors(com.serotonin.m2m2.vo.dataPoint.DataPointWithEventDetectors) Test(org.junit.Test)

Aggregations

DataPointWithEventDetectors (com.serotonin.m2m2.vo.dataPoint.DataPointWithEventDetectors)54 DataPointRT (com.serotonin.m2m2.rt.dataImage.DataPointRT)29 PointValueDao (com.serotonin.m2m2.db.dao.PointValueDao)25 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)24 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)22 Test (org.junit.Test)22 ArrayList (java.util.ArrayList)20 AbstractPointEventDetectorVO (com.serotonin.m2m2.vo.event.detector.AbstractPointEventDetectorVO)18 PointValueCache (com.infiniteautomation.mango.pointvaluecache.PointValueCache)7 ValidationException (com.infiniteautomation.mango.util.exception.ValidationException)6 JsonException (com.serotonin.json.JsonException)6 HashMap (java.util.HashMap)5 NotFoundException (com.infiniteautomation.mango.util.exception.NotFoundException)4 JsonArray (com.serotonin.json.type.JsonArray)4 TranslatableJsonException (com.serotonin.m2m2.i18n.TranslatableJsonException)4 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)4 IDataPointValueSource (com.serotonin.m2m2.rt.dataImage.IDataPointValueSource)4 MockPointLocatorVO (com.serotonin.m2m2.vo.dataPoint.MockPointLocatorVO)4 SerialPointLocatorVO (com.infiniteautomation.serial.vo.SerialPointLocatorVO)3 DataPointChangeDefinition (com.serotonin.m2m2.module.definitions.dataPoint.DataPointChangeDefinition)3