Tidied alarm reminder behavior

This commit is contained in:
Richard Frith-Macdonald 2020-10-15 12:03:24 +01:00
parent dcb5368a23
commit 917e7f8bb5
2 changed files with 28 additions and 33 deletions

View file

@ -68,7 +68,7 @@
* <desc>The type of message ... <em>Error</em>, <em>Alert</em>, * <desc>The type of message ... <em>Error</em>, <em>Alert</em>,
* <em>Alarm</em>, <em>Raise</em> or <em>Clear</em>.<br /> * <em>Alarm</em>, <em>Raise</em> or <em>Clear</em>.<br />
* If this is not specified, messages of any type may match.<br /> * If this is not specified, messages of any type may match.<br />
* NB. Alarm reminders have one of three types. The type <em>Raise</em> * NB. Alarm alerts have one of three types. The type <em>Raise</em>
* matches only the initial raising of an alarm while <em>Clear</em> * matches only the initial raising of an alarm while <em>Clear</em>
* matches only the final clearing of the alarm. The type <em>Alarm</em> * matches only the final clearing of the alarm. The type <em>Alarm</em>
* will match raising, clearing, and also (if ReminderInterval is set) * will match raising, clearing, and also (if ReminderInterval is set)

View file

@ -865,6 +865,7 @@ replaceFields(NSDictionary *fields, NSString *template)
EcAlertRegex *e; EcAlertRegex *e;
NSString *s; NSString *s;
id o; id o;
int ri;
BOOL isReminder; BOOL isReminder;
RELEASE(pool); RELEASE(pool);
@ -963,30 +964,13 @@ replaceFields(NSDictionary *fields, NSString *template)
} }
} }
/* The next set are matches only for alarms.
*/
ri = [[d objectForKey: @"ReminderInterval"] intValue];
if (event->isAlarm && event->reminder > 0 && NO == event->isClear) if (event->isAlarm && event->reminder > 0 && NO == event->isClear)
{ {
isReminder = YES; isReminder = YES;
}
else
{
isReminder = NO;
}
/* The next set are matches only for alarms.
*/
if (nil != (s = [d objectForKey: @"Component"]))
{
if (NO == [s isEqual: event->component])
{
continue;
}
}
if (nil != (s = [d objectForKey: @"ReminderInterval"]))
{
if (isReminder)
{
int v = [s intValue];
/* This is an alarm reminder (neither the initial alarm /* This is an alarm reminder (neither the initial alarm
* nor the clear), so we check the ReminderInterval. * nor the clear), so we check the ReminderInterval.
* In order for a match to occur, the ReminderInterval * In order for a match to occur, the ReminderInterval
@ -995,14 +979,17 @@ replaceFields(NSDictionary *fields, NSString *template)
* NB, unlike other patterns, the absence of this one * NB, unlike other patterns, the absence of this one
* implies a match failure! * implies a match failure!
*/ */
if (v < 1 || (event->reminder % v) != 0) if (ri < 1 || (event->reminder % ri) != 0)
{ {
continue; // Not a match. continue; // Not a match.
} }
} }
else else
{ {
continue; // Not a reminder isReminder = NO;
if (ri > 0)
{
continue; // Rule matches only reminders
} }
} }
@ -1030,6 +1017,14 @@ replaceFields(NSDictionary *fields, NSString *template)
continue; // Not a match. continue; // Not a match.
} }
if (nil != (s = [d objectForKey: @"Component"]))
{
if (NO == [s isEqual: event->component])
{
continue;
}
}
if (nil != (e = [d objectForKey: @"SeverityTextRegex"]) if (nil != (e = [d objectForKey: @"SeverityTextRegex"])
&& (NO == event->isAlarm || [e match: event->severityText] == nil)) && (NO == event->isAlarm || [e match: event->severityText] == nil))
{ {