Hello Wolfgang, I tried your rules but they don't seem to work correctly. Nothing comes back thus the consequences are not executed. I think we need to introduce a timer to trigger the rule once a while because if there nothing comes in (e.g. no one get killed) then nothing will get executed.
Best Regards, Kevin Zhao 在 2010年10月28日 下午4:57,赵侃侃 <kevin...@gmail.com>写道: > To be honest, I don't quite understand the rules you wrote. Let me explain > this a little bit with a real world scenario. > Assume this is an on-line game that EventB indicates a 'kill' event that a > player is losing its character who might be killed by some other player. > The property index points to the player who owns this character. What I'm > looking for here is to find out when a player's character survives in 2 > minutes. The number of players in a game is at least 2 but can be up to any > number. > > Best Regards, > Kevin Zhao > > 2010/10/28 Wolfgang Laun <wolfgang.l...@gmail.com> > >> >> >> 2010/10/28 赵侃侃 <kevin...@gmail.com> >> >>> Hello Wolfgang, >>> >>> Index is just like the index in an array. the value can be any from 0 to >>> the array length. >>> for the previous example, the length is 1 so index can be either 0 or 1. >>> but in the real case, the length can be an arbitrary number. >>> >>> another question, there are 2 rules here, do both of them have to be >>> applied? >>> >> >> One creates and inserts the PatternConsumer which blocks repeated usage of >> the pair of EventB facts that have been successfully paired. Otherwise a >> sequence EventB:0, EventB:1, EventB:2 would fire 2 times. >> >> If the positive condition is more complex, e.g., you need *all* index >> values 0,...,L-1 within 2m, then other conditions will be required (and >> that's what I meant with "more precisesly"). If any pair a,b from [0..L-1] >> will do, then the modified version (!=) should be OK. >> >> -W >> >> >> >>> >>> Best Regards, >>> Kevin Zhao >>> >>> 2010/10/28 Wolfgang Laun <wolfgang.l...@gmail.com> >>> >>> Kindly state your requirements precisely. >>>> >>>> Perhaps >>>> not ( EventB ( index != $index,... ) >>>> is what you need. >>>> -W >>>> >>>> 2010/10/28 赵侃侃 <kevin...@gmail.com> >>>> >>>> I haven't tested this rule, but what about the case that property index >>>>> would have arbitrary number of possible values? >>>>> >>>>> 2010/10/27 Wolfgang Laun <wolfgang.l...@gmail.com> >>>>> >>>>>> Omitting the Entry Points: >>>>>> >>>>>> rule "B-0-1-not OK" >>>>>> when >>>>>> $b : EventB( $index: index ) >>>>>> not ( PatternConsumer( id == "B01", events contains $b ) ) >>>>>> not ( EventB( index == (1 - $index), this after[0s,2m] $b ) ) >>>>>> then >>>>>> System.out.println( "B:" + $index + ", but no B:" + (1-$index) ); >>>>>> end >>>>>> >>>>>> rule "B-0-1" >>>>>> when >>>>>> $b1 : EventB( $index: index ) >>>>>> $b2 : EventB( index == (1 - $index), this after[0s,2m] $b1 ) >>>>>> then >>>>>> insert( new PatternConsumer( "B01", $b1, $b2 ) ); >>>>>> System.out.println( "B:" + $index + "+B:" + (1-$index) ); >>>>>> end >>>>>> >>>>>> -W >>>>>> >>>>>> 2010/10/27 赵侃侃 <kevin...@gmail.com>: >>>>>> > Hello, >>>>>> > With the help from the community I managed to get my first rule >>>>>> working, and >>>>>> > I'm trying to write my second rule on my own but it just doesn't >>>>>> seem to >>>>>> > work correctly. >>>>>> > Here is the scenario, what I want is to identify a pattern that >>>>>> there's no >>>>>> > EventB coming in within 2 minutes with a particular index value. >>>>>> > For example, EventB would have a property named index and assume the >>>>>> value >>>>>> > of index would be either 0 or 1. >>>>>> > Before firing the rules, I would manually insert facts of >>>>>> possibleIndex with >>>>>> > value 0 and 1 into the workingMemory. >>>>>> > Within 2 minutes, if there only comes one EventB with index valued 0 >>>>>> then >>>>>> > the system should report no EventB coming in with index value 1 in >>>>>> last 2 >>>>>> > minutes. >>>>>> > Vice versa, in the case of only coming one EventB with index valued >>>>>> 1 then >>>>>> > the system should report no EventB coming in with index value 0 in >>>>>> last 2 >>>>>> > minutes. >>>>>> > If within 2 minutes, there comes 2 EventB with both value 0 and 1 >>>>>> then >>>>>> > nothing should report. >>>>>> > Here is what I wrote, but it doesn't seem to work correctly. >>>>>> > I used a timer to fire this rule every 10 seconds because I don't >>>>>> think the >>>>>> > rule would run automatically if I don't add that. (not too sure >>>>>> though) >>>>>> > rule "no B in 2 minutes" >>>>>> > timer (0 10s) >>>>>> > when >>>>>> > possibleIndex( $index : index ) from entry-point "Event stream" >>>>>> > $p : PatternConsumer ( name == 'no B' && index == $index ) >>>>>> > not ( EventB( index == $index && this after[0ms,2m] $p) over >>>>>> window:time(2m) >>>>>> > from entry-point "Event stream" ) >>>>>> > then >>>>>> > PatternConsumer pc = new PatternConsumer( "no B", $index ); >>>>>> > insert(pc); >>>>>> > System.out.println("no B in 2 minutes " + $index); >>>>>> > end >>>>>> > Best Regards, >>>>>> > Kevin Zhao >>>>>> > _______________________________________________ >>>>>> > rules-users mailing list >>>>>> > rules-users@lists.jboss.org >>>>>> > https://lists.jboss.org/mailman/listinfo/rules-users >>>>>> > >>>>>> > >>>>>> >>>>>> _______________________________________________ >>>>>> rules-users mailing list >>>>>> rules-users@lists.jboss.org >>>>>> https://lists.jboss.org/mailman/listinfo/rules-users >>>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> rules-users mailing list >>>>> rules-users@lists.jboss.org >>>>> https://lists.jboss.org/mailman/listinfo/rules-users >>>>> >>>>> >>>> >>>> _______________________________________________ >>>> rules-users mailing list >>>> rules-users@lists.jboss.org >>>> https://lists.jboss.org/mailman/listinfo/rules-users >>>> >>>> >>> >>> _______________________________________________ >>> rules-users mailing list >>> rules-users@lists.jboss.org >>> https://lists.jboss.org/mailman/listinfo/rules-users >>> >>> >> >> _______________________________________________ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> >> >
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users