Rev 329 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#ifndef ELEVATOR_H#define ELEVATOR_H#include <cstdio>#include <iostream>#include <unistd.h>#include <assert.h>#include <vector>using namespace std;/* Custom #defines for just the elevator class */#define MOVE_UP 0#define MOVE_DOWN 1#define IDLE 2#define ELEVATOR_TIME_MOVE_AMOUNT 0.1#define ELEVATOR_TIME_DELAY_USEC 500000#define ELEVATOR_TIME_PAUSE_USEC 50000class Elevator{public:Elevator (int num_floors);~Elevator ();// Service Functionsint floors_above_current ();int floors_below_current ();bool has_any_floors_to_stop_at ();void push_button (int floor);// Getters and Settersint get_direction ();float get_current_floor ();// Thread Functionsstatic void thread_entry (const Elevator *me);void thread_exit ();void thread_pause ();void thread_unpause ();private:// Private Functionsbool near_a_floor ();bool near_floor (int floor);bool has_floors_to_stop_at ();bool should_stop_at_current_floor ();// Thread Functionsvoid run_elevator_logic ();// Private Variablesint num_floors;float current_floor;std::vector<bool> stop_at_floors;int direction;// Thread Variablebool terminate;bool pause;};#endif // ELEVATOR_H