0

How to check time difference between two events. can someone suggest me the approach to do this?

I have different events coming from a device. initially it will be sending "started" event and after sometime it will send "completed" event. I need to calculate the difference in the start and completed event. How can I do this?

Joby
  • 21
  • 3

1 Answers1

1

In CEP events the time variable is of java type Date so you can use something like:

d1.getTime() - d2.getTime()

and you have the difference in milliseconds

TyrManuZ
  • 2,039
  • 1
  • 14
  • 23
  • @TyrManz can you provide a sample query. I am also facing with similar scenario. I am new to cumulocity and cep. I also need to identify if the starting and ending events is from same device. – rajmohan Apr 12 '18 at 14:39
  • @rajmohan You can find quite some Cumulocity examples here: http://cumulocity.com/guides/event-language/advanced/. Take a look at contexts for how to process depending on the device. I can also recommend the following page from esper: http://www.espertech.com/esper/solution-patterns/. It has a lot of examples how to solve certain tasks with esper in general – TyrManuZ Apr 12 '18 at 14:44