-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sensor.h
executable file
·50 lines (40 loc) · 1.1 KB
/
Sensor.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
#ifndef SENSOR_H
#define SENSOR_H
/*for testing*/
#ifndef MOCK_OBJECTS
#include "AbstractController.h"
#else
#include "test/mock_Controller.h"
#endif
#include <pthread.h>
class Sensor
{
/*instance variables*/
private:
AbstractController *target; //controller to set flag on
char trigger; //character to detect when input is read
int flagPosition; //flag to set when trigger is detected
int readFD; //file descriptor to read on
int writeFD; //file descriptor to write on
pthread_t *thread;
pthread_attr_t *threadAttr;
/*constructors*/
public:
Sensor(AbstractController *target, char trigger, int flagPosition,
int readFD);
Sensor(AbstractController *target, char trigger, int flagPosition);
~Sensor();
/*member functions*/
public:
int getReadFD();
int getWriteFD();
int getTrigger();
void checkTrigger(char received);
private:
void createThread();
};
/*non member function for thread*/
namespace sensor_util {
void *listen(void *args);
}
#endif