/** * 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); } }
/** * 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); } }
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)); } }