Merge branch 'master' of https://github.com/szmoore/MCTX3420.git
[matches/MCTX3420.git] / server / actuator.h
1 /**
2  * @file actuator.h
3  * @brief Declarations for actuator control
4  */
5
6 #ifndef _ACTUATOR_H
7 #define _ACTUATOR_H
8
9 #include "common.h"
10 #include "data.h"
11
12 //NOTE: Functionality is very similar to Sensor stuff
13 //              BUT it's probably very unwise to try and generalise Sensors and Actuators to the same thing (ie: Device)
14 //              Might be OK in C++ but not easy in C
15
16 /** Number of actuators **/
17 #define NUMACTUATORS 3
18
19 /** List of actuator ids (should be of size NUMACTUATORS) **/
20 typedef enum
21 {
22         ACTUATOR_TEST0,
23         ACTUATOR_TEST1,
24         ACTUATOR_TEST2
25 } ActuatorId;
26
27 /** Human readable names for the Actuators **/
28 extern const char * g_actuator_names[NUMACTUATORS];
29
30 /** Control structure for Actuator setting **/
31 typedef struct
32 {
33         //TODO: Add functionality as needed
34         /** Simple value for Actuator **/
35         double value;
36 } ActuatorControl;
37
38 typedef struct
39 {
40         /** ID number of the actuator **/
41         ActuatorId id;
42         /** Control parameters for the Actuator **/
43         ActuatorControl control;
44         /** Flag indicates if ActuatorControl has been changed **/
45         bool control_changed;
46         /** DataFile to store actuator settings **/
47         DataFile data_file;
48         /** Thread the Actuator is controlled by **/
49         pthread_t thread;
50         /** Mutex around ActuatorControl **/
51         pthread_mutex_t mutex;
52         /** Used to wake up Actuator control thread **/
53         pthread_cond_t cond;
54         /** Indicates whether the Actuator is running **/
55         bool activated;
56
57 } Actuator;
58
59 extern void Actuator_Init(); // One off initialisation of *all* Actuators
60
61 extern void Actuator_SetModeAll(ControlModes mode, void *arg);
62 extern void Actuator_SetMode(Actuator * a, ControlModes mode, void *arg);
63
64 extern void * Actuator_Loop(void * args); // Main loop for a thread that handles an Actuator
65 extern void Actuator_SetValue(Actuator * a, double value); // Set an actuator by value
66 extern void Actuator_SetControl(Actuator * a, ActuatorControl * c); // Set the control for an Actuator
67 extern Actuator * Actuator_Identify(const char * str); // Identify a Sensor from a string Id
68
69 extern void Actuator_Handler(FCGIContext *context, char * params); // Handle a FCGI request for Actuator control
70
71 #endif //_ACTUATOR_H
72
73 //EOF

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