I suspect that you do not insert the Signal object as facts in<br>addition to the Device facts, and so they cannot be used as<br>events, wich need to be facts in the first place.<br><br>But you can use the temporal operators on Date values as well.<br>
Forget the declare Signal and use<br>  $e : Signal( status == &quot;red&quot;, time before[24h,0s] $p.jobTime) from $p.getSignalBuffer()<br><br>-W<br><br><div class="gmail_quote">On 14 December 2010 10:32, Harris <span dir="ltr">&lt;<a href="mailto:harrisx@gmx.de">harrisx@gmx.de</a>&gt;</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;"><br>
Hi,<br>
<br>
I&#39;m trying to get the following rule running:<br>
<br>
import foo.bar.Device;<br>
import foo.bar.Signal;<br>
<br>
declare Signal<br>
    @role( event )<br>
    @timestamp( time )<br>
end<br>
<br>
rule &quot;No red signal within the last 3 days before job start for type=4<br>
devices ..&quot;<br>
    salience 1000<br>
    when<br>
        $p : Device( type == &quot;4&quot; )<br>
        $e : Signal( status == &quot;red&quot;, this before[24h,0s] $p.jobTime) from<br>
$p.getSignalBuffer()<br>
    then<br>
        // do something ...<br>
end<br>
<br>
For a special kind of device it should be checked whether there have been<br>
alarms raised within a certain time interval.<br>
A couple of &quot;devices&quot; are inserted as facts. Each device has a buffer with<br>
its n past &quot;signals&quot;.<br>
<br>
<br>
public class Device {<br>
        String type;<br>
        List&lt;Signal&gt; signalBuffer = new ArrayList&lt;Signal&gt;();<br>
        Date jobTime = new Date();<br>
        // Getters and Setters<br>
}<br>
<br>
public class Signal {<br>
        Date time;<br>
        String status;<br>
        // Getters and Setters<br>
}<br>
<br>
These classes are generate by JAXB/xjc according to a given XML Schema.<br>
<br>
Although the rule looks OK to me, I&#39;m getting the exception:<br>
<br>
java.lang.ClassCastException: org.drools.common.DefaultFactHandle cannot be<br>
cast to org.drools.common.EventFactHandle<br>
<br>
I assume that &quot;From&quot; doesn&#39;t really work with the temporal operator and<br>
events.<br>
Is there a way to get this working?<br>
<br>
Kind regards<br>
Harris<br>
<font color="#888888">--<br>
View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Problem-with-FROM-and-temporal-operators-tp2084522p2084522.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Problem-with-FROM-and-temporal-operators-tp2084522p2084522.html</a><br>

Sent from the Drools - User 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>