[rules-users] Accumulate + Temporal Operators
Greg Barton
greg_barton at yahoo.com
Mon Jan 18 01:24:01 EST 2010
Yeah, you'll have to reinsert events into the stream, or another stream. Probably the latter would be better.
rule "DetectedFooAverageOver1"
when
$f : Double(doubleValue > 1.0) from accumulate( Event($v : value, name == "Foo") over window:time ( 10s ) from entry-point EntryPoint, average($v))
then
entryPoints["DetectedStuff"].insert(new ComplexEvent("FooAvg", $f));
end
Then a similar rule for the Bar average, and a rule to test the coincidence of the complex events:
rule "ComplexAvgBarPrettySoonAfterComplexAvgFoo"
when
$foo : ComplexEvent(name == "FooAvg") from entry-point DetectedStuff
$bar : ComplexEvent(name == "BarAvg", this after[0s,1s] $foo) from entry-point DetectedStuff
then
System.out.println("Uf, dah!");
end
And more fun can be had with this event aggregation idea.
--- On Sun, 1/17/10, Paul R. <reverselogic at gmail.com> wrote:
> From: Paul R. <reverselogic at gmail.com>
> Subject: Re: [rules-users] Accumulate + Temporal Operators
> To: "Rules Users List" <rules-users at lists.jboss.org>
> Date: Sunday, January 17, 2010, 12:29 PM
> I've declared an @expires of 30s for
> both events. However, my problem is that within a 30 second
> window it doesn't seem possible to ascertain whether
> both of the events occur simultaneously. I could change the
> @expires to 10 seconds for the above rule, which would make
> it work. However, I would like to be to perform more
> complicated matches, e.g. matching sequences of events which
> occur after another.
>
>
> $f : Double(doubleValue > 1.0) from
> accumulate( Event($v : value, name == "Foo") over
> window:time ( 10s )
>
> from entry-point EntryPoint,
> average($v))
>
> // following event must start immediately
> _after_ the above.
>
> $b : Double(doubleValue < 1.0) from
> accumulate( Event($v : value, name == "Bar") over
> window:time ( 20s )
>
> from entry-point EntryPoint,
> average($v))
>
> Any suggestions how I can achieve this kind of
> functionality?
>
> Many Thanks,
>
> Paul
>
>
> On Sun, Jan 17, 2010 at 4:19 AM,
> Greg Barton <greg_barton at yahoo.com>
> wrote:
>
> Do your Foo and Bar events declare
> an @expires value? If their expiration is less than 10
> seconds then the rule below won't work properly. (And by
> default an event's expiration is 0, which makes the rule
> below go wacky if @expires hasn't been declared...) If
> the @expires is 10s or greater for both events it should
> work.
>
>
>
>
> --- On Thu, 1/14/10, Paul R. <reverselogic at gmail.com>
> wrote:
>
>
>
> > From: Paul R. <reverselogic at gmail.com>
>
> > Subject: [rules-users] Accumulate + Temporal
> Operators
>
> > To: rules-users at lists.jboss.org
>
> > Date: Thursday, January 14, 2010, 1:56 PM
>
> > Hi,
>
> >
>
> > I'm using accumulate with sliding windows to
> verify
>
> > that certain event conditions are present for a
> specified
>
> > period of time, which works fine, however
>
> > I need to verify that both conditions are present at
> the
>
> > same time, i.e Foo.value > 1 for 10 seconds and
> Bar.value
>
> > < 1 for 10 seconds. There doesn't
>
> >
>
> > appear to be an obvious way to use the temporal
> operators
>
> > in this situation. Can anybody offer any suggestions?
>
> >
>
> > rule test no-loop true
>
> > when
>
> > $f : Double(doubleValue > 1.0) from
>
> > accumulate( Foo($v : value) over window:time ( 10s )
>
> >
>
> > from entry-point EntryPoint,
>
> > min($v))
>
> > $b : Double(doubleValue < 1.0) from
>
> > accumulate( Bar($v : value) over window:time ( 10s )
>
> > from entry-point EntryPoint,
>
> > max($v))
>
> > then
>
> >
>
> > // ...
>
> > end
>
> >
>
> > Any help greatly appreciated.
>
> >
>
> > Thanks,
>
> >
>
> > Paul
>
> >
>
> >
>
> > -----Inline Attachment Follows-----
>
> >
>
> > _______________________________________________
>
> > rules-users mailing list
>
> > rules-users at lists.jboss.org
>
> > https://lists.jboss.org/mailman/listinfo/rules-users
>
> >
>
>
>
>
>
>
>
>
>
> _______________________________________________
>
> rules-users mailing list
>
> rules-users at lists.jboss.org
>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> -----Inline Attachment Follows-----
>
> _______________________________________________
> 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