Exemplo n.º 1
0
        public void execute(long t) {
          if (!hasMillisecondObservers) {
            return;
          }

          millisecondObservable.newMillisecond(getSimulationTime());
          scheduleEvent(this, t + MILLISECOND);
        }
Exemplo n.º 2
0
  /**
   * Add millisecond observer. This observer is notified once every simulated millisecond.
   *
   * @see #deleteMillisecondObserver(Observer)
   * @param newObserver Observer
   */
  public void addMillisecondObserver(Observer newObserver) {
    millisecondObservable.addObserver(newObserver);
    hasMillisecondObservers = true;

    invokeSimulationThread(
        new Runnable() {
          public void run() {
            if (!millisecondEvent.isScheduled()) {
              scheduleEvent(
                  millisecondEvent,
                  currentSimulationTime - (currentSimulationTime % MILLISECOND) + MILLISECOND);
            }
          }
        });
  }
Exemplo n.º 3
0
 public String toString() {
   return "MILLISECOND: " + millisecondObservable.countObservers();
 }
Exemplo n.º 4
0
 /**
  * Delete millisecond observer.
  *
  * @see #addMillisecondObserver(Observer)
  * @param observer Observer to delete
  */
 public void deleteMillisecondObserver(Observer observer) {
   millisecondObservable.deleteObserver(observer);
   hasMillisecondObservers = millisecondObservable.countObservers() > 0;
 }