Search in sources :

Example 21 with AlarmLevels

use of com.serotonin.m2m2.rt.event.AlarmLevels in project ma-core-public by infiniteautomation.

the class EventInstanceWithTagsQueryTest method createDataPointEventInstance.

protected EventInstance createDataPointEventInstance(DataPointVO point, AbstractPointEventDetectorVO detector, AlarmLevels level) {
    DataPointEventType type = new DataPointEventType(point, detector);
    Map<String, Object> context = new HashMap<String, Object>();
    context.put("pointEventDetector", detector);
    context.put("point", point);
    EventInstance instance = new EventInstance(type, this.timer.currentTimeMillis(), true, level, new TranslatableMessage("common.default", "testing"), context);
    return instance;
}
Also used : EventInstance(com.serotonin.m2m2.rt.event.EventInstance) HashMap(java.util.HashMap) TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage) DataPointEventType(com.serotonin.m2m2.rt.event.type.DataPointEventType)

Example 22 with AlarmLevels

use of com.serotonin.m2m2.rt.event.AlarmLevels in project ma-core-public by infiniteautomation.

the class EventInstanceDaoTest method testPurgeEventsBeforeByAlarmLevel.

@Test
public void testPurgeEventsBeforeByAlarmLevel() {
    long refTime = System.currentTimeMillis();
    createEvents(10, 2, refTime);
    assertEquals(10, eventDao.getEventCount());
    assertEquals(20, userCommentDao.count());
    AlarmLevels alarmLevel = newVO().getAlarmLevel();
    int count = eventDao.purgeEventsBefore(refTime, alarmLevel);
    assertEquals(5, count);
    assertEquals(5, eventDao.getEventCount());
    assertEquals(10, userCommentDao.count());
}
Also used : AlarmLevels(com.serotonin.m2m2.rt.event.AlarmLevels) Test(org.junit.Test)

Example 23 with AlarmLevels

use of com.serotonin.m2m2.rt.event.AlarmLevels in project ma-core-public by infiniteautomation.

the class DataSourceVO method jsonWrite.

@Override
public void jsonWrite(ObjectWriter writer) throws IOException, JsonException {
    super.jsonWrite(writer);
    // Write the type
    writer.writeEntry("type", this.definition.getDataSourceTypeName());
    ExportCodes eventCodes = getEventCodes();
    if (eventCodes != null && eventCodes.size() > 0) {
        Map<String, String> alarmCodeLevels = new HashMap<>();
        for (int i = 0; i < eventCodes.size(); i++) {
            int eventId = eventCodes.getId(i);
            AlarmLevels level = getAlarmLevel(eventId, AlarmLevels.URGENT);
            alarmCodeLevels.put(eventCodes.getCode(eventId), level.name());
        }
        writer.writeEntry("alarmLevels", alarmCodeLevels);
    }
    writer.writeEntry("purgeType", Common.TIME_PERIOD_CODES.getCode(purgeType));
}
Also used : ExportCodes(com.serotonin.m2m2.util.ExportCodes) HashMap(java.util.HashMap) AlarmLevels(com.serotonin.m2m2.rt.event.AlarmLevels)

Example 24 with AlarmLevels

use of com.serotonin.m2m2.rt.event.AlarmLevels in project ma-core-public by infiniteautomation.

the class PublisherVO method jsonWrite.

@Override
public void jsonWrite(ObjectWriter writer) throws IOException, JsonException {
    super.jsonWrite(writer);
    writer.writeEntry("type", definition.getPublisherTypeName());
    writer.writeEntry("snapshotSendPeriodType", Common.TIME_PERIOD_CODES.getCode(snapshotSendPeriodType));
    writer.writeEntry("publishType", PUBLISH_TYPE_CODES.getCode(publishType));
    ExportCodes eventCodes = getEventCodes();
    if (eventCodes != null && eventCodes.size() > 0) {
        Map<String, String> alarmCodeLevels = new HashMap<>();
        for (int i = 0; i < eventCodes.size(); i++) {
            int eventId = eventCodes.getId(i);
            AlarmLevels level = getAlarmLevel(eventId, AlarmLevels.URGENT);
            alarmCodeLevels.put(eventCodes.getCode(eventId), level.name());
        }
        writer.writeEntry("alarmLevels", alarmCodeLevels);
    }
}
Also used : ExportCodes(com.serotonin.m2m2.util.ExportCodes) HashMap(java.util.HashMap) AlarmLevels(com.serotonin.m2m2.rt.event.AlarmLevels)

Example 25 with AlarmLevels

use of com.serotonin.m2m2.rt.event.AlarmLevels in project ma-core-public by infiniteautomation.

the class PublisherVO method setAlarmLevel.

/**
 * Set an alarm level based on the sub-type of the publisher event type
 * which MUST (and already is) one of the codes in getEventCodes()
 */
public void setAlarmLevel(String subType, AlarmLevels level) throws ValidationException {
    ExportCodes codes = getEventCodes();
    int eventId = codes.getId(subType);
    if (eventId == -1) {
        ProcessResult result = new ProcessResult();
        result.addContextualMessage("alarmLevel", "emport.error.eventCode", subType, codes.getCodeList());
        throw new ValidationException(result);
    }
    alarmLevels.put(eventId, level);
}
Also used : ExportCodes(com.serotonin.m2m2.util.ExportCodes) ValidationException(com.infiniteautomation.mango.util.exception.ValidationException) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult)

Aggregations

AlarmLevels (com.serotonin.m2m2.rt.event.AlarmLevels)19 ExportCodes (com.serotonin.m2m2.util.ExportCodes)14 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)11 ArrayList (java.util.ArrayList)11 EventInstance (com.serotonin.m2m2.rt.event.EventInstance)9 PermissionHolder (com.serotonin.m2m2.vo.permission.PermissionHolder)8 UserEventLevelSummary (com.serotonin.m2m2.rt.event.UserEventLevelSummary)7 HashMap (java.util.HashMap)7 EventTypeVO (com.serotonin.m2m2.vo.event.EventTypeVO)6 ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)5 TranslatableJsonException (com.serotonin.m2m2.i18n.TranslatableJsonException)5 User (com.serotonin.m2m2.vo.User)5 ValidationException (com.infiniteautomation.mango.util.exception.ValidationException)4 SystemEventType (com.serotonin.m2m2.rt.event.type.SystemEventType)4 EnumMap (java.util.EnumMap)4 Test (org.junit.Test)4 JsonObject (com.serotonin.json.type.JsonObject)3 UserEventListener (com.serotonin.m2m2.rt.event.UserEventListener)3 Collections (java.util.Collections)3 HashSet (java.util.HashSet)3