<div>Hi,</div>
<div> </div>
<div>First time posting in the mailing list, so I apologise if I make any silly mistakes.</div>
<div> </div>
<div>I have two classes MachineOnline and MachineOffline, which denote when a machine is online and offline respectively</div>
<div> </div>
<div>public class MachineOnline {</div>
<div> int machineId</div>
<div> </div>
<div>}</div>
<div> </div>
<div> </div>
<div>These are declared in the drl file as events, so Drools Fusion automatically generates the timestamp for me (I am running in STREAM mode, so i get real time updates on the machine status)</div>
<div> </div>
<div>declare MachineOnline</div>
<div> @role(event)</div>
<div>end</div>
<div> </div>
<div>I then have a rule to generate the duration when the machine is online, but I cannot seem to extract the timestamp that drools automatically inserts. A thread a few years ago suggested using .startTimestamp, but Drools does not seem to recognise it as a field. I believe that needs an EventFactHandle, but I'm not sure how to retrieve that inside the drl file. </div>
<div> </div>
<div>rule "Find duration machine is online"</div>
<div> when $message1 : MachineOnline()</div>
<div> $message2: MachineOffline(machineId == $message1.machineId && this after $message1) // + more rules to handle edge cases</div>
<div> then</div>
<div> //processing</div>
<div> duration = $message2.startTimestamp - $message1.startTimestamp ?</div>
<div>end</div>
<div> </div>
<div>The eventual aim is to allow for a query that allows me to find how long the machine is online for during a specified time interval, so if there is a way to do this without needing to retrieve the actual timestamp of each event, that will be great too. Or would it be better to manually define a timeStamp field for each event? I've been using the default one as that together with the pseudo allows for easy unit testing.</div>
<div> </div>
<div>Thanks a lot!</div>
<div> </div>
<div>Regards</div>
<div>Jing</div>
<div> </div>