Added Beaglebone code to sensors.c & actuators.c
[matches/MCTX3420.git] / server / sensor.h
1 /**
2  * @file sensor.h
3  * @brief Declarations for sensor thread related stuff
4  */
5
6 #ifndef _SENSOR_H
7 #define _SENSOR_H
8
9 #include "data.h"
10
11 /** Number of sensors **/
12 #define NUMSENSORS 8
13
14 /** Sensor ids - there should be correspondence with the names in g_sensor_names **/
15 typedef enum SensorId 
16 {
17         ANALOG_TEST0,
18         ANALOG_TEST1,
19         ANALOG_REALTEST,
20         ANALOG_FAIL0,
21         DIGITAL_TEST0,
22         DIGITAL_TEST1,
23         DIGITAL_REALTEST,
24         DIGITAL_FAIL0
25 } SensorId;
26
27 /** Human readable names for the sensors **/
28 extern const char * g_sensor_names[NUMSENSORS];
29
30 /** Structure to represent a sensor **/
31 typedef struct
32 {
33         /** ID number of the sensor **/
34         SensorId id;
35         /** DataFile to store sensor values in **/
36         DataFile data_file;
37         /** Indicates whether the Sensor is not stopped **/
38         bool activated;
39         /** Indicates whether the Sensor should record data **/
40         bool record_data;
41         /** Thread the Sensor is running in **/
42         pthread_t thread;
43         /** Most recently recorded data **/
44         DataPoint newest_data;
45 } Sensor;
46
47 // Structure to define the warning and error thresholds of the sensors
48 typedef struct
49 {
50         double max_error;
51         double min_error;
52         double max_warn;
53         double min_warn;
54 } SensorThreshold;
55
56 extern void Sensor_Init(); // One off initialisation of *all* sensors
57
58 extern void Sensor_SetModeAll(ControlModes mode, void * arg);
59 extern void Sensor_SetMode(Sensor * s, ControlModes mode, void * arg);
60
61 extern void * Sensor_Loop(void * args); // Main loop for a thread that handles a Sensor
62 extern bool Sensor_Read(Sensor * s, DataPoint * d); // Read a single DataPoint, indicating if it has changed since the last one
63 extern void Sensor_CheckData(SensorId id, double value); // Check a DataPoint
64 extern Sensor * Sensor_Identify(const char * str); // Identify a Sensor from a string Id
65
66 extern void Sensor_Handler(FCGIContext *context, char * params); // Handle a FCGI request for Sensor data
67
68 #endif //_SENSOR_H
69
70

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