Reference > Rule Languages > ILOG Rule Language > IRL Keywords > event (in rule conditions)

Summary

A statement for declaring an event condition or an event object. This keyword is used in rule conditions.

Syntax

[?var:] event className (test1;...;testn);
where a temporal test testi has the form: 
{after|before|occursin} [interval]

Description

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);

Example

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:

There are two action statements:

Any alarm will be automatically retracted from the working memory 6 clock ticks after its insertion.

See Also

after, before, occursin, timeof