Subversion Repositories programming

Rev

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

Rev 328 Rev 329
Line 6... Line 6...
6
#include <iostream>
6
#include <iostream>
7
#include <unistd.h>
7
#include <unistd.h>
8
#include <assert.h>
8
#include <assert.h>
9
#include <vector>
9
#include <vector>
10
 
10
 
-
 
11
#include <boost/thread/thread.hpp>
-
 
12
#include <boost/bind.hpp>
-
 
13
 
11
/* Custom #defines for just the elevator class */
14
/* Custom #defines for just the elevator class */
12
#define MOVE_UP     0
15
#define MOVE_UP     0
13
#define MOVE_DOWN   1
16
#define MOVE_DOWN   1
14
#define IDLE        2
17
#define IDLE        2
15
 
18
 
16
#define ELEVATOR_TIME_MOVE_AMOUNT   0.1
19
#define ELEVATOR_TIME_MOVE_AMOUNT   0.05   //0.1
17
#define ELEVATOR_TIME_DELAY_USEC    500000
20
#define ELEVATOR_TIME_DELAY_USEC    250000 //500000
18
#define ELEVATOR_TIME_PAUSE_USEC    50000
21
#define ELEVATOR_TIME_PAUSE_USEC    50000
19
 
22
 
20
class Elevator
23
class Elevator
21
{
24
{
22
    public:
25
    public:
Line 33... Line 36...
33
        // Getters and Setters
36
        // Getters and Setters
34
        int get_direction ();
37
        int get_direction ();
35
        float get_current_floor ();
38
        float get_current_floor ();
36
 
39
 
37
        // Thread Functions
40
        // Thread Functions
38
        static void thread_entry (const Elevator *me);
41
        void thread_start ();
39
        void thread_exit ();
42
        void thread_exit ();
40
        void thread_pause ();
43
        void thread_pause ();
41
        void thread_unpause ();
44
        void thread_unpause ();
42
 
45
 
43
    private:
46
    private:
Line 47... Line 50...
47
        bool has_floors_to_stop_at ();
50
        bool has_floors_to_stop_at ();
48
        bool should_stop_at_current_floor ();
51
        bool should_stop_at_current_floor ();
49
 
52
 
50
        // Thread Functions
53
        // Thread Functions
51
        void run_elevator_logic ();
54
        void run_elevator_logic ();
-
 
55
        static void thread_entry (const Elevator *me);
52
 
56
 
53
        // Private Variables
57
        // Private Variables
54
        int num_floors;
58
        int num_floors;
55
        float current_floor;
59
        float current_floor;
56
        std::vector<bool> stop_at_floors;
60
        std::vector<bool> stop_at_floors;