/** * Dispatch all setup events (the ones that define initial settings). For * example, a vehicle that is added during setup (at time < 0) will receive * its first tick at time 0. If the vehicle is added at the beginning of the * simulation (time 0) the first tick it will receive will be the second * (globally) tick. */ protected void dispatchSetupEvents() { TimedEvent e = null; while ((e = scenarioQueue.peek()) != null && e.getTime() < 0) { scenarioQueue.poll(); dispatch(e); } }
/** * Collects all event arrival times of the specified {@link Scenario}. * @param s The scenario. * @return {@link ImmutableList} containing event arrival times. */ public static ImmutableList<Long> getArrivalTimes(Scenario s) { final ImmutableList.Builder<Long> builder = ImmutableList.builder(); for (final TimedEvent te : s.getEvents()) { if (te instanceof AddParcelEvent) { builder.add(te.getTime()); } } return builder.build(); }
/** * Dispatch all setup events (the ones that define initial settings). For * example, a vehicle that is added during setup (at time < 0) will receive * its first tick at time 0. If the vehicle is added at the beginning of the * simulation (time 0) the first tick it will receive will be the second * (globally) tick. */ protected void dispatchSetupEvents() { TimedEvent e = null; while ((e = scenarioQueue.peek()) != null && e.getTime() < 0) { scenarioQueue.poll(); dispatch(e); } }
static boolean isOnline(Gendreau06Scenario scen) { for (final TimedEvent e : scen.getEvents()) { if (e instanceof AddParcelEvent && e.getTime() == -1) { return false; } } return true; }
private void dispatchEvents(TimeLapse timeLapse) { TimedEvent e = null; while ((e = scenarioQueue.peek()) != null && e.getTime() <= timeLapse.getTime()) { scenarioQueue.poll(); if (status == null) { LOGGER.info("scenario started at virtual time:" + timeLapse.getTime()); status = EventType.SCENARIO_STARTED; disp.dispatchEvent(new Event(status, this)); } dispatch(e); } if ((e = scenarioQueue.peek()) != null && e.getTime() <= timeLapse.getTime() + timeLapse.getTickLength() && clock instanceof RealtimeClockController) { LOGGER.trace("Found an event in next tick, switch to RT"); ((RealtimeClockController) clock).switchToRealTime(); } if (e == null && status != EventType.SCENARIO_FINISHED) { status = EventType.SCENARIO_FINISHED; disp.dispatchEvent(new Event(status, this)); } }
private void dispatchEvents(TimeLapse timeLapse) { TimedEvent e = null; while ((e = scenarioQueue.peek()) != null && e.getTime() <= timeLapse.getTime()) { scenarioQueue.poll(); if (status == null) { LOGGER.info("scenario started at virtual time:" + timeLapse.getTime()); status = EventType.SCENARIO_STARTED; disp.dispatchEvent(new Event(status, this)); } dispatch(e); } if ((e = scenarioQueue.peek()) != null && e.getTime() <= timeLapse.getTime() + timeLapse.getTickLength() && clock instanceof RealtimeClockController) { LOGGER.trace("Found an event in next tick, switch to RT"); ((RealtimeClockController) clock).switchToRealTime(); } if (e == null && status != EventType.SCENARIO_FINISHED) { status = EventType.SCENARIO_FINISHED; disp.dispatchEvent(new Event(status, this)); } }
static void containsTimeOut(Gendreau06Scenario scen, int minutes) { final TimedEvent e = scen.getEvents().get(scen.getEvents().size() - 1); assertThat(e).isInstanceOf(TimeOutEvent.class); assertEquals(minutes * 60 * 1000, e.getTime()); }
} else if (se.getTimedEvent() instanceof TimeOutEvent) { simFinish = true; scenarioEndTime = se.getTimedEvent().getTime();
} else if (se.getTimedEvent() instanceof TimeOutEvent) { simFinish = true; scenarioEndTime = se.getTimedEvent().getTime();