[rules-users] latest event within a timeframe

Alexander Wolf mail at alexander-wolf.net
Wed Sep 18 06:06:52 EDT 2013


[Drools Version 5.5.0 Final]

Hey - 

I got an event E1 that is only valid, if the latest event E2 following E1 within 2 minutes has the value 1
--> I want have the rule fire 2 minutes after E1 but only if E1 is valid

This is my rule:

rule "inform about E1"
when
	//event (T1) is the initial trigger
	$event1 : Event(type == EventType.T1)
	//there is an event (T2) with value 0 between 0,2m after doorClosed
	$event2: Event(type == EventType.T2, value == 1, this after [0, 2m] $event1, $timestamp : timestamp)
	//there is no newer event (T2) within the timeframe
	not Measurement(type == EventType.T2, this after [0, 2m] $event1, timestamp > $timestamp) 
then
	//print info
	log(drools, "E1 valid");
end

An example of Events:

12:00:00  - E1
12:01:00  - E2 ( value = 0 ) 
12:01:10  - E2 ( value = 0 ) 
12:01:40  - E2 ( value = 0 ) 
12:01:50  - E2 ( value = 1 ) 
12:02:10  - E2 ( value = 0 )

I would expect the output:   [log() does log the clock-time when my rule fires)

12:02:00 E1 valid

But what I get is:

12:03:50 E1 valid


So I see that the late coming E2 (@12:02:10) is correctly ignored, the rule result is basically correct, but the rule is fired much to late.  (actually 2 minutes after $event2 and not as expected 2 minutes after $event1).

Could someone give me a hint what I did wrong?

Regards, 
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130918/1efddb2e/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20130918/1efddb2e/attachment.bin 


More information about the rules-users mailing list