Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed
Fork of ICE by
Diff: src/ConfigurationHandler/Controls/ManualControl.cpp
- Revision:
- 192:052a419837fa
- Parent:
- 177:9ec90c8e3ce1
- Child:
- 195:21df85341cb3
--- a/src/ConfigurationHandler/Controls/ManualControl.cpp Thu Oct 06 12:25:44 2016 +0000
+++ b/src/ConfigurationHandler/Controls/ManualControl.cpp Thu Oct 06 15:36:26 2016 +0000
@@ -13,8 +13,8 @@
extern mDot *GLOBAL_mdot;
-// Method: load
-// Description: open the configuration file and assign data to the
+// method: load
+// description: open the configuration file and assign data to the
// setpoint control object
//
// @param controlFile -> name of the control file
@@ -46,6 +46,18 @@
// parse the json data
parse(json_value, dataBuf);
+ if ( !json_value.hasMember("id") ||
+ !json_value.hasMember("output") ||
+ !json_value.hasMember("type") ||
+ !json_value.hasMember("priority") ||
+ !json_value.hasMember("duration") ||
+ !json_value.hasMember("setpoint") ||
+ !json_value.hasMember("state") ||
+ !json_value.hasMember("percent") ) {
+ logError("Manual Control file is missing expected tags");
+ return false;
+ }
+
id = json_value ["id"].get<string>();
output = json_value ["output"].get<string>();
type = atoi(json_value["type"].get<string>().c_str());
@@ -58,8 +70,8 @@
return true;
}
-// Method: start
-// Description: start the manual control
+// method: start
+// description: start the manual control
//
// @param none
// @return none
@@ -70,8 +82,8 @@
}
-// Method: update
-// Description:
+// method: update
+// description:
//
// @param none
// @return none
@@ -111,8 +123,8 @@
return rc;
}
-// Method: unregisterControl
-// Description: unregister this control with the output master
+// method: unregisterControl
+// description: unregister this control with the output master
//
// @param none
// @return none
@@ -123,17 +135,24 @@
OutputControlMsg_t *output_mail = OutputMasterMailBox.alloc();
memset(output_mail, 0, sizeof(OutputControlMsg_t));
-
+
output_mail->controlType = CONTROL_MANUAL;
output_mail->action = ACTION_CONTROL_UNREGISTER;
output_mail->priority = this->priority;
strncpy(output_mail->output_tag, this->output.c_str(), sizeof(output_mail->output_tag)-1);
strncpy(output_mail->id, this->id.c_str(), sizeof(output_mail->id)-1);
-
+
OutputMasterMailBox.put(output_mail);
return 0;
}
+//
+// method: powerOutput
+// description: send a message to the output thread to power the relay
+//
+// @param none
+// @return -1 on error; 0 otherwise
+//
int ManualControl::powerOutput(void)
{
printf("%s: %s attempting to manually turn %s relay %s\n",
@@ -141,17 +160,24 @@
OutputControlMsg_t *output_mail = OutputMasterMailBox.alloc();
memset(output_mail, 0, sizeof(OutputControlMsg_t));
-
+
output_mail->controlType = CONTROL_MANUAL;
output_mail->action = (state) ? ACTION_CONTROL_ON : ACTION_CONTROL_OFF;
output_mail->priority = this->priority;
strncpy(output_mail->output_tag, this->output.c_str(), sizeof(output_mail->output_tag)-1);
strncpy(output_mail->id, this->id.c_str(), sizeof(output_mail->id)-1);
-
+
OutputMasterMailBox.put(output_mail);
return 0;
}
+//
+// method: display
+// description: display the pertinents
+//
+// @param none
+// @return none
+//
void ManualControl::display(void)
{
string mapper[] = { "INIT",
