-/**
- * Handles control of the actuators.
- *
-void ActuatorHandler(FCGIContext *context, ActuatorId id, const char *set_value) {
- char *ptr;
-
- switch(id) { //Add new actuators here
- case ACT_PRESSURE: //Suppose is pressure regulator. 0-700 input (kPa)
- {
- int value = strtol(set_value, &ptr, 10);
- if (*ptr == '\0' && value >= 0 && value <= 700) {
- FCGI_BeginJSON(context, STATUS_OK);
- FCGI_JSONKey("description");
- FCGI_JSONValue("\"Set pressure to %d kPa!\"", value);
- FCGI_EndJSON();
- } else {
- FCGI_RejectJSONEx(context,
- STATUS_ERROR, "Invalid pressure specified.");
- }
- } break;
- case ACT_SOLENOID1:
- {
- int value = strtol(set_value, &ptr, 10);
- if (*ptr == '\0') {
- const char *state = "off";
- if (value)
- state = "on";
- FCGI_BeginJSON(context, STATUS_OK);
- FCGI_JSONKey("description");
- FCGI_JSONValue("\"Solenoid 1 turned %s!\"", state);
- FCGI_EndJSON();
- } else {
- FCGI_RejectJSON(context, "Invalid actuator value specified");
- }
- } break;
- default:
- FCGI_RejectJSONEx(context,
- STATUS_ERROR, "Invalid actuator id specified.");
+ControlData g_controls = {CONTROL_STOP, PTHREAD_MUTEX_INITIALIZER, {0}};
+
+static bool PathExists(const char *path) {
+ FILE *fp = fopen(path, "r");
+ if (fp) {
+ fclose(fp);
+ return true;