Beispiel #1
0
 protected void halt_randomEventsActionPerformed(ActionEvent evt) {
   if (randomEventGen.isRunning()) {
     try {
       randomEventGen.setProbability(Probability.PASSENGER, 0f);
       randomEventGen.setProbability(Probability.FAULT, 0f);
       randomEventGen.setProbability(Probability.EMERGENCY, 0f);
     } catch (ProbabilityOutofBoundsException e) {
       displayError(e.getMessage());
     }
   }
 }
Beispiel #2
0
  public void setupRandomEvents(float pass_prob, float emerg_prob, float hardware_prob) {
    try {
      randomEventGen.setProbability(Probability.PASSENGER, pass_prob);
      randomEventGen.setProbability(Probability.FAULT, hardware_prob);
      randomEventGen.setProbability(Probability.EMERGENCY, emerg_prob);
      if (!randomEventGen.isRunning()) randomEventGen.start();
      if (controller.isRunning()) {
        randomEventGen.runEvents();
      }

    } catch (ProbabilityOutofBoundsException e) {
      displayError(e.getMessage());
    }
  }
Beispiel #3
0
  private void destroyWorld() {
    if (simStarted) {
      simStarted = false;

      // reset safety thread
      safety.interrupt();

      // destroy elevator system
      controller.interrupt();
      controller.destroy();

      // stop random events
      randomEventGen.interrupt();

      // reset logs
      Log.printStatusReport();
      Log.cleanLogs();

      // reset MsgBox
      deleteAllMsgs();

      // reset tabs, passenger table
      for (int i = ElevatorPane.getTabCount() - 1; i > 0; i--) ElevatorPane.remove(i);
      elevatorTabs = null;
      floorDropDownList.removeAllItems();
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              passengerTable.setModel(new PassengerTableModel());
              FloorPassengerTable.setModel(new PassengerTableModel());
            }
          });

      // clean up simulation view
      view.cleanup();
      view.restart();

      // reset timer
      simTimeLabel.setText("00:00:00");

      // recreate objects
      controller = new Controller();
      safety = new Safety(controller);
      try {
        randomEventGen = new RandomEventGenerator(controller, safety, 0.0f, 0.0f, 0.0f);
      } catch (ProbabilityOutofBoundsException e) {
        displayError(e.getMessage());
      }
    }
  }