use of com.serotonin.m2m2.vo.dataPoint.DataPointWithEventDetectors in project ma-modules-public by infiniteautomation.
the class SerialDataSourceTestData method getNewlineTerminated.
public static DataPointRT getNewlineTerminated(DataSourceRT<? extends DataSourceVO> ds) {
DataPointVO vo = new DataPointVO();
vo.setName("newlineTerminated");
vo.setXid("newlineTerminated");
vo.setId(currentId++);
vo.setDataSourceId(ds.getId());
SerialPointLocatorVO plVo = new SerialPointLocatorVO();
plVo.setDataType(DataType.ALPHANUMERIC);
plVo.setValueRegex(PATTERNS.get(vo.getName()));
plVo.setValueIndex(2);
plVo.setPointIdentifier("");
vo.setPointLocator(plVo);
return new DataPointRT(new DataPointWithEventDetectors(vo, new ArrayList<>()), plVo.createRuntime(), ds, null, Common.getBean(PointValueDao.class), Common.getBean(PointValueCache.class), null);
}
use of com.serotonin.m2m2.vo.dataPoint.DataPointWithEventDetectors in project ma-core-public by infiniteautomation.
the class RateOfChangeDetectorTest method testDifferentThresholdPeriodToAverage.
/**
* Change of 1.0/s in 10 seconds
*/
@Test
public void testDifferentThresholdPeriodToAverage() {
DataPointWithEventDetectors dp = createDisabledPoint(1.0, 0.5, TimePeriods.SECONDS, false, CalculationMode.AVERAGE, 10, TimePeriods.SECONDS, ComparisonMode.GREATER_THAN, 0, TimePeriods.SECONDS);
// Save some values
PointValueDao dao = Common.getBean(PointValueDao.class);
dao.savePointValueSync(dp.getDataPoint(), new PointValueTime(0.0, 0));
dao.savePointValueSync(dp.getDataPoint(), new PointValueTime(0.1, 1000));
dao.savePointValueSync(dp.getDataPoint(), new PointValueTime(0.2, 2000));
dao.savePointValueSync(dp.getDataPoint(), new PointValueTime(0.3, 3000));
timer.fastForwardTo(10000);
dp.getDataPoint().setEnabled(true);
Common.runtimeManager.startDataPoint(dp);
DataPointRT rt = Common.runtimeManager.getDataPoint(dp.getDataPoint().getId());
timer.fastForwardTo(10999);
assertEquals(0, listener.raised.size());
assertEquals(0, listener.rtn.size());
ensureSetPointValue(rt, new PointValueTime(10.3, timer.currentTimeMillis()));
timer.fastForwardTo(11000);
assertEquals(1, listener.raised.size());
assertEquals(10999, listener.raised.get(0).getActiveTimestamp());
assertEquals(0, listener.rtn.size());
ensureSetPointValue(rt, new PointValueTime(11.3, timer.currentTimeMillis()));
timer.fastForwardTo(13000);
// Nothing raised as our change is only 1 in the last 10s
assertEquals(1, listener.raised.size());
assertEquals(0, listener.rtn.size());
ensureSetPointValue(rt, new PointValueTime(21.4, timer.currentTimeMillis()));
timer.fastForwardTo(13999);
assertEquals(1, listener.raised.size());
assertEquals(0, listener.rtn.size());
// Allow reset of alarm after 10s and no change
timer.fastForwardTo(26000);
assertEquals(1, listener.rtn.size());
assertEquals(23000, (long) listener.rtn.get(0).getRtnTimestamp());
ensureSetPointValue(rt, new PointValueTime(41.4, timer.currentTimeMillis()));
timer.fastForwardTo(33000);
assertEquals(2, listener.raised.size());
assertEquals(26000, listener.raised.get(1).getActiveTimestamp());
assertEquals(1, listener.rtn.size());
}
use of com.serotonin.m2m2.vo.dataPoint.DataPointWithEventDetectors in project ma-core-public by infiniteautomation.
the class RateOfChangeDetectorTest method testOneSecondPeriodTwoInitialValuesTwoValuesInRange.
@Test
public void testOneSecondPeriodTwoInitialValuesTwoValuesInRange() {
DataPointWithEventDetectors dp = createDisabledPoint(1.0, null, TimePeriods.SECONDS, false, CalculationMode.INSTANTANEOUS, 0, TimePeriods.SECONDS, ComparisonMode.GREATER_THAN, 0, TimePeriods.SECONDS);
// Save some values
PointValueDao dao = Common.getBean(PointValueDao.class);
dao.savePointValueSync(dp.getDataPoint(), new PointValueTime(0.001, 0));
dao.savePointValueSync(dp.getDataPoint(), new PointValueTime(0.0003, 100));
timer.fastForwardTo(timer.currentTimeMillis() + 200);
dp.getDataPoint().setEnabled(true);
Common.runtimeManager.startDataPoint(dp);
DataPointRT rt = Common.runtimeManager.getDataPoint(dp.getDataPoint().getId());
ensureSetPointValue(rt, new PointValueTime(0.0005, timer.currentTimeMillis()));
timer.fastForwardTo(timer.currentTimeMillis() + 500);
ensureSetPointValue(rt, new PointValueTime(0.0009, timer.currentTimeMillis()));
timer.fastForwardTo(timer.currentTimeMillis() + 4500);
assertEquals(0, listener.raised.size());
assertEquals(0, listener.rtn.size());
}
use of com.serotonin.m2m2.vo.dataPoint.DataPointWithEventDetectors in project ma-core-public by infiniteautomation.
the class RateOfChangeDetectorTest method testOneSecondPeriodTwoInitialValuesOneValueOutOfRangeForOneSecondAverage.
/**
* Settings:
* RoC Threshold: 1.0/Second
* reset Threshold: none
* RoC Averaging Period: 1 Second
* useAbsoluteValue: false
* calculationMode: AVERAGE
* comparisonMode: GREATER_THAN
* duration: 1 Seconds
*
* Initial value(s): 0.1 at 0, 1.101 at 100
*
* Test:
* advance to 1000 and start point, ensure no events raised
* set value to 2.5 at 1000
* advance to 1001 ensure no events raised
* advance to 2000
*
* Result: No events raised
*/
@Test
public void testOneSecondPeriodTwoInitialValuesOneValueOutOfRangeForOneSecondAverage() {
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(1001);
assertEquals(0, listener.raised.size());
assertEquals(0, listener.rtn.size());
timer.fastForwardTo(2000);
assertEquals(1, listener.raised.size());
assertEquals(2000, listener.raised.get(0).getActiveTimestamp());
assertEquals(1, listener.rtn.size());
assertEquals(2000, (long) listener.rtn.get(0).getRtnTimestamp());
}
use of com.serotonin.m2m2.vo.dataPoint.DataPointWithEventDetectors in project ma-core-public by infiniteautomation.
the class RateOfChangeDetectorTest method testOneSecondPeriodTwoInitialValuesTwoValuesOutOfRangeResetAverage.
@Test
public void testOneSecondPeriodTwoInitialValuesTwoValuesOutOfRangeResetAverage() {
DataPointWithEventDetectors dp = createDisabledPoint(1.0, 0.9, TimePeriods.SECONDS, false, CalculationMode.AVERAGE, 1, TimePeriods.SECONDS, ComparisonMode.GREATER_THAN, 0, TimePeriods.SECONDS);
// Save some values
PointValueDao dao = Common.getBean(PointValueDao.class);
dao.savePointValueSync(dp.getDataPoint(), new PointValueTime(0.0, 0));
dao.savePointValueSync(dp.getDataPoint(), new PointValueTime(1.1, 100));
timer.fastForwardTo(1000);
dp.getDataPoint().setEnabled(true);
Common.runtimeManager.startDataPoint(dp);
DataPointRT rt = Common.runtimeManager.getDataPoint(dp.getDataPoint().getId());
timer.fastForwardTo(1500);
assertEquals(1, listener.raised.size());
assertEquals(1000, listener.raised.get(0).getActiveTimestamp());
assertEquals(1, listener.rtn.size());
assertEquals(1100, (long) listener.rtn.get(0).getRtnTimestamp());
ensureSetPointValue(rt, new PointValueTime(0.5, timer.currentTimeMillis()));
timer.fastForwardTo(2000);
ensureSetPointValue(rt, new PointValueTime(0.9, timer.currentTimeMillis()));
timer.fastForwardTo(4500);
assertEquals(1, listener.rtn.size());
assertEquals(1, listener.raised.size());
}
Aggregations