Updated control stuff
[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 2
18
19 /** List of actuator ids (should be of size NUMACTUATORS) **/
20 typedef enum
21 {
22         ACTUATOR_TEST0,
23         ACTUATOR_TEST1
24 } ActuatorId;
25
26 /** Human readable names for the Actuators **/
27 extern const char * g_actuator_names[NUMACTUATORS];
28
29 /** Control structure for Actuator setting **/
30 typedef struct
31 {
32         //TODO: Add functionality as needed
33         /** Simple value for Actuator **/
34         double value;
35 } ActuatorControl;
36
37 typedef struct
38 {
39         /** ID number of the actuator **/
40         ActuatorId id;
41         /** Control parameters for the Actuator **/
42         ActuatorControl control;
43         /** Flag indicates if ActuatorControl has been changed **/
44         bool control_changed;
45         /** DataFile to store actuator settings **/
46         DataFile data_file;
47         /** Thread the Actuator is controlled by **/
48         pthread_t thread;
49         /** Mutex around ActuatorControl **/
50         pthread_mutex_t mutex;
51         /** Used to wake up Actuator control thread **/
52         pthread_cond_t cond;
53         /** Indicates whether the Actuator is running **/
54         bool activated;
55         /** Indicates whether the Actuator can be actuated or not **/
56         bool allow_actuation;
57
58 } Actuator;
59
60 extern void Actuator_Init(); // One off initialisation of *all* Actuators
61
62 extern void Actuator_SetModeAll(ControlModes mode, void *arg);
63 extern void Actuator_SetMode(Actuator * a, ControlModes mode, void *arg);
64
65 extern void * Actuator_Loop(void * args); // Main loop for a thread that handles an Actuator
66 extern void Actuator_SetValue(Actuator * a, double value); // Set an actuator by value
67 extern void Actuator_SetControl(Actuator * a, ActuatorControl * c); // Set the control for an Actuator
68 extern Actuator * Actuator_Identify(const char * str); // Identify a Sensor from a string Id
69
70 extern void Actuator_Handler(FCGIContext *context, char * params); // Handle a FCGI request for Actuator control
71
72 #endif //_ACTUATOR_H
73
74 //EOF

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