diff --git a/ChangeLog b/ChangeLog index bd536c3..b1494e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2018-02-20 Richard Frith-Macdonald + + EcAlerter.h: + EcAlerter.m: + New type 'Raise' to match only an alarm being raised. Behavior of + 'Alarm' changed to match both 'Raise' and 'Clear' (and reminders as + long as ReminderInterval matches). + 2018-01-05 Richard Frith-Macdonald EcProcess.h: diff --git a/EcAlerter.h b/EcAlerter.h index 6b7119a..6fc54f4 100644 --- a/EcAlerter.h +++ b/EcAlerter.h @@ -66,10 +66,13 @@ * * Type * The type of message ... Error, Alert, - * Alarm or Clear.
+ * Alarm, Raise or Clear.
* If this is not specified, messages of any type may match.
- * NB. Alarm reminders have a type of Alarm while alarm - * clears have a type of Clear. + * NB. Alarm reminders have one of three types. The type Raise + * matches only the initial raising of an alarm while Clear + * matches only the final clearing of the alarm. The type Alarm + * will match raising, clearing, and also (if ReminderInterval is set) + * reminders about the alarm. *
* DurationAbove * For [EcAlarm] messages, this may be used to match any message diff --git a/EcAlerter.m b/EcAlerter.m index e5e7f75..885d0d5 100644 --- a/EcAlerter.m +++ b/EcAlerter.m @@ -783,13 +783,19 @@ replaceFields(NSDictionary *fields, NSString *template) s = [d objectForKey: @"Type"]; if (s != nil && [s isEqualToString: event->type] == NO) { - continue; // Not a match. + /* For alarms only, the type 'Alarm' matches all three types + * of alarm event (raise, reminder, and clear). + */ + if (NO == event->isAlarm || [s isEqualToString: @"Alarm"] == NO) + { + continue; // Not a match. + } } /* The next set are performed only for alarms, * since a non-alarm can never match them. */ - if (event->reminder >= 0) + if (YES == event->isAlarm) { if (event->reminder > 0 && NO == event->isClear) { @@ -1186,6 +1192,7 @@ replaceFields(NSDictionary *fields, NSString *template) event->severityText = @""; event->isAlarm = NO; event->isClear = NO; + event->reminder = -1; if (nil != identifier) { event->type = @"Alert"; @@ -1201,6 +1208,7 @@ replaceFields(NSDictionary *fields, NSString *template) ASSIGN(event->severityText, [EcAlarm stringFromSeverity: event->severity]); event->isAlarm = YES; + event->reminder = reminder; if ([@"Clear" isEqual: [alarm extra]]) { event->isClear = YES; @@ -1209,10 +1217,16 @@ replaceFields(NSDictionary *fields, NSString *template) else { event->isClear = NO; - event->type = @"Alarm"; + if (0 == event->reminder) + { + event->type = @"Raise"; + } + else + { + event->type = @"Alarm"; + } } } - event->reminder = reminder; event->duration = (0.0 - [timestamp timeIntervalSinceNow]) / 60.0; m = event->m = [[NSMutableDictionary alloc] initWithCapacity: 20];