I'm a newbie to Drools (version 6.3) and I have some trouble coming up with a specific rule. I have a class called Steps with just a simple field double steps;
. Each step event represent the steps taken since the previous event and
I have a working rule that says that you need to get moving when you do not do
50 steps in the last hour:
declare Steps
@role(event)
end
rule "STEPS RULE"
when
$totalSteps : Number( doubleValue < 50 ) from accumulate(
Steps( stepsCount : steps ) over window:time( 1h ) from entry-point
"entrySteps", sum( stepsCount ) )
then
System.out.println("STEPS RULE: get moving!");
end
Now instead that each event is the steps taken since previous event, I want that they represent the cumulative steps. So if an event has 50 steps and you take 20 steps, then I want that the next event has 70 steps. The question is how can I change my rule so it would still work?
Steps
is an incoming event, its data is fixed - so if it contains 50 steps, then that's it. You can derive something from two events in a sequence, so that one Steps with 50 and the next one with 20 produces a sum of 70, but that doesn't appear to be your problem. – laune