-#include <iostream>
-#include <list>
-#include <unistd.h>
-using namespace std;
-
-#include "stop.hpp"
-#include "position.hpp"
-#include "elevator.hpp"
-#include "elevatorcontroller.hpp"
-#include "elevatorgui.hpp"
-
-#include <gtkmm/main.h>
+#include "main.hpp"
+ElevatorGUI *thegui = NULL;
int main (int argc, char *argv[])
{
- const int floors = 7;
- const int elevators = 3;
+ int floors = 7;
+ int elevators = 3;
+
+#define USE_STATIC_FLOORS 1
+#ifndef USE_STATIC_FLOORS
+ do
+ {
+ std::cout << "Enter the number of floors to use [2-10]: ";
+ std::cin >> floors;
+
+ if (floors < 2 || floors > 10)
+ {
+ std::cout << "You entered: " << floors
+ << " which is outside the acceptable range." << std::endl;
+ std::cout << "Please try again..." << std::endl << std::endl;
+ }
+ else
+ {
+ // Good input, leave now
+ break;
+ }
+ } while (true);
+
+ do
+ {
+ std::cout << "Enter the number of elevators to use [1-5]: ";
+ std::cin >> elevators;
+
+ if (elevators < 1 || elevators > 5)
+ {
+ std::cout << "You entered: " << elevators
+ << " which is outside the acceptable range." << std::endl;
+ std::cout << "Please try again..." << std::endl << std::endl;
+ }
+ else
+ {
+ // Good input, leave now
+ break;
+ }
+ } while (true);
+#endif
// Start GTK
Gtk::Main app(argc, argv);
+ // Start the GUI
ElevatorGUI eg(floors, elevators);
+ thegui = ⪚
+
+ // Show the GUI
eg.show ();
+ // Run it!
Gtk::Main::run (eg);
-
-
-#if TEST_ELEVATORCONTROLLER
- 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 ();
-#endif
-
-
-#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;
}