Add ElevatorController
[cs356-p1-elevator.git] / test.cpp
1 #include <iostream>
2 #include <list>
3 #include <unistd.h>
4 using namespace std;
5
6 #include "stop.hpp"
7 #include "position.hpp"
8 #include "elevator.hpp"
9 #include "elevatorcontroller.hpp"
10
11
12 int main (int argc, char *argv[])
13 {
14         const int floors = 10;
15         const int elevators = 2;
16
17         ElevatorController ec(floors, elevators);
18
19         //ec.elevator_request (0, 2);
20         ec.call_elevator_to (3, DOWN);
21
22         for (int i=0; i<35; i++)
23                 ec.move_elevators ();
24
25         // Note: without the GUI, this is dependent on choosing the same elevator
26         // that was randomly chosen by the call_elevator_to() funtion.
27         //
28         // This may need to be run a few times to work :)
29         ec.elevator_request (0, 2);
30
31         for (int i=0; i<35; i++)
32                 ec.move_elevators ();
33
34
35 #if TEST_ELEVATOR
36         Elevator e(2);
37
38         Stop s2(3, DOWN);
39         e.stop_at (s2);
40
41         Stop s3(1, UP);
42         e.stop_at (s3);
43
44         Stop s4(4, DOWN);
45         e.stop_at (s4);
46
47         Stop s5(5, ALL);
48         e.stop_at (s5);
49
50         for (int i=0; i<100; ++i)
51         {
52                 usleep (500000);
53                 e.move ();
54         }
55 #endif
56
57         return 0;
58 }
59
60 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */