/** 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); } } } } } } }
/** * Called once when the door starts opening * * @param hallway which door the event pertains to */ private void doorOpening(Hallway hallway) { // reset weightChange counter weightChange = false; // Check next desired direction nextDirection = mDesiredFloor.getDirection(); current_floor = floorArray.getCurrentFloor(); if (current_floor != mDesiredFloor.getFloor()) { warning("R-T7 Violated: Opening doors at floor" + current_floor + " with no pending calls."); } else if (mDesiredFloor.getHallway() != Hallway.BOTH) { if (mDesiredFloor.getHallway() != hallway) { warning( "R-T7 Violated: Opening doors at floor" + current_floor + " hallway " + hallway + " with no pending calls."); } } }
/** 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."); } }