I have a multiple uses with each a sensor that sends pedometer data. I have a rule file that based on the macAddress, fires the rule:
declare Steps
@role(event)
end
declare User
@role(fact)
end
rule "MAC"
when
User( $mac: macAddress ) from entry-point "entrySteps"
then end
rule "ACC STEPS RULE" extends "MAC"
when
accumulate( Steps( $s : steps , macAddress == $mac )
over window:time( 1h ) from entry-point "entrySteps";
$fst: min( $s ), $lst: max( $s );
$lst - $fst < 50 )
then
System.out.println($lst + " " + $fst);
Action.handleAction($mac,"STEPS RULE: get moving!");
end
My User has just a field macAddress
and Steps events have the following fields:
double steps;
Date timeStamp;
String macAddress;
Now when I insert an event then for each macAddress, the rule will fire if the number of steps of a user with that macAddress in the last hour is less then 50. So the rule will fire for every macAddress if this condition is fulfilled. But I want that the rule can only fire for the macAddress of the inserted Step event. How can I adjust my rule?