use of com.serotonin.m2m2.module.definitions.event.detectors.RateOfChangeDetectorDefinition in project ma-core-public by MangoAutomation.
the class RateOfChangeDetectorTest method createDisabledPoint.
/**
* Create a point in the database that is not running.
*
* NOTE: The poll period is 1s for the data source
*/
protected DataPointWithEventDetectors createDisabledPoint(double rocThreshold, Double resetThreshold, int rocThresholdPeriodType, boolean useAbsoluteValue, CalculationMode calculationMode, int rocDuration, int rocDurationType, ComparisonMode comparisonMode, int durationPeriods, int durationPeriodType) {
// Create point locator
MockPointLocatorVO plVo = new MockPointLocatorVO(DataType.NUMERIC, true);
// Setup Data Point VO
DataPointVO dpVo = new DataPointVO();
dpVo.setName("Test");
dpVo.setXid("DP_1");
dpVo.setEnabled(false);
dpVo.setLoggingType(DataPointVO.LoggingTypes.ALL);
dpVo.setPointLocator(plVo);
dpVo.setDataSourceId(dsVo.getId());
// Setup our ROC Detector
RateOfChangeDetectorVO rocVo = new RateOfChangeDetectorVO(dpVo);
rocVo.setXid(EventDetectorDao.getInstance().generateUniqueXid());
rocVo.setDefinition(new RateOfChangeDetectorDefinition());
rocVo.setRateOfChangeThreshold(rocThreshold);
rocVo.setRateOfChangeThresholdPeriodType(rocThresholdPeriodType);
if (resetThreshold != null) {
rocVo.setUseResetThreshold(true);
rocVo.setResetThreshold(resetThreshold);
}
rocVo.setRateOfChangePeriods(rocDuration);
rocVo.setRateOfChangePeriodType(rocDurationType);
rocVo.setComparisonMode(comparisonMode);
rocVo.setCalculationMode(calculationMode);
rocVo.setUseAbsoluteValue(useAbsoluteValue);
rocVo.setDuration(durationPeriods);
rocVo.setDurationType(durationPeriodType);
validate(rocVo);
DataPointService service = Common.getBean(DataPointService.class);
validate(dpVo);
service.insert(dpVo);
rocVo.setSourceId(dpVo.getId());
EventDetectorDao.getInstance().insert(rocVo);
List<AbstractPointEventDetectorVO> eventDetectors = new ArrayList<>();
eventDetectors.add(rocVo);
return new DataPointWithEventDetectors(dpVo, eventDetectors);
}
use of com.serotonin.m2m2.module.definitions.event.detectors.RateOfChangeDetectorDefinition in project ma-core-public by infiniteautomation.
the class RateOfChangeDetectorTest method createDisabledPoint.
/**
* Create a point in the database that is not running.
*
* NOTE: The poll period is 1s for the data source
*/
protected DataPointWithEventDetectors createDisabledPoint(double rocThreshold, Double resetThreshold, int rocThresholdPeriodType, boolean useAbsoluteValue, CalculationMode calculationMode, int rocDuration, int rocDurationType, ComparisonMode comparisonMode, int durationPeriods, int durationPeriodType) {
// Create point locator
MockPointLocatorVO plVo = new MockPointLocatorVO(DataType.NUMERIC, true);
// Setup Data Point VO
DataPointVO dpVo = new DataPointVO();
dpVo.setName("Test");
dpVo.setXid("DP_1");
dpVo.setEnabled(false);
dpVo.setLoggingType(DataPointVO.LoggingTypes.ALL);
dpVo.setPointLocator(plVo);
dpVo.setDataSourceId(dsVo.getId());
// Setup our ROC Detector
RateOfChangeDetectorVO rocVo = new RateOfChangeDetectorVO(dpVo);
rocVo.setXid(EventDetectorDao.getInstance().generateUniqueXid());
rocVo.setDefinition(new RateOfChangeDetectorDefinition());
rocVo.setRateOfChangeThreshold(rocThreshold);
rocVo.setRateOfChangeThresholdPeriodType(rocThresholdPeriodType);
if (resetThreshold != null) {
rocVo.setUseResetThreshold(true);
rocVo.setResetThreshold(resetThreshold);
}
rocVo.setRateOfChangePeriods(rocDuration);
rocVo.setRateOfChangePeriodType(rocDurationType);
rocVo.setComparisonMode(comparisonMode);
rocVo.setCalculationMode(calculationMode);
rocVo.setUseAbsoluteValue(useAbsoluteValue);
rocVo.setDuration(durationPeriods);
rocVo.setDurationType(durationPeriodType);
validate(rocVo);
DataPointService service = Common.getBean(DataPointService.class);
validate(dpVo);
service.insert(dpVo);
rocVo.setSourceId(dpVo.getId());
EventDetectorDao.getInstance().insert(rocVo);
List<AbstractPointEventDetectorVO> eventDetectors = new ArrayList<>();
eventDetectors.add(rocVo);
return new DataPointWithEventDetectors(dpVo, eventDetectors);
}
Aggregations