Beispiel #1
0
 // RANDOM EVENTS
 protected void setup_randomEventsActionPerformed(ActionEvent evt) {
   SetupRandomEventsDialog dialog = new SetupRandomEventsDialog(this, true);
   dialog.setSliders(
       randomEventGen.getPassengerProb(),
       randomEventGen.getEmergencyProb(),
       randomEventGen.getFaultProb());
   dialog.setVisible(true);
 }
Beispiel #2
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 #3
0
 private void Start_Stop_buttonActionPerformed(java.awt.event.ActionEvent evt) {
   if (controller.isRunning()) {
     controller.pauseSim();
     randomEventGen.pauseEvents();
     simStatusLabel.setText("PAUSED");
     simStatusLabel.setForeground(new java.awt.Color(255, 0, 0));
   } else {
     controller.runSim();
     randomEventGen.runEvents();
     simStatusLabel.setText("RUNNING");
     simStatusLabel.setForeground(new Color(0, 128, 0));
   }
 }
Beispiel #4
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 #5
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());
      }
    }
  }
Beispiel #6
0
  public void createWorld(
      int numElevators, int numFloors, Boolean penthouse, Vector<Integer>[] bounds) {
    if (simStarted) destroyWorld();

    try {
      controller.setFloors(numFloors);
      controller.createElevators(numElevators);

      if (penthouse) controller.addPenthouse();
      for (int e = 0; e < bounds.length; e++) {
        for (int f = 0; f < bounds[e].size(); f++) controller.lockFloor(e, bounds[e].get(f));
      }

      view.createWorld(numElevators, numFloors, penthouse, bounds);

      controller.setSimView(this, view);
      controller.start();
      safety.start();
      randomEventGen.start();

      postGeneralEventMsg("Welcome to BOSS LIFT Elevator Simulator!");
      postGeneralEventMsg("The simulation is PAUSED");
      simStatusLabel.setText("PAUSED");
      simStatusLabel.setForeground(new java.awt.Color(255, 0, 0));

      elevatorTabs = new ElevatorInfoPanel[numElevators];
      for (int i = 0; i < numElevators; i++) {
        elevatorTabs[i] = new ElevatorInfoPanel();
        if (bounds[i].size() > 0)
          elevatorTabs[i].setElevatorBounds(controller.getElevatorBounds(i));
        JScrollPane p = new JScrollPane();
        p.setViewportView(elevatorTabs[i]);
        ElevatorPane.addTab("E" + i, p);
      }

      setGUIEnabled(true);
      populateElevatorMenus(numElevators);

      for (int i = 0; i < numFloors; i++) {
        floorDropDownList.addItem(i);
      }

      simStarted = true;

      controller.setAlgorithm(AlgorithmDropList.getSelectedIndex());
    } catch (BossLiftGeneralException e1) {
      displayError(e1.getMessage());
    }
  }