/** * Stops the simulation. */ public void stop() { clock.stop(); }
static RealtimeBuilder create(long length, Unit<Duration> unit, ClockMode mode) { return new AutoValue_TimeModel_RealtimeBuilder(length, unit, mode); } }
@Override public void tick(TimeLapse timeLapse) { if (clock.getClockMode() == ClockMode.REAL_TIME) { rtCounter++; } else { stCounter++; } }
static TimeLapse copy(TimeLapse tl) { final TimeLapse copy = TimeLapseFactory.create(tl.getTimeUnit(), tl.getStartTime(), tl.getEndTime()); if (tl.getTimeConsumed() > 0) { copy.consume(tl.getTimeConsumed()); } return copy; }
@Override public void tick(TimeLapse timeLapse) { if (timeLapse.getStartTime() == 200) { clock.switchToSimulatedTime(); } else if (timeLapse.getStartTime() == 600) { clock.switchToRealTime(); } }
@Override public void afterTick(TimeLapse timeLapse) { if (timeLapse.getStartTime() == 3000L) { clock.stop(); } } });
static TimeLapse init() { final TimeLapse tl = TimeLapseFactory.create(0, 1); tl.consumeAll(); return tl; }
/** * @return The current simulation time. */ public long getCurrentTime() { return clock.getCurrentTime(); }
@Override public void tick(TimeLapse timeLapse) { super.tick(timeLapse); if (getTickCount() > 2) { getModel().unregister(d); } } };
@Override public void afterTick(TimeLapse timeLapse) { super.afterTick(timeLapse); if (getTickCount() > 2) { getModel().unregister(this); } } };
@Override public void tick(TimeLapse timeLapse) { super.tick(timeLapse); if (getTickCount() > 2) { getModel().unregister(this); } } };
TickListenerChecker checker() { return new TickListenerChecker(getModel().getTickLength(), getModel() .getTimeUnit()); }
/** * Advances the time a single tick. */ public void tick() { clock.tick(); }
@Override void doStart() { try { while (isTicking()) { tickImpl(); } } catch (final RuntimeException e) { cleanUpAfterException(); throw e; } }
LimitingTickListener limiter(int tickLimit) { return new LimitingTickListener(getModel(), tickLimit); }
/** * @return The unit of time that is used for generating ticks. */ public Unit<Duration> getTimeUnit() { return clock.getTimeUnit(); }
/** * @return An immutable list of {@link RealtimeTickInfo} objects. */ public ImmutableList<RealtimeTickInfo> getTickInfoList() { return ((RealtimeModel) clock).getTickInfoList(); }
/** * @return A new builder for constructing the logger. */ public static ModelBuilder<?, ?> builder() { return new AutoValue_RealtimeClockLogger_Builder(); }