| Reference > Rule Languages > ILOG Rule Language > IRL Keywords > event (in rule conditions) |
event (in rule conditions) |
PREVIOUS NEXT |
A statement for declaring an event condition or an event object. This keyword is used in rule conditions.
[?var:] event className (test1;...;testn);
where a temporal test testi has the form:
{after|before|occursin} [interval]
On the left-hand side of a rule, an event condition can be bound to a variable. The event className is defined in the statement together with tests, where testi can be either nontemporal or temporal tests. In the case of a temporal test in an event condition, a temporal constraint is expressed with test operators: after, before, occursin. The temporal constraints between two events are expressed using the after and before operators. The interval, when provided, restricts the allowed delay between the events. A temporal constraint on a single event is expressed using the occursin operator. An occursin test is satisfied if the timestamp of the event is included in the interval.
The reference to variables bound to or in other event conditions is forbidden in the expression. The expression is evaluated once, when the events occurring as operands of the temporal constraint operator are inserted.
Non-temporal tests and temporal constraints can be combined in the following way:
?a: event Alarm(); ?b: event Alarm(sev >= HIGH || ?this after[1,5] ?a);
rule alarmManager {
when {
?mo: ManagedObject();
?operator: Operator() in ?mo.subscribers();
?alarm1: event Alarm(managedObject == ?mo);
?alarm2: event Alarm(managedObject == ?mo; ?this after[1, 5]
?alarm1);
}
then {
System.out.println("Seen two alarms on " + ?mo.name);
?operator.report(?alarm1, ?alarm2);
}
}
The alarmManager rule prints a message when two alarms occur on the same managed object with a time difference between 1 and 5 clock ticks.
The rule contains four conditions:
?mo is matched by a ManagedObject object.
Operator objects in the variable ?operator.
?alarm1 points to an event object named Alarm with a single constraint: the value of the field managedObject is equal to the variable ?mo.
?alarm2 points to an event object named Alarm with the following constraints: the value of the field managedObject is equal to the variable ?mo, and the difference between the first event object timestamp and the second event object timestamp is greater than or equal to 1 and less than or equal to 5 clock ticks.
There are two action statements:
?operator.report method using the event object variables ?alarm1 and ?alarm2.
Any alarm will be automatically retracted from the working memory 6 clock ticks after its insertion.
after, before, occursin, timeof
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |