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());
}
Aggregations