Search in sources :

Example 1 with RateOfChangeDetectorVO

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);
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) DataPointService(com.infiniteautomation.mango.spring.service.DataPointService) AbstractPointEventDetectorVO(com.serotonin.m2m2.vo.event.detector.AbstractPointEventDetectorVO) ArrayList(java.util.ArrayList) DataPointWithEventDetectors(com.serotonin.m2m2.vo.dataPoint.DataPointWithEventDetectors) RateOfChangeDetectorVO(com.serotonin.m2m2.vo.event.detector.RateOfChangeDetectorVO) RateOfChangeDetectorDefinition(com.serotonin.m2m2.module.definitions.event.detectors.RateOfChangeDetectorDefinition) MockPointLocatorVO(com.serotonin.m2m2.vo.dataPoint.MockPointLocatorVO)

Example 2 with RateOfChangeDetectorVO

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;
}
Also used : RateOfChangeDetectorVO(com.serotonin.m2m2.vo.event.detector.RateOfChangeDetectorVO)

Example 3 with RateOfChangeDetectorVO

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);
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) DataPointService(com.infiniteautomation.mango.spring.service.DataPointService) AbstractPointEventDetectorVO(com.serotonin.m2m2.vo.event.detector.AbstractPointEventDetectorVO) ArrayList(java.util.ArrayList) DataPointWithEventDetectors(com.serotonin.m2m2.vo.dataPoint.DataPointWithEventDetectors) RateOfChangeDetectorVO(com.serotonin.m2m2.vo.event.detector.RateOfChangeDetectorVO) RateOfChangeDetectorDefinition(com.serotonin.m2m2.module.definitions.event.detectors.RateOfChangeDetectorDefinition) MockPointLocatorVO(com.serotonin.m2m2.vo.dataPoint.MockPointLocatorVO)

Aggregations

RateOfChangeDetectorVO (com.serotonin.m2m2.vo.event.detector.RateOfChangeDetectorVO)3 DataPointService (com.infiniteautomation.mango.spring.service.DataPointService)2 RateOfChangeDetectorDefinition (com.serotonin.m2m2.module.definitions.event.detectors.RateOfChangeDetectorDefinition)2 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)2 DataPointWithEventDetectors (com.serotonin.m2m2.vo.dataPoint.DataPointWithEventDetectors)2 MockPointLocatorVO (com.serotonin.m2m2.vo.dataPoint.MockPointLocatorVO)2 AbstractPointEventDetectorVO (com.serotonin.m2m2.vo.event.detector.AbstractPointEventDetectorVO)2 ArrayList (java.util.ArrayList)2