Exemplo n.º 1
0
 /** Called when the drive is in the Slow State */
 private void driveSlow() {
   // Check if there are any calls in the specified direction.
   // If so, then violation. Otherwise, no violation.
   if (nextDirection != Direction.STOP) {
     int currentFloor = floorArray.getCurrentFloor() - 1;
     if (nextDirection == Direction.UP) {
       for (int f_u = currentFloor + 1; f_u < Elevator.numFloors; f_u++) {
         for (Hallway h : Hallway.replicationValues) {
           for (Direction d : Direction.replicationValues) {
             if (carLights[f_u][h.ordinal()].lighted()
                 || hallLights[f_u][h.ordinal()][d.ordinal()].lighted()) {
               if (nextDirection != driveActualSpeed.direction())
                 warning(
                     "R-T8.3 Violated: Elevator is sevicing direction "
                         + driveActualSpeed.direction()
                         + " instead of "
                         + (f_u + 1)
                         + " "
                         + h
                         + " in direction "
                         + nextDirection);
             }
           }
         }
       }
     } else if (nextDirection == Direction.DOWN) {
       for (int f_d = currentFloor - 1; f_d >= 1; f_d--) {
         for (Hallway h : Hallway.replicationValues) {
           for (Direction d : Direction.replicationValues) {
             if (carLights[f_d][h.ordinal()].lighted()
                 || hallLights[f_d][h.ordinal()][d.ordinal()].lighted()) {
               if (nextDirection != driveActualSpeed.direction())
                 warning(
                     "R-T8.3 Violated: Elevator is sevicing direction "
                         + driveActualSpeed.direction()
                         + " instead of "
                         + f_d
                         + " "
                         + h
                         + " in direction "
                         + nextDirection);
             }
           }
         }
       }
     }
   }
 }
Exemplo 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);
           }
         }
       }
     }
 }