0

I would like to measure the time of cars with an unique Id with NEsper. My problem is, that there are several cars on a road. This road has predefined steps. I want to start to stop the time for every unique car that is in first step until this car receives the last step.

select ice.* from pattern[ice = IncomingCarEvent -> every timer:interval(1 sec) and not LastStepEvent]

The problem is, that I don't know how to separate the cars with a given Id. In this example, if one of the cars receives the last step the event does not fire anymore.

1 Answers1

0

I'm not very clear on why you measure until the last step and the pattern says "not lastestep". Partitioning can be done by correlating the events in the patterns such as "a=A => B(id=a.id)". You can also partition using a context declaration which is in this link: http://esper.codehaus.org/esper-5.1.0/doc/reference/en-US/html_single/index.html#context_def_keyed Or you may find the match-recognize to be easier to use as it has more of a step-wise approach to expressing a match much like regular expressions.

user650839
  • 2,594
  • 1
  • 13
  • 9
  • My idea was to fire an event until the car did not reached the last step. Thanks for mentioning contexts, I will try it. – HassanJackson Nov 26 '14 at 12:19
  • I did not found an example for that but it is maybe possible to measure the time until a specific car reaches the last step and then fire the event with the measured time. This would be also an option for me. – HassanJackson Nov 26 '14 at 13:58