Search in sources :

Example 1 with AnalogChangeDetectorVO

use of com.serotonin.m2m2.vo.event.detector.AnalogChangeDetectorVO in project ma-core-public by infiniteautomation.

the class DataPointEditDwr method updateAnalogChangeDetector.

@DwrPermission(user = true)
public void updateAnalogChangeDetector(int pedId, String xid, String alias, double limit, boolean checkIncrease, boolean checkDecrease, int duration, int durationType, int alarmLevel, int updateEvent) {
    AnalogChangeDetectorVO ped = (AnalogChangeDetectorVO) getEventDetector(pedId);
    ped.setXid(xid);
    ped.setName(alias);
    ped.setLimit(limit);
    ped.setCheckIncrease(checkIncrease);
    ped.setCheckDecrease(checkDecrease);
    ped.setDuration(duration);
    ped.setDurationType(durationType);
    ped.setAlarmLevel(alarmLevel);
    ped.setUpdateEvent(updateEvent);
}
Also used : AnalogChangeDetectorVO(com.serotonin.m2m2.vo.event.detector.AnalogChangeDetectorVO) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 2 with AnalogChangeDetectorVO

use of com.serotonin.m2m2.vo.event.detector.AnalogChangeDetectorVO in project ma-modules-public by infiniteautomation.

the class AnalogChangeEventDetectorModel method toVO.

@Override
public AnalogChangeDetectorVO toVO() {
    AnalogChangeDetectorVO vo = super.toVO();
    vo.setLimit(limit);
    vo.setCheckIncrease(checkIncrease);
    vo.setCheckDecrease(checkDecrease);
    vo.setUpdateEvent(AnalogChangeDetectorVO.UPDATE_EVENT_TYPE_CODES.getId(updateEvent));
    return vo;
}
Also used : AnalogChangeDetectorVO(com.serotonin.m2m2.vo.event.detector.AnalogChangeDetectorVO)

Example 3 with AnalogChangeDetectorVO

use of com.serotonin.m2m2.vo.event.detector.AnalogChangeDetectorVO in project ma-core-public by infiniteautomation.

the class EmailHandlerRTTest method createDataPointEventInstance.

protected EventInstance createDataPointEventInstance() {
    DataPointEventType type = new DataPointEventType(1, 1);
    Map<String, Object> context = new HashMap<String, Object>();
    DataPointVO dp = new DataPointVO();
    dp.setDataSourceName("test data source");
    dp.setTags(new HashMap<>());
    AnalogChangeDetectorVO ped = new AnalogChangeDetectorVO(dp);
    context.put("pointEventDetector", ped);
    context.put("point", dp);
    EventInstance instance = new EventInstance(type, this.timer.currentTimeMillis(), true, AlarmLevels.CRITICAL, new TranslatableMessage("common.default", "testing"), context);
    return instance;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) EventInstance(com.serotonin.m2m2.rt.event.EventInstance) AnalogChangeDetectorVO(com.serotonin.m2m2.vo.event.detector.AnalogChangeDetectorVO) HashMap(java.util.HashMap) TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage) DataPointEventType(com.serotonin.m2m2.rt.event.type.DataPointEventType)

Example 4 with AnalogChangeDetectorVO

use of com.serotonin.m2m2.vo.event.detector.AnalogChangeDetectorVO in project ma-core-public by infiniteautomation.

the class EventInstanceWithTagsQueryTest method before.

@Before
public void before() {
    super.before();
    service = Common.getBean(EventInstanceService.class);
    eventDetectorsService = Common.getBean(EventDetectorsService.class);
    dao = Common.getBean(EventDao.class);
    roleService = Common.getBean(RoleService.class);
    runAs = Common.getBean(RunAs.class);
    setupRoles();
    AtomicInteger count = new AtomicInteger();
    List<String> tagKeys = Stream.generate(() -> "key" + count.getAndIncrement()).limit(2).collect(Collectors.toList());
    allTags = tagKeys.stream().collect(Collectors.toMap(Function.identity(), k -> k + "_value" + random.nextInt(10)));
    MockDataSourceVO ds = createMockDataSource(true);
    // Insert 2 data points
    point1 = createMockDataPoint(ds, (dp) -> {
        key1 = tagKeys.get(0);
        value1 = allTags.get(tagKeys.get(0));
        Map<String, String> tags = new HashMap<>();
        tags.put(key1, value1);
        dp.setTags(tags);
        dp.setReadPermission(MangoPermission.requireAllRoles(point1ReadRole));
    });
    point2 = createMockDataPoint(ds, (dp) -> {
        key2 = tagKeys.get(1);
        value2 = allTags.get(tagKeys.get(1));
        Map<String, String> tags = new HashMap<>();
        tags.put(key2, value2);
        dp.setTags(tags);
        dp.setReadPermission(MangoPermission.requireAllRoles(point2ReadRole));
    });
    // Create the event detectors
    runAs.runAs(runAs.systemSuperadmin(), () -> {
        AnalogChangeEventDetectorDefinition definition = (AnalogChangeEventDetectorDefinition) ModuleRegistry.getEventDetectorDefinition(AnalogChangeEventDetectorDefinition.TYPE_NAME);
        AnalogChangeDetectorVO detector = definition.baseCreateEventDetectorVO(point1);
        detector.setName("Detector for point " + point1.getName());
        eventDetectorsService.insert(detector);
        detector1 = detector;
    });
    runAs.runAs(runAs.systemSuperadmin(), () -> {
        AnalogChangeEventDetectorDefinition definition = (AnalogChangeEventDetectorDefinition) ModuleRegistry.getEventDetectorDefinition(AnalogChangeEventDetectorDefinition.TYPE_NAME);
        AnalogChangeDetectorVO detector = definition.baseCreateEventDetectorVO(point2);
        detector.setName("Detector for point " + point2.getName());
        eventDetectorsService.insert(detector);
        detector2 = detector;
    });
}
Also used : Role(com.serotonin.m2m2.vo.role.Role) EventInstance(com.serotonin.m2m2.rt.event.EventInstance) MockDataSourceVO(com.serotonin.m2m2.vo.dataSource.mock.MockDataSourceVO) AnalogChangeEventDetectorDefinition(com.serotonin.m2m2.module.definitions.event.detectors.AnalogChangeEventDetectorDefinition) HashMap(java.util.HashMap) Random(java.util.Random) Function(java.util.function.Function) DataPointVO(com.serotonin.m2m2.vo.DataPointVO) ArrayList(java.util.ArrayList) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AbstractPointEventDetectorVO(com.serotonin.m2m2.vo.event.detector.AbstractPointEventDetectorVO) Map(java.util.Map) RoleVO(com.serotonin.m2m2.vo.role.RoleVO) MangoTestBase(com.serotonin.m2m2.MangoTestBase) ConditionSortLimitWithTagKeys(com.infiniteautomation.mango.db.query.ConditionSortLimitWithTagKeys) Before(org.junit.Before) RunAs(com.infiniteautomation.mango.spring.components.RunAs) Common(com.serotonin.m2m2.Common) RQLUtils(com.infiniteautomation.mango.util.RQLUtils) EventDao(com.serotonin.m2m2.db.dao.EventDao) TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage) AnalogChangeDetectorVO(com.serotonin.m2m2.vo.event.detector.AnalogChangeDetectorVO) Test(org.junit.Test) Collectors(java.util.stream.Collectors) ModuleRegistry(com.serotonin.m2m2.module.ModuleRegistry) DataPointEventType(com.serotonin.m2m2.rt.event.type.DataPointEventType) List(java.util.List) Stream(java.util.stream.Stream) ASTNode(net.jazdw.rql.parser.ASTNode) MangoPermission(com.infiniteautomation.mango.permission.MangoPermission) Assert(org.junit.Assert) AlarmLevels(com.serotonin.m2m2.rt.event.AlarmLevels) User(com.serotonin.m2m2.vo.User) MockDataSourceVO(com.serotonin.m2m2.vo.dataSource.mock.MockDataSourceVO) AnalogChangeDetectorVO(com.serotonin.m2m2.vo.event.detector.AnalogChangeDetectorVO) RunAs(com.infiniteautomation.mango.spring.components.RunAs) EventDao(com.serotonin.m2m2.db.dao.EventDao) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HashMap(java.util.HashMap) Map(java.util.Map) AnalogChangeEventDetectorDefinition(com.serotonin.m2m2.module.definitions.event.detectors.AnalogChangeEventDetectorDefinition) Before(org.junit.Before)

Aggregations

AnalogChangeDetectorVO (com.serotonin.m2m2.vo.event.detector.AnalogChangeDetectorVO)4 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)2 EventInstance (com.serotonin.m2m2.rt.event.EventInstance)2 DataPointEventType (com.serotonin.m2m2.rt.event.type.DataPointEventType)2 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)2 HashMap (java.util.HashMap)2 ConditionSortLimitWithTagKeys (com.infiniteautomation.mango.db.query.ConditionSortLimitWithTagKeys)1 MangoPermission (com.infiniteautomation.mango.permission.MangoPermission)1 RunAs (com.infiniteautomation.mango.spring.components.RunAs)1 RQLUtils (com.infiniteautomation.mango.util.RQLUtils)1 Common (com.serotonin.m2m2.Common)1 MangoTestBase (com.serotonin.m2m2.MangoTestBase)1 EventDao (com.serotonin.m2m2.db.dao.EventDao)1 ModuleRegistry (com.serotonin.m2m2.module.ModuleRegistry)1 AnalogChangeEventDetectorDefinition (com.serotonin.m2m2.module.definitions.event.detectors.AnalogChangeEventDetectorDefinition)1 AlarmLevels (com.serotonin.m2m2.rt.event.AlarmLevels)1 User (com.serotonin.m2m2.vo.User)1 MockDataSourceVO (com.serotonin.m2m2.vo.dataSource.mock.MockDataSourceVO)1 AbstractPointEventDetectorVO (com.serotonin.m2m2.vo.event.detector.AbstractPointEventDetectorVO)1 Role (com.serotonin.m2m2.vo.role.Role)1