mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-21 02:41:11 +00:00
Make alarm handling easier
This commit is contained in:
parent
a732e99ee4
commit
b2c31b8261
3 changed files with 32 additions and 7 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2018-02-20 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
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 <rfm@gnu.org>
|
2018-01-05 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
EcProcess.h:
|
EcProcess.h:
|
||||||
|
|
|
@ -66,10 +66,13 @@
|
||||||
* </desc>
|
* </desc>
|
||||||
* <term>Type</term>
|
* <term>Type</term>
|
||||||
* <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> 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 a type of <em>Alarm</em> while alarm
|
* NB. Alarm reminders have one of three types. The type <em>Raise</em>
|
||||||
* clears have a type of <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>
|
||||||
|
* will match raising, clearing, and also (if ReminderInterval is set)
|
||||||
|
* reminders about the alarm.
|
||||||
* </desc>
|
* </desc>
|
||||||
* <term>DurationAbove</term>
|
* <term>DurationAbove</term>
|
||||||
* <desc>For [EcAlarm] messages, this may be used to match any message
|
* <desc>For [EcAlarm] messages, this may be used to match any message
|
||||||
|
|
18
EcAlerter.m
18
EcAlerter.m
|
@ -782,14 +782,20 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
|
|
||||||
s = [d objectForKey: @"Type"];
|
s = [d objectForKey: @"Type"];
|
||||||
if (s != nil && [s isEqualToString: event->type] == NO)
|
if (s != nil && [s isEqualToString: event->type] == NO)
|
||||||
|
{
|
||||||
|
/* 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.
|
continue; // Not a match.
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* The next set are performed only for alarms,
|
/* The next set are performed only for alarms,
|
||||||
* since a non-alarm can never match them.
|
* since a non-alarm can never match them.
|
||||||
*/
|
*/
|
||||||
if (event->reminder >= 0)
|
if (YES == event->isAlarm)
|
||||||
{
|
{
|
||||||
if (event->reminder > 0 && NO == event->isClear)
|
if (event->reminder > 0 && NO == event->isClear)
|
||||||
{
|
{
|
||||||
|
@ -1186,6 +1192,7 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
event->severityText = @"";
|
event->severityText = @"";
|
||||||
event->isAlarm = NO;
|
event->isAlarm = NO;
|
||||||
event->isClear = NO;
|
event->isClear = NO;
|
||||||
|
event->reminder = -1;
|
||||||
if (nil != identifier)
|
if (nil != identifier)
|
||||||
{
|
{
|
||||||
event->type = @"Alert";
|
event->type = @"Alert";
|
||||||
|
@ -1201,6 +1208,7 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
ASSIGN(event->severityText,
|
ASSIGN(event->severityText,
|
||||||
[EcAlarm stringFromSeverity: event->severity]);
|
[EcAlarm stringFromSeverity: event->severity]);
|
||||||
event->isAlarm = YES;
|
event->isAlarm = YES;
|
||||||
|
event->reminder = reminder;
|
||||||
if ([@"Clear" isEqual: [alarm extra]])
|
if ([@"Clear" isEqual: [alarm extra]])
|
||||||
{
|
{
|
||||||
event->isClear = YES;
|
event->isClear = YES;
|
||||||
|
@ -1209,10 +1217,16 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
event->isClear = NO;
|
event->isClear = NO;
|
||||||
|
if (0 == event->reminder)
|
||||||
|
{
|
||||||
|
event->type = @"Raise";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
event->type = @"Alarm";
|
event->type = @"Alarm";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event->reminder = reminder;
|
}
|
||||||
event->duration = (0.0 - [timestamp timeIntervalSinceNow]) / 60.0;
|
event->duration = (0.0 - [timestamp timeIntervalSinceNow]) / 60.0;
|
||||||
|
|
||||||
m = event->m = [[NSMutableDictionary alloc] initWithCapacity: 20];
|
m = event->m = [[NSMutableDictionary alloc] initWithCapacity: 20];
|
||||||
|
|
Loading…
Reference in a new issue