Add ElevatorController
[cs356-p1-elevator.git] / test.cpp
index a7e65d9..6f85ea1 100644 (file)
--- a/test.cpp
+++ b/test.cpp
@@ -1,42 +1,58 @@
 #include <iostream>
 #include <list>
+#include <unistd.h>
 using namespace std;
 
 #include "stop.hpp"
 #include "position.hpp"
 #include "elevator.hpp"
+#include "elevatorcontroller.hpp"
 
 
 int main (int argc, char *argv[])
 {
-       Elevator e;
-
-       Stop s(1, UP);
-       e.stop_at (s);
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
-       e.move ();
+       const int floors = 10;
+       const int elevators = 2;
+
+       ElevatorController ec(floors, elevators);
+
+       //ec.elevator_request (0, 2);
+       ec.call_elevator_to (3, DOWN);
+
+       for (int i=0; i<35; i++)
+               ec.move_elevators ();
+
+       // Note: without the GUI, this is dependent on choosing the same elevator
+       // that was randomly chosen by the call_elevator_to() funtion.
+       //
+       // This may need to be run a few times to work :)
+       ec.elevator_request (0, 2);
+
+       for (int i=0; i<35; i++)
+               ec.move_elevators ();
+
+
+#if TEST_ELEVATOR
+       Elevator e(2);
+
+       Stop s2(3, DOWN);
+       e.stop_at (s2);
+
+       Stop s3(1, UP);
+       e.stop_at (s3);
+
+       Stop s4(4, DOWN);
+       e.stop_at (s4);
+
+       Stop s5(5, ALL);
+       e.stop_at (s5);
+
+       for (int i=0; i<100; ++i)
+       {
+               usleep (500000);
+               e.move ();
+       }
+#endif
 
        return 0;
 }