public void execute(long t) { /* As fast as possible: no need to reschedule delay event */ if (delayTime == 0) { return; } /* Special case: real time */ if (delayPeriod == Integer.MIN_VALUE) { delayLastSim++; long tmp = System.currentTimeMillis(); if (delayLastSim > tmp) { try { Thread.sleep(delayLastSim - tmp); } catch (InterruptedException e) { } } /* Reschedule us next millisecond */ scheduleEvent(this, t + MILLISECOND); return; } /* Normal operation */ try { Thread.sleep(delayTime); } catch (InterruptedException e) { } /* Reschedule us next period */ scheduleEvent(this, t + delayPeriod * MILLISECOND); }
public void execute(long t) { if (!hasMillisecondObservers) { return; } millisecondObservable.newMillisecond(getSimulationTime()); scheduleEvent(this, t + MILLISECOND); }
/** Starts simulation if stopped, executes one millisecond, and finally stops simulation again. */ public void stepMillisecondSimulation() { if (isRunning()) { return; } TimeEvent stopEvent = new TimeEvent(0) { public void execute(long t) { /* Stop simulation */ stopSimulation(); } }; scheduleEvent(stopEvent, getSimulationTime() + Simulation.MILLISECOND); startSimulation(); }