bcfe3b352acda7a783a70818f1bbaea1568466cb
[cs356-p1-elevator.git] / main.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 #include "elevatorgui.hpp"
11
12 #include <gtkmm/main.h>
13
14
15 int main (int argc, char *argv[])
16 {
17         const int floors = 7;
18         const int elevators = 3;
19
20         // Start GTK
21         Gtk::Main app(argc, argv);
22
23         ElevatorGUI eg(floors, elevators);
24         eg.show ();
25
26         Gtk::Main::run (eg);
27
28
29
30 #if TEST_ELEVATORCONTROLLER
31         const int floors = 10;
32         const int elevators = 2;
33
34         ElevatorController ec(floors, elevators);
35
36         //ec.elevator_request (0, 2);
37         ec.call_elevator_to (3, DOWN);
38
39         for (int i=0; i<35; i++)
40                 ec.move_elevators ();
41
42         // Note: without the GUI, this is dependent on choosing the same elevator
43         // that was randomly chosen by the call_elevator_to() funtion.
44         //
45         // This may need to be run a few times to work :)
46         ec.elevator_request (0, 2);
47
48         for (int i=0; i<35; i++)
49                 ec.move_elevators ();
50 #endif
51
52
53 #if TEST_ELEVATOR
54         Elevator e(2);
55
56         Stop s2(3, DOWN);
57         e.stop_at (s2);
58
59         Stop s3(1, UP);
60         e.stop_at (s3);
61
62         Stop s4(4, DOWN);
63         e.stop_at (s4);
64
65         Stop s5(5, ALL);
66         e.stop_at (s5);
67
68         for (int i=0; i<100; ++i)
69         {
70                 usleep (500000);
71                 e.move ();
72         }
73 #endif
74
75         return 0;
76 }
77
78 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */