endinsert( new LastReading( $r ) );thennot LastReading( this == $r )rule "first Reading"$r: Reading()
when
From: Wolfgang Laun <wolfgang.laun@gmail.com>
To: Rules Users List <rules-users@lists.jboss.org>
Sent: Tuesday, June 11, 2013 12:07 PM
Subject: Re: [rules-users] Monitoring sensor parameter change
then$new: Reading( $np: power > $pp + 2 )endinsert( new LastReading( $r ) );thennot LastReading()$r: Reading()Basically a good approach.declare LastReadinglast : Reading
end// fire once, to set up LastReading with the very first Readingrule "first Reading"
when// based on the existence of a previous reading...rule "next Reading"
when
$lr: LastReading( $last: last )
Reading( this == $last, $pp: power )then
end// ...detect and handle an increment beyond the thresholdrule "next Reading, big increment"
extends "next Reading"
whenupdate( $lr ){ setLast( $new ) }... code for big incrementend// ...detect and handle an increment below the thresholdrule "next Reading, small increment"
extends "next Reading"
when
$new: Reading( this != $last, $np: power <= $pp + 2 )
then
update( $lr ){ setLast( $new ) }end
All of this is untested and may contain syntax errors. - The additional constraint (this != $last) in the last rule avoids looping.-WOn 11 June 2013 14:46, rjr201 <rich.j.riley@gmail.com> wrote:
If I understand your question right, you could create a class called
LastReading( SensorRead() ) and then your rules would look something like:
rule 1 //check to see if the increase is > 2
when
$last : LastReading( SensorRead($lastPower : power) )
SensorRead( $lastPower - power > 2)
then
System.out.println("Power increased more than 2")
end
rule2 //update which sensor read is the lastest reading
salience 100
when
$last : LastReading( )
$new : SensorRead()
then
retract($last)
insert(new LastReading($new))
end
--
View this message in context: http://drools.46999.n3.nabble.com/rules-users-Monitoring-sensor-parameter-change-tp4024242p4024243.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users