use of com.serotonin.m2m2.vo.event.detector.RateOfChangeDetectorVO 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.vo.event.detector.RateOfChangeDetectorVO in project ma-modules-public by infiniteautomation.
the class RateOfChangeEventDetectorModel method toVO.
@Override
public RateOfChangeDetectorVO toVO() {
RateOfChangeDetectorVO vo = super.toVO();
vo.setRateOfChangeThreshold(rateOfChangeThreshold);
if (rateOfChangeThresholdUnit != null) {
vo.setRateOfChangeThresholdPeriodType(TimePeriodType.convertFrom(rateOfChangeThresholdUnit));
}
vo.setUseResetThreshold(useResetThreshold);
vo.setResetThreshold(resetThreshold);
vo.setComparisonMode(comparisonMode);
vo.setCalculationMode(calculationMode);
if (this.calculationMode == CalculationMode.AVERAGE && rateOfChangePeriod != null) {
vo.setRateOfChangePeriods(rateOfChangePeriod.getPeriods());
vo.setRateOfChangePeriodType(TimePeriodType.convertFrom(rateOfChangePeriod.getType()));
} else {
vo.setRateOfChangePeriods(0);
vo.setRateOfChangePeriodType(Common.TimePeriods.SECONDS);
}
vo.setUseAbsoluteValue(useAbsoluteValue);
return vo;
}
use of com.serotonin.m2m2.vo.event.detector.RateOfChangeDetectorVO 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