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