[rules-users] How can we make the ‘over window:time’ parameter being configurable?

moonbeam jplaberge at magenta.ca
Wed Jun 11 08:02:45 EDT 2014


By 'configurable', I mean 'user defined' instead of 'programmer defined'.  I
know, I can write (and it will work):

rule "Sound the alarm in case temperature rises above threshold" 
when 
   TemperatureThreshold( $max : max ) 
   Number( doubleValue > $max ) from accumulate( 
   SensorReading( $temp : temperature ) over window:time( 30s ), 
   average( $temp ) ) 
then 
   // sound the alarm 
End

In this manner, the threshold ($max) is ‘user defined’.  Just need to inject
a TemperatureThreshold fact with user’s preferred 'max' value.
But the 'window:time' is hardcoded forever.

I would prefer injecting TemperatureThreshold fact containing a second
parameter (windowTime) that could be decide at 'inject time'.  That gives a
rule similar to the one I had posted originally.
But, unfortunately this way, the rule does not compile at all. Passing a
variable (like $windowTime) to 'window:time' does not seems to be syntax
acceptable.




--
View this message in context: http://drools.46999.n3.nabble.com/How-can-we-make-the-over-window-time-parameter-being-configurable-tp4029932p4029982.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list