64 lines
1.6 KiB
Java
64 lines
1.6 KiB
Java
package simulation;
|
|
|
|
import Requests.CallFromElevatorRequest;
|
|
import Requests.CallFromFloorRequest;
|
|
|
|
import commandSystem.EventQueue;
|
|
import commandSystem.Direction;
|
|
import commandSystem.ElevatorListener;
|
|
import simulation.Elevator;
|
|
|
|
|
|
public class Simulation implements ElevatorListener {
|
|
private boolean running = false;
|
|
private int currentFloor = 0;
|
|
private EventQueue queue;
|
|
private Elevator elevator;
|
|
|
|
public Simulation(Elevator elevator) {
|
|
this.elevator = elevator;
|
|
}
|
|
|
|
public void elevatorCall(int floor) {
|
|
}
|
|
|
|
public void floorCall(int floor, Direction direction) {
|
|
}
|
|
|
|
public void floorChange(Direction d) {
|
|
switch (d) {
|
|
case UP:
|
|
currentFloor++;
|
|
break;
|
|
case DOWN:
|
|
currentFloor--;
|
|
break;
|
|
}
|
|
// iter();
|
|
}
|
|
|
|
// public void iter() {
|
|
// int nextDestination = queue.getNextInstruction();
|
|
// int currentFloor = 0;
|
|
// //System.out.println("next dest = " + nextDestination);
|
|
// if (!running) {
|
|
// if (nextDestination > 0) { /* We have a destination to go to. */
|
|
// running = true;
|
|
// elevator.goDown();
|
|
// }
|
|
// }
|
|
// else {
|
|
// if (elevator.currentFloor == nextDestination) {
|
|
// queue.removeInstruction(elevator.currentFloor, elevator.direction);
|
|
// running = false;
|
|
// }
|
|
// else {
|
|
// elevator.direction = elevator.currentFloor < nextDestination ? Direction.UP : Direction.DOWN;
|
|
// elevator.currentFloor += elevator.direction == Direction.UP ? 1 : -1;
|
|
// }
|
|
// }
|
|
// System.out.println("elevator floor " + elevator.currentFloor + " direction " +
|
|
// (elevator.direction == Direction.UP? "up" : "down") + " running: " + running);
|
|
// }
|
|
}
|