示例#1
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());
    }
  }
示例#2
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());
    }
  }