Esempio n. 1
0
 /** Called when the drive is transitioning to the Stop state */
 private void driveStopping() {
   int currentFloor = floorArray.getCurrentFloor();
   Hallway h;
   if (Elevator.hasLanding(currentFloor, Hallway.FRONT)) {
     if (Elevator.hasLanding(currentFloor, Hallway.BACK)) h = Hallway.BOTH;
     else h = Hallway.FRONT;
   } else h = Hallway.BACK;
   currentFloor--;
   if (h == Hallway.BOTH) {
     if (!carLights[currentFloor][Hallway.FRONT.ordinal()].lighted()
         && !carLights[currentFloor][Hallway.BACK.ordinal()].lighted()
         && !hallLights[currentFloor][Hallway.FRONT.ordinal()][Direction.UP.ordinal()].lighted()
         && !hallLights[currentFloor][Hallway.FRONT.ordinal()][Direction.DOWN.ordinal()].lighted()
         && !hallLights[currentFloor][Hallway.BACK.ordinal()][Direction.UP.ordinal()].lighted()
         && !hallLights[currentFloor][Hallway.BACK.ordinal()][Direction.DOWN.ordinal()]
             .lighted()) {
       warning("R-T6 Violated: Stopped at floor" + currentFloor + " with no pending calls.");
     }
   } else if (!carLights[currentFloor][h.ordinal()].lighted()
       && !hallLights[currentFloor][h.ordinal()][Direction.UP.ordinal()].lighted()
       && !hallLights[currentFloor][h.ordinal()][Direction.DOWN.ordinal()].lighted()) {
     warning("R-T6 Violated: Stopped at floor" + currentFloor + " with no pending calls.");
   }
 }
Esempio n. 2
0
 /**
  * Called once when the doors are fully open
  *
  * @param hallway which door the event pertains to
  */
 private void doorOpened(Hallway hallway) {
   nextDirection = mDesiredFloor.getDirection();
   // System.out.println(hallway.toString() + " Door Opened");
   // if the lantern flickers, violation of 8.2
   if (nextDirection == Direction.UP) {
     if (carLanterns[Direction.DOWN.ordinal()].lighted())
       warning(
           "R-T8.2 Violated: Both lanterns lit in one cycle! NextDirection "
               + nextDirection
               + " DesiredFloor "
               + mDesiredFloor.getFloor()
               + mDesiredFloor.getHallway()
               + mDesiredFloor.getDirection());
     // Check if car lantern is in compliance with requirements.
   } else if (nextDirection == Direction.DOWN) {
     if (carLanterns[Direction.UP.ordinal()].lighted())
       warning(
           "R-T8.2 Violated: Both lanterns lit in one cycle! NextDirection "
               + nextDirection
               + " DesiredFloor "
               + mDesiredFloor.getFloor()
               + mDesiredFloor.getHallway()
               + mDesiredFloor.getDirection());
     // Check if car lantern is in compliance with requirements.
   }
   // else, nextDirection == STOP and lantern not on.
   else
     for (int f = 1; f < Elevator.numFloors; f++) {
       for (Hallway h : Hallway.replicationValues) {
         for (Direction d : Direction.replicationValues) {
           if (carLights[f][h.ordinal()].lighted()
               || hallLights[f][h.ordinal()][d.ordinal()].lighted()) {
             warning(
                 "R-T8.1 Violated: Lantern not on with other pending"
                     + "calls on other floors at hallway "
                     + hallway);
           }
         }
       }
     }
 }