Try a rule with a timer:
rule AnoB
timer( int: 3m )
when
$a: A( status == "waiting for B" )
not B( this after $a )
then
modify( $a ){ setStatus( "no B within 3m after me" ) }
end
Untested.
-W
On 5 July 2011 13:00, wendy <w.mungovan(a)yahoo.com> wrote:
Hi,
I'm having trouble writing an absence pattern. What I'm trying to do is
detect when there is an A followed by no Bs for 3+minutes. I don't care if
there is more than one A. What I'm running into is that when I try to use
'over window:time' the time within drools is the end time of the window.
So
this means I need to write the no Bs for 3+ min first:
not( $b: B() over window:time(3m))
then try to find the A before it:
$now: Long() from RuleUtilityFunctions.getSessionClockTime()
$a: A( this before [3m] $now)
then I should have to check to make sure that I don't have any Bs between
$a's time and the start of the no B window:
not( B( time >= $a.time,
time <= $now))
This is not working. I think that it has something to do with my function
to get the session clock time (RuleUtilityFunctions.getSessionClockTime())
and how things get evaluated within the Rete engine. Because it does not
seem like $now is getting re-evaluated on future calls that pass the $b
condition. If I replace $now with the call to getSessionClockTime()
everything just seems to get weird.
I've tried to write the rule forward too. Look for A followed by no B but
that does not seem to work because A is matched at the current time and the
rule triggers because there is no B because the future B data has not be
inserted into working memory yet.
What is the right way to write this rule? Is there a way to get the start
and end time of the time window that met the over window:time() condition?
Thank you,
Wendy
--
View this message in context:
http://drools.46999.n3.nabble.com/Absence-Pattern-question-tp3140377p3140...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users