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