示例#1
0
        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);
        }
示例#2
0
        public void execute(long t) {
          if (!hasMillisecondObservers) {
            return;
          }

          millisecondObservable.newMillisecond(getSimulationTime());
          scheduleEvent(this, t + MILLISECOND);
        }
示例#3
0
 /** 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();
 }