[rules-users] sliding window question
Wolfgang Laun
wolfgang.laun at gmail.com
Thu Feb 27 02:01:38 EST 2014
The correct way to ascertain that something hasn't happened for
a certain interval must be based on "staking out" this interval. One
way is by means of two distinct events:
when
$r1: Reading( reading >90 )
$r2: Reading( reading > 90, this after[30s] $r1 )
not Reading( reading <= 90, this after $r1 && before $r2 )
then
Clearly, this will only work if Readings arrive regularly, and you may have a
certain amount of delay at the end.
Another way would be to use a sliding window over time:
when
not Reading( reading <= 90 ) over window:time( 30s )
then
Here's a snag, too: If there are no readings at all, you'll also get an alert.
And then you'll have to think about the seconds following the 30th
second: should another alert be emitted repeatedly...
Most of the time, it's not an issue in CEP ;-)
-W
On 27/02/2014, lin.lin <lin.lin at comcast.net> wrote:
> Hi,
>
> I tried to create a rule that gives an alert when a machine reading is high
> for 30 seconds. I modeled the machine reading input as events. The
> following is the rule:
>
> rule "rule1"
> dialect "mvel"
> when
> $rd1 : mReading( reading >90 ) from entry-point ReadingStream
> not ($rd2 : mReading (reading<=90 , this before [0s, 30s] $rd1 )
> from entry-point ReadingStream )
> then
> System.out.print ("alert: Reading high for 30 seconds \n");
> end
>
> This does not detect detect the bad reading. However, If I changed the
> rule
> to be following (change second condition from "not" to "exists"), it
> detects
> all readings that are good.
>
> rule "rule1"
> dialect "mvel"
> when
> $rd1 : mReading( reading >90 ) from entry-point ReadingStream
> exists ($rd2 : mReading (reading<=90 , this before [0s, 30s] $rd1 )
> from entry-point ReadingStream )
> then
> System.out.print ("alert: Reading high for 30 seconds \n");
> End
>
>
> Is this an issue in CEP or did I do something wrong?
>
> Thanks a lot!
> Lily
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/sliding-window-question-tp4028367.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
More information about the rules-users
mailing list