-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.h
107 lines (84 loc) · 2.81 KB
/
types.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
#pragma once
#include <pthread.h>
extern const int QUEUE_ERROR;
extern const int QUEUE_SUCCESS;
//inside buttons
extern const int FLOOR_ONE_REQUEST;
extern const int FLOOR_TWO_REQUEST;
extern const int FLOOR_THREE_REQUEST;
//outside buttons
extern const int FLOOR_ONE_UP_REQUEST;
extern const int FLOOR_TWO_DOWN_REQUEST;
extern const int FLOOR_TWO_UP_REQUEST;
extern const int FLOOR_THREE_DOWN_REQUEST;
extern const int FIRE_CODE;
extern const int INITIAL_QUEUE_SIZE;
extern const int QUEUE_EMPTY_FLAG ;
extern const int INITIAL_DOOR_WAIT_TIME ;
extern const int IR_DOOR_WAIT_TIME;
extern const int NUMBER_OF_FLOORS;
extern const char FLOOR_CHAR_EXTERNAL_ONE_UP;
extern const char FLOOR_CHAR_EXTERNAL_TWO_UP;
extern const char FLOOR_CHAR_EXTERNAL_TWO_DOWN;
extern const char FLOOR_CHAR_EXTERNAL_THREE_DOWN;
extern const char FLOOR_CHAR_INTERNAL_ONE;
extern const char FLOOR_CHAR_INTERNAL_TWO;
extern const char FLOOR_CHAR_INTERNAL_THREE;
extern const int ELEVATOR_DEFAULT_SPEED_DOWN;
extern const int ELEVATOR_DEFAULT_SPEED_UP;
extern const int GIPO_PIN_IR_SEND;
extern const int GIPO_PIN_IR_RECIEVE;
extern const int GIPO_PIN_REED;
extern const int GIPO_PIN_MOTOR_DOWN;
extern const int GIPO_PIN_MOTOR_UP;
extern const int GIPO_PIN_MOTOR_PWM;
//lots of output, shouldn't have alot happening
extern const int LOG_LEVEL_DEBUG;
//are there bugs happening?
extern const int LOG_LEVEL_ERROR;
//I WANT EVERYTHING EVEN IF IT LOOPS A THOUSAND TIMES A SECOND!
extern const int LOG_LEVEL_SUPERDEBUG;
//structures
struct ElevatorData {
//used by lights data
//this cannot be of variable size in this .c file
//instead I will initialize it to the proper size
//with that, it will work fine
//int externalFloorRequests[2 + ((NUMBER_OF_FLOORS - 2) * 2)];
int *externalFloorRequests;
//same here. Turning to a pointer and malloc to make it an array of
//propper size
//int internalFloorRequests[NUMBER_OF_FLOORS];
int *internalFloorRequests;
//array, treated as a queue, that will
//hold the next floor to go to.
//the floor queue is going to start
//as an array of INITIAL_QUEUE_SIZE
//then will dynamically resize
//as it is needed to while elements are removed
int queueSize;
int *floorQueue;
//no longer queue-related stuff
int reachedFloorFlag;
//later on
//make so that all threads
//loop until this is equal to 1
int stopProgramFlag;
int doorFlag;
long lastIRTime;
int doorOpenFlag;
int initialDoorWaitOverFlag;
int currentFloor;
int nextFloor;
};
struct ArgumentData{
struct ElevatorData *ed;
pthread_mutex_t *mutex;
};
//functions
//logging will have levels
//log function will take a string and an int
//logs above the level of the current number will display
//logs below the level set here will not display
void logString(char* string, int level);
void debugBlock(struct ElevatorData *ed);