[rules-users] sliding window question

Wolfgang Laun wolfgang.laun at gmail.com
Sat Mar 1 03:09:34 EST 2014


You can accumulate the minimum as well:

accumulate( Reading ( $r:reading) over windiw:time(30s) from entry-point
HeartrateStream;
                  $avg: average($r),
                  $min: min($r);
                  $min > 90 )

This tells you that all readings are over 90.
-W




On 28 February 2014 15:25, Lin Lin <lin.lin at comcast.net> wrote:

>
>
>
>
> On Feb 27, 2014, at 4:06 PM, "lin.lin [via Drools]" <
> ml-node+s46999n4028396h13 at n3.nabble.com> wrote:
>
> Hi
>
>    Thanks again for the pointers!!
>
>    I modified the code but the sliding window rule does not seem to be
> working as how I want it to be(copied shown in the following).  I injected
> 6 events, one event every 10 seconds, the first one is less than 90, the
> rest are more than 90.  I am expecting getting 3 alerts at 4th event, 5th
> event and 6 event. But instead I only get one alert.
>
>   when
>     not Reading( reading <= 90 ) over window:time( 30s ) from entry-point
> ReadingStream
>   then
>      System.out.print ("alert: Reading high for 30 seconds \n");
>
>
>   So I used the other way as you suggested. It works and gives me 3
> alerts. However if I added the accumulate pattern (copied below) , no alert
> is generated at all.  If I removed the first 3 patterns, just leave the
> last pattern, it does print the average of last 30 seconds event every time
> when a new event is injected. What else did I do wrong?
>
>       when
>           $r1: Reading( reading >90 ) from entry-point HeartrateStream
>           $r2: Reading( reading > 90, this after[30s,30s] $r1 ) from
> entry-point HeartrateStream
>           not (Reading( reading <= 90, this after $r1, this before $r2 )
> from entry-point HeartrateStream)
>          $averg: Number() from accumulate( Reading ( $r:reading) over
> windiw:time(30s) from entry-point HeartrateStream, average($r) )
>       then
>          System.out.print ("alert: Reading high for 30 seconds, average
> reading"+$averg+"\n");
>
>
> Thanks a lot!!!
> Lin
>
>
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://drools.46999.n3.nabble.com/sliding-window-question-tp4028367p4028396.html
>  To unsubscribe from sliding window question, click here<http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4028367&code=bGluLmxpbkBjb21jYXN0Lm5ldHw0MDI4MzY3fC0xODk3NDMyNjQ3>
> .
> NAML<http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20140301/217a43ac/attachment.html 


More information about the rules-users mailing list