X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=server%2Fcontrol.c;h=4da1f7507718de6c90e7517efa1b9542a06a6f10;hb=d0f77e15cfa58191a7683caf343037c25be9f31c;hp=59b5bf80d8ec582d53873c0184730418daca1527;hpb=34ec9353b52472aabc2b42ec0861e004c50b76eb;p=matches%2FMCTX3420.git diff --git a/server/control.c b/server/control.c index 59b5bf8..4da1f75 100644 --- a/server/control.c +++ b/server/control.c @@ -5,14 +5,18 @@ #include "common.h" #include "control.h" +const char * g_actuator_names[NUMACTUATORS] = { + "Pressure regulator", "Solenoid 1" +}; + /** * Handles control of the actuators. */ -void ActuatorHandler(FCGIContext *context, int id, const char *set_value) { +void ActuatorHandler(FCGIContext *context, ActuatorId id, const char *set_value) { char *ptr; switch(id) { //Add new actuators here - case ACT_PREG: //Suppose is pressure regulator. 0-700 input (kPa) + 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) { @@ -37,7 +41,7 @@ void ActuatorHandler(FCGIContext *context, int id, const char *set_value) { FCGI_JSONValue("\"Solenoid 1 turned %s!\"", state); FCGI_EndJSON(); } else { - FCGI_RejectJSON(context); + FCGI_RejectJSON(context, "Invalid actuator value specified"); } } break; default: @@ -57,7 +61,7 @@ void Control_Handler(FCGIContext *context, char *params) { const char *action = NULL, *set_value = NULL; bool force = false; char *ptr; - int id = ACT_NONE; + int id = -1; while ((params = FCGI_KeyPair(params, &key, &value))) { if (!strcmp(key, "action")) @@ -77,7 +81,7 @@ void Control_Handler(FCGIContext *context, char *params) { } if (action == NULL) { //Must have an action - FCGI_RejectJSON(context); + FCGI_RejectJSON(context, "No action specified"); } else if (!strcmp(action, "start")) { FCGI_BeginControl(context, force); } else if (!strcmp(action, "stop")) { //Don't require control key to stop...