Subversion Repositories programming

Rev

Rev 340 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 340 Rev 344
Line 9... Line 9...
9
#ifndef CONTROLLER_H
9
#ifndef CONTROLLER_H
10
#define CONTROLLER_H
10
#define CONTROLLER_H
11
 
11
 
12
#include <assert.h>
12
#include <assert.h>
13
#include <vector>
13
#include <vector>
-
 
14
#include <queue>
14
#include <limits.h>
15
#include <limits.h>
15
#include <math.h>
16
#include <math.h>
16
#include <cstdio>
17
#include <iostream>
-
 
18
#include <iomanip>
-
 
19
 
-
 
20
#include <glibmm.h>
17
 
21
 
18
#include "elevator.h"
22
#include "elevator.h"
-
 
23
#include "dispatch_data.h"
19
#include "elevator_window.h"
24
#include "elevator_window.h"
20
 
25
 
21
class Elevator;
26
class Elevator;
22
class Elevator_Window;
27
class Elevator_Window;
23
 
28
 
Line 25... Line 30...
25
{
30
{
26
    public:
31
    public:
27
        Controller (int num_floors, int num_elevators);
32
        Controller (int num_floors, int num_elevators);
28
        ~Controller ();
33
        ~Controller ();
29
 
34
 
-
 
35
        // Mass thread functions
30
        void start_all_elevators ();
36
        void start_all_elevators ();
31
        void stop_all_elevators ();
37
        void stop_all_elevators ();
32
        void pause_all_elevators ();
38
        void pause_all_elevators ();
33
        void unpause_all_elevators ();
39
        void unpause_all_elevators ();
34
 
40
 
35
        void request_elevator (int on_floor, int direction);
41
        void request_elevator (int on_floor, int direction);
36
        void disable_elevator (int elevator_number);
-
 
37
        void enable_elevator (int elevator_number);
-
 
38
 
-
 
39
        void stop_at_floor (Elevator *e, int on_floor);
-
 
40
        void update_elevator_position (Elevator *e);
-
 
41
 
42
 
-
 
43
        // Public Dispatcher Stuff
42
        void set_gui (Elevator_Window *gui);
44
        void set_gui (Elevator_Window *gui);
-
 
45
        void push_to_gui_queue (Dispatch_Data data);
-
 
46
        void push_button_in_elevator (int elevator_num, int floor);
43
 
47
 
44
    private:
48
    private:
45
        bool floor_already_requested (int on_floor);
49
        bool floor_already_requested (int on_floor);
46
        int find_closest_elevator (int to_floor, int in_direction);
50
        int find_closest_elevator (int to_floor, int in_direction);
47
        int which_elevator_is (Elevator *e);
51
        int which_elevator_is (Elevator *e);
48
 
52
 
49
        std::vector<Elevator*> elevator;
53
        std::vector<Elevator*> elevator;
50
        int num_floors;
54
        int num_floors;
51
        int num_elevators;
55
        int num_elevators;
52
 
56
 
-
 
57
        // GUI Functions
-
 
58
        void stop_at_floor (Elevator *e, int on_floor);
-
 
59
        void update_elevator_position (Elevator *e, float new_floor);
-
 
60
 
-
 
61
        // Dispatcher Stuff
-
 
62
        Glib::Dispatcher dispatcher;
-
 
63
        std::queue<Dispatch_Data> gui_events;
-
 
64
        void dispatch_handler ();
-
 
65
 
53
        Elevator_Window *gui;
66
        Elevator_Window *gui;
54
};
67
};
55
 
68
 
56
#endif // CONTROLLER_H
69
#endif // CONTROLLER_H
57
 
70