Absence of facts (and events) is not a good foundation for rules, as you have discovered.<div><br></div><div>Consider that the arrival of an event with some specific itemName is another fact, and you want to monitor the aging of that secondary fact, or cancel it as soon as yet another one arrives.</div>
<div><br></div><div>rule "start monitoring"</div><div>when</div><div> $se: StateEvent( $in: itemName )</div><div>then</div><div> Monitor m = new Monitor( $se, $in );</div><div> insert( m );</div><div>end</div>
<div><br></div><div>rule "stop monitoring"</div><div>when</div><div> $se: StateEvent( $in: itemName )</div><div> $m: Monitor( stateEvent != $se, itemName == $in )</div><div>then</div><div> retract( $m );</div>
<div>end</div><div><br></div><div>rule "nothing for 1m"</div><div>timer( int: 1m )</div><div>when</div><div> $m: Monitor( $in: itemName )</div><div>then</div><div> System.out.println( "not working: " + $in );</div>
<div> retract( $m );</div><div>end</div><div><br></div><div>Untested!</div><div>-W</div><div><br><br><div class="gmail_quote">2012/2/7 Juanker Atina <span dir="ltr"><<a href="mailto:juankera@gmail.com">juankera@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi there,<br><br>I'm working on a rule that will alert me when there is no events from the sensors for a while.<br>
<br>So, first idea was to use time window and matches in condition side, to match all types of sensors, and then to print that something is wrong.<br>
<br>rule "Alert if there is no activity"<br>
when<br>
not StateEvent(itemName matches "door.*|presence.*|luminosity.*") over window:time( 1m ) from entry-point "EventStream"<br>
then<br>
System.out.println("Alert: one sensor is not working");<br>
end<br><br>First change was to add a timer, as truth maintenance will fire this rule the first time, but not forever. So i add a timer to fire the rule every 20 seconds, for example.<br><br>rule "Alert if there is no activity"<br>
timer (cron:0/20 * * * * ?)<br>
when<br>
not StateEvent(itemName matches "door.*|presence.*|luminosity.*") over window:time( 1m ) from entry-point "EventStream"<br>
then<br>
System.out.println("Alert: one sensor is not working");<br>
end<br><br>The second thing i want to achieve is to print what specific sensor is not working, but i understand that as there is no StateEvent, i can't declare a variable, for example.<br><br>rule "Alert if there is no activity"<br>
timer (cron:0/20 * * * * ?)<br>
when<br>
not $event: StateEvent(itemName matches "door.*|presence.*|luminosity.*") over window:time( 1m ) from entry-point "EventStream"<br>
then<br>
System.out.println("Alert: one sensor is not working: " + $event.getItemName());<br><br>So, do you know how can i know which sensor is not working? must i rewrite the rule to achieve this? is this possible?<br>
<br><br>Thanks for your help.<br>
end<br><br>
<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>
<br></blockquote></div><br></div>