Ciao, not really sure where is your problem exactly, but as I use often similar use-case of yours, thought worthy to share what I usually find useful:1. check STREAM mode is activated2. check in the .drl is clearly defined what is a Fact, and what is an Event. In your case I would check TemperatureRead is declared as Event?3. activate Audit log / runtime logger.I find especially useful point #3 because you will see, as the session clock advances, what is still in working memory and when rule is activated you will see against which Event/Facts.Hope this is helpfulCiaoMMOn Fri, Dec 6, 2013 at 11:54 PM, martinzp <martinzp@gmail.com> wrote:
Hi, i am new in the forum, and a beginner user of Drools so forgive me if my
question isn't quite good.
I want to test the "over window:time" operand.
In order to do that i use the pseudo clock, but i have noticed that it
doesn't behave as i would expect.
The behaviour i think i observed, is that the rule is using the real clock
instead of the pseudo clock.
*Here is my drl file:*
rule "Fire Detected"
when
c : Number(intValue >= 3) from accumulate (
$tr : TemperatureRead(read > 40)
over window:time ( 1s )
from entry-point entryone ,
count ($tr)
)
then
System.out.println("Fire Detected!");
end
*and here is the portion of my main file that inserts the events:*
TemperatureRead temp1 = new TemperatureRead(33.2);
TemperatureRead temp2 = new TemperatureRead(38.7);
TemperatureRead temp3 = new TemperatureRead(39.5);
TemperatureRead temp4 = new TemperatureRead(42.5);
TemperatureRead temp5 = new TemperatureRead(43.1);
TemperatureRead temp6 = new TemperatureRead(47.8);
SessionPseudoClock clock = ksession.getSessionClock();
entryPoint1.insert(temp1);
clock.advanceTime((new Date()).getTime(), TimeUnit.MILLISECONDS);
fireRules();
entryPoint1.insert(temp2);
clock.advanceTime(1, TimeUnit.SECONDS);
fireRules();
entryPoint1.insert(temp3);
clock.advanceTime(1, TimeUnit.SECONDS);
fireRules();
entryPoint1.insert(temp4);
clock.advanceTime(1, TimeUnit.SECONDS);
fireRules();
entryPoint1.insert(temp5);
clock.advanceTime(1, TimeUnit.SECONDS);
fireRules();
entryPoint1.insert(temp6);
fireRules();
In my opinion, the rule shouldn't be fired, because as i am (supposedly)
using the pseudo clock, the events shouldn't fall into the same sliding
window (1 second.)
In general, the rule should fire when it detects 3 or more temperature reads
with a temperature over 40.
Any idea about what i might be doing wrong?
Thanks in advance!
--
View this message in context: http://drools.46999.n3.nabble.com/Problem-with-time-sliding-windows-and-pseudo-clock-in-Drools-Fusion-5-5-0-tp4027137.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