Beispiel #1
0
        // ***************************
        // AssignElevator (RequestedFloor) This method will be used for the requests made on
        //the first floor.
        public void AssignElevator(int RequestedFloor)
        {
            Console.WriteLine(">>> Someone at RC wants to go to the : " + RequestedFloor + "<<<");
            Console.WriteLine("----------------------------------------------------------\n");

            // find the correespondante column
            Column   column  = getColumn(RequestedFloor);
            Elevator bestFit = findBestElevator(RequestedFloor, column);

            Console.WriteLine("- Select elevetor: " + column.id + " [" + bestFit.id + "]" + " Position: " + bestFit.position + " to RC");
            bestFit.doors.openDoor();

            if (bestFit.safetyFirst(bestFit.weightmax, bestFit.sensor))
            {
                Console.WriteLine("Safety check: is ok !");
                bestFit.doors.closeDoor();
            }

            // To assign a elevator : STEP 1: we move elevator to Rc
            bestFit.moveElevator(1);

            Console.WriteLine("- stopover: " + column.id + " [" + bestFit.id + "]" + " Position : " + bestFit.position + " Is sent to : " + RequestedFloor);

            bestFit.doors.openDoor();

            if (bestFit.safetyFirst(bestFit.weightmax, bestFit.sensor))
            {
                Console.WriteLine("Safety check: is ok !");
                bestFit.doors.closeDoor();
            }
            // STEP 2: we move elevator to RequestedFloor
            bestFit.moveElevator(RequestedFloor);
            bestFit.doors.openDoor();
        }
Beispiel #2
0
        // This method represents an elevator request on a floor or basement.
        public void RequestElevator(int FloorNumber)
        {
            Console.WriteLine(">> User at : " + FloorNumber + " wants to go to RC <<");
            Console.WriteLine("----------------------------------------------------------");

            // find the right column and get the best elevator
            Column   column   = getColumn(FloorNumber);
            Elevator elevator = column.bestElevator(FloorNumber);

            Console.WriteLine("- Select elevator  " + column.id + " [" + elevator.id + "]" + " Position: " + elevator.position + " sent to: " + FloorNumber);

            elevator.doors.openDoor();
            // Safety Check
            if (elevator.safetyFirst(elevator.weightmax, elevator.sensor))
            {
                Console.WriteLine("Safety check: is ok !");
                elevator.doors.closeDoor();
            }
            // Move Elevator
            elevator.moveElevator(FloorNumber);

            elevator.doors.openDoor();
            if (elevator.safetyFirst(elevator.weightmax, elevator.sensor))
            {
                Console.WriteLine("Safety check: is ok !");
                elevator.doors.closeDoor();
            }

            // move the elevator to RC
            elevator.moveElevator(1);
            elevator.doors.openDoor();
        }