It's getting closer now but still has one problem that it reports for a pattern match where there's an EventB with same index value in between. The Testing events feed pattern that I use can be described as below:
EventA:0 EventB:1 EventA:0 EventB:1 EventA:1 EventB:0 EventA:0 here it reports for a pattern match where it shouldn't EventB:1 Best Regards, Kevin Zhao 在 2010年10月26日 下午4:33,Wolfgang Laun <[email protected]>写道: > If there may be two EventA with the same timestamp, additional > constraints may be necessary, and > after may have to be used with a start time of 0ms: > > $a1: EventA( $index : index ) > $a2: EventA( this != $a1 && after[0ms] $a1, index == $index ) > $a3: EventA( this != $a1 && != $a2 && after[0ms] $a2, index == $index ) > > -W > > > 2010/10/26 赵侃侃 <[email protected]>: > > Hello, > > Hello, > > I just tried this rule, but it doesn't seem to work as expected. > > What I have now is every time I have an EventA received then a pattern is > > reported matched no matter whether any of the other constrains is met. > > Any ideas? > > Best Regards, > > Kevin Zhao > > > > 2010/10/26 Michael Anstis <[email protected]> > >> > >> You could try this too; if you don't want lots of new attributes for > your > >> model:- > >> > >> rule "three A" > >> when > >> $a1: EventA( $index : index ) > >> $a2: EventA( index == $index ) > >> $a3: EventA( index == $index ) > >> not PatternConsumer( name == 'AAA', events contain $a1 || contais $a2 > || > >> contains $a3) > >> not EventB( this after[0ms] $a1 && before[0ms] $a3, index == $index ) > >> then > >> // ... match > >> PatternConsumer pc = new PatternConsumer("AAA", $a1, $a2, $a3 ); > >> insert(pc); > >> end > >> > >> > >> 2010/10/25 Wolfgang Laun <[email protected]> > >>> > >>> Giving those other rules a higher salience is one way, but I think > >>> it is better to add a boolean field "usedForAAA" to class EventA. > >>> > >>> rule "three A" > >>> when > >>> $a1: EventA( $index : index, usedForAAA == false ) > >>> $a2: EventA( index == $index, usedForAAA == false ) > >>> $a3: EventA( index == $index, usedForAAA == false ) > >>> not EventB( this after[0ms] $a1 && before[0ms] $a3, index == $index ) > >>> then > >>> // ... match > >>> modify( $a1 ){ setUsedForAAA( true ) } > >>> modify( $a2 ){ setUsedForAAA( true ) } > >>> modify( $a3 ){ setUsedForAAA( true ) } > >>> end > >>> > >>> -W > >>> > >>> > >>> 2010/10/25 赵侃侃 <[email protected]> > >>>> > >>>> Thanks Wolfgang, > >>>> It now starts to make sense to me. However, is it possible that I > don't > >>>> retract those matched eventA? All those events might be used to > evaluate > >>>> against other rules. > >>>> Thanks again, > >>>> Kevin Zhao > >>>> 2010/10/25 Wolfgang Laun <[email protected]> > >>>>> > >>>>> I assume you are using Fusion, using a session clock so that temporal > >>>>> operators are available. > >>>>> > >>>>> rule "three A" > >>>>> when > >>>>> $a1: EventA( $index : index ) > >>>>> $a2: EventA( index == $index ) > >>>>> $a3: EventA( index == $index ) > >>>>> not EventB( this after[0ms] $a1 && before[0ms] $a3, index == $index > ) > >>>>> then > >>>>> // ... match > >>>>> retract( $a1 ); > >>>>> retract( $a2 ); > >>>>> retract( $a3 ); > >>>>> end > >>>>> > >>>>> -W > >>>>> > >>>>> 2010/10/25 赵侃侃 <[email protected]> > >>>>>> > >>>>>> Hello, > >>>>>> I'm still quite new to the drools stuffs just getting the examples > >>>>>> running. I'm sorry if my question is too basic. > >>>>>> I have a system that will continuously to receive events sent from > >>>>>> some other system. Basically I have two types of events, eventA and > eventB. > >>>>>> Both eventA and eventB have two properties, index and timestamp. > >>>>>> What I want is to capture a pattern to meet the following conditions > >>>>>> 1. every 3 consecutive eventsA without any eventB in between having > a > >>>>>> same index value ordering by their timestamp. > >>>>>> 2. all events in a matched pattern will have the same value of > >>>>>> property index. > >>>>>> 3. if a pattern is matched, any of the events in this pattern should > >>>>>> not be used again for a new matching. > >>>>>> there are some examples below, the number after a colon stands for > the > >>>>>> value of its index number and assume those events are already > ordered by > >>>>>> their timestamp. > >>>>>> eventB:2 eventA:1 eventA:1 eventA:1 eventB:3 > >>>>>> --------- one successful match, we have three eventA with same > index value > >>>>>> 1 in a row > >>>>>> eventB:2 eventA:1 eventA:1 eventB:1 eventA:1 > >>>>>> --------- no match because there's an eventB in between > >>>>>> eventB:2 eventA:1 eventA:1 eventB:2 eventA:1 > >>>>>> --------- one successful match because the in-between eventB has a > >>>>>> different index value > >>>>>> eventA:1 eventA:1 eventA:1 eventA:1 eventA:1 > >>>>>> --------- only one match, because once matched, the events can not > be used > >>>>>> for a second match again. > >>>>>> > >>>>>> I just don't know how to write a rule like this. Is there anyone who > >>>>>> can shed some lights on? > >>>>>> Best Regards, > >>>>>> Kevin > >>>>>> > >>>>>> > >>>>>> _______________________________________________ > >>>>>> rules-users mailing list > >>>>>> [email protected] > >>>>>> https://lists.jboss.org/mailman/listinfo/rules-users > >>>>>> > >>>>> > >>>>> > >>>>> _______________________________________________ > >>>>> rules-users mailing list > >>>>> [email protected] > >>>>> https://lists.jboss.org/mailman/listinfo/rules-users > >>>>> > >>>> > >>>> > >>>> _______________________________________________ > >>>> rules-users mailing list > >>>> [email protected] > >>>> https://lists.jboss.org/mailman/listinfo/rules-users > >>>> > >>> > >>> > >>> _______________________________________________ > >>> rules-users mailing list > >>> [email protected] > >>> https://lists.jboss.org/mailman/listinfo/rules-users > >>> > >> > >> > >> _______________________________________________ > >> rules-users mailing list > >> [email protected] > >> https://lists.jboss.org/mailman/listinfo/rules-users > >> > > > > > > _______________________________________________ > > rules-users mailing list > > [email protected] > > https://lists.jboss.org/mailman/listinfo/rules-users > > > > > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users >
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
