Put FastCGI code into server framework
[matches/MCTX3420.git] / server / sensor.h
1
2 /**
3  * @file sensor.h
4  * @purpose Declarations for sensor thread related stuff
5  */
6
7
8
9 #ifndef _SENSOR_H
10 #define _SENSOR_H
11
12 #include "common.h"
13
14 /** Number of data points to keep in sensor buffers **/
15 #define SENSOR_DATABUFSIZ 10
16
17
18 /** Number of sensors **/
19 #define NUMSENSORS 1
20
21 /** Structure to represent data recorded by a sensor at an instant in time **/
22 typedef struct
23 {
24         /** Time at which data was taken **/
25         float time;
26         /** Value of data **/
27         float value;
28 } DataPoint;
29
30 /** Structure to represent a sensor **/
31 typedef struct
32 {
33         /** ID number of the sensor **/
34         enum {SENSOR_TEST0=0, SENSOR_TEST1=1, SENSOR_NONE} id;
35         /** Buffer to store data from the sensor **/
36         DataPoint buffer[SENSOR_DATABUFSIZ];
37         /** Index of last point written in the data buffer **/
38         int write_index;
39         /** Offset position in binary file for query thread to read from**/
40         int read_offset;
41         /** Binary file to write data into when buffer is full **/
42         FILE * file;
43         /** Thread running the sensor **/
44         pthread_t thread;
45         /** Mutex to protect access to stuff **/
46         pthread_mutex_t mutex;
47
48         
49 } Sensor;
50
51 /** Array of Sensors **/
52 extern Sensor g_sensors[];
53
54 extern void Sensor_Init(Sensor * s, int id); // Initialise sensor
55 extern void * Sensor_Main(void * args); // main loop for sensor thread; pass a Sensor* cast to void*
56
57 extern int Sensor_Query(Sensor * s, DataPoint * buffer, int bufsiz); // fill buffer with sensor data
58
59
60 #endif //_SENSOR_H
61

UCC git Repository :: git.ucc.asn.au