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;
}
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());
}
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));
}
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);
}
}
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);
}
Aggregations