Skip to content

Commit

Permalink
provide more information in the exception when events are not properl…
Browse files Browse the repository at this point in the history
…y ordered
  • Loading branch information
mrieser committed Jan 18, 2024
1 parent 0a402d9 commit 2245f48
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ public void run() {
if (event.getTime() < this.lastEventTime) {
throw new RuntimeException("Events in the queue are not ordered chronologically. " +
"This should never happen. Is the SimTimeStepParallelEventsManager registered " +
"as a MobsimAfterSimStepListener?");
"as a MobsimAfterSimStepListener? LastEventTime = " + this.lastEventTime +
" currentEvent.time = " + event.getTime() + " currentEvent.type = " + event.getEventType() +
" full event: " + event.toString());
} else {
this.lastEventTime = event.getTime();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,21 @@ public void reset(int iteration) {}
new PersonStuckEvent(1.0, Id.createPersonId(0), Id.createLinkId(0), "car"));
}

@Test
void testEventsAreChronologicallyOrdered() {
SimStepParallelEventsManagerImpl events = new SimStepParallelEventsManagerImpl(2);
EventsCollector collector = new EventsCollector();
events.addHandler(collector);
try {
events.initProcessing();
events.processEvent(new LinkEnterEvent(10.0, Id.createVehicleId(0), Id.createLinkId(0)));
events.processEvent(new LinkLeaveEvent(50.0, Id.createVehicleId(0), Id.createLinkId(0)));
events.processEvent(new LinkEnterEvent(49.0, Id.createVehicleId(0), Id.createLinkId(0)));
events.processEvent(new LinkLeaveEvent(69.0, Id.createVehicleId(0), Id.createLinkId(0)));
events.finishProcessing();
Assertions.fail("Expected exception about order of events");
} catch (Exception expected) {
}
}

}

0 comments on commit 2245f48

Please sign in to comment.