[rules-users] CEP + prevent consequences from triggering multiple times?

reverselogic reverselogic at gmail.com
Thu Dec 3 13:41:41 EST 2009


Hi,

I'm trying to write a rule in drools, which triggers once some condition is
active for a specified time interval. For example, if a vehicle is over a
speed limit (100 mph) for 30 seconds, I want to trigger an action. However,
once this rule has fired, I don't want it to fire again until the vehicle
has dropped below the speed limit (and gone over the limit again). The only
way I've managed to model this is by defining two rules; one for determining
when the vehicle is speeding and one for determining when it is not speeding
and using a global object to track the state of the vehicle (see rules
below).

rule "OverSpeedLimit" no-loop true
when
	$minSpeed : Double() from accumulate(
		$speedingEvent : SpeedingEvent ($speed : speed)
			over window:time( 30s )
			from entry-point SpeedingStream,
		min($speed)
	);
	
	eval ($minSpeed > 100.0 && !state.speeding)
then
	state.speeding = true
end

rule "!OverSpeedLimit" no-loop true
when
	$speedingEvent : SpeedingEvent()
		from entry-point SpeedingStream
	eval ($speedingEvent.speed <= 100.0)
then
	state.speeding = false
end

My questions is: Is there a better way to model the above behaviour,
preferably as a single rule? The reason I ask is because I believe it would
be too complicated for my users to define rules like this. Ideally, I would
like to be able to create a DSL such as: "when Speed is above X for Y
seconds then ..."

Any help greatly appreciated.

Thanks,

Paul




-- 
View this message in context: http://n3.nabble.com/CEP-prevent-consequences-from-triggering-multiple-times-tp67424p67424.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list