-
Notifications
You must be signed in to change notification settings - Fork 0
/
elev.h
123 lines (82 loc) · 2.63 KB
/
elev.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// Wrapper for libComedi Elevator control.
// These functions provides an interface to the elevators in the real time lab
//
// 2007, Martin Korsgaard
#ifndef __INCLUDE_DRIVER_H__
#define __INCLUDE_DRIVER_H__
// Number of floors
#define N_FLOORS 4
/**
Initialize elevator.
@return Non-zero on success, 0 on failure.
*/
int elev_init(void);
/**
Motor direction for function elev_set_motor_direction().
*/
typedef enum tag_elev_motor_direction {
DIRN_DOWN = -1,
DIRN_STOP = 0,
DIRN_UP = 1
} elev_motor_direction_t;
/**
Sets the motor direction of the elevator.
@param dirn New direction of the elevator.
*/
void elev_set_motor_direction(elev_motor_direction_t dirn);
/**
Turn door-open lamp on or off.
@param value Non-zero value turns lamp on, 0 turns lamp off.
*/
void elev_set_door_open_lamp(int value);
/**
Get signal from obstruction switch.
@return 1 if obstruction is enabled. 0 if not.
*/
int elev_get_obstruction_signal(void);
/**
Get signal from stop button.
@return 1 if stop button is pushed, 0 if not.
*/
int elev_get_stop_signal(void);
/**
Turn stop lamp on or off.
@param value Non-zero value turns lamp on, 0 turns lamp off.
*/
void elev_set_stop_lamp(int value);
/**
Get floor sensor signal.
@return -1 if elevator is not on a floor. 0-3 if elevator is on floor. 0 is
ground floor, 3 is top floor.
*/
int elev_get_floor_sensor_signal(void);
/**
Set floor indicator lamp for a given floor.
@param floor Which floor lamp to turn on. Other floor lamps are turned off.
*/
void elev_set_floor_indicator(int floor);
/**
Button types for function elev_set_button_lamp() and elev_get_button().
*/
typedef enum tag_elev_lamp_type {
BUTTON_CALL_UP = 0,
BUTTON_CALL_DOWN = 1,
BUTTON_COMMAND = 2
} elev_button_type_t;
/**
Gets a button signal.
@param button Which button type to check. Can be BUTTON_CALL_UP,
BUTTON_CALL_DOWN or BUTTON_COMMAND (button "inside the elevator).
@param floor Which floor to check button. Must be 0-3.
@return 0 if button is not pushed. 1 if button is pushed.
*/
int elev_get_button_signal(elev_button_type_t button, int floor);
/**
Set a button lamp.
@param lamp Which type of lamp to set. Can be BUTTON_CALL_UP,
BUTTON_CALL_DOWN or BUTTON_COMMAND (button "inside" the elevator).
@param floor Floor of lamp to set. Must be 0-3
@param value Non-zero value turns lamp on, 0 turns lamp off.
*/
void elev_set_button_lamp(elev_button_type_t button, int floor, int value);
#endif // #ifndef __INCLUDE_DRIVER_H__