Add ElevatorController
[cs356-p1-elevator.git] / test.cpp
index 9a0bf7e..6f85ea1 100644 (file)
--- a/test.cpp
+++ b/test.cpp
@@ -1,24 +1,60 @@
 #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;
+       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);
 
-       e.stop_at (2, UP);
-       e.stop_at (3, UP);
-       e.stop_at (4, UP);
-       e.stop_at (5, DOWN);
-       e.stop_at (6, DOWN);
+       Stop s3(1, UP);
+       e.stop_at (s3);
 
-       e.move ();
+       Stop s4(4, DOWN);
+       e.stop_at (s4);
 
-       Elevator e2;
+       Stop s5(5, ALL);
+       e.stop_at (s5);
 
-       e.stop_at (3, DOWN);
+       for (int i=0; i<100; ++i)
+       {
+               usleep (500000);
+               e.move ();
+       }
+#endif
 
        return 0;
 }
 
+/* vim: set ts=4 sts=4 sw=4 noet tw=112: */