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:
- 242:3b0086a6d625
- Parent:
- 217:d5a2ff093319
- Child:
- 253:ae850c19cf81
--- a/src/ConfigurationHandler/Controls/ManualControl.cpp Thu Oct 20 14:13:31 2016 +0000
+++ b/src/ConfigurationHandler/Controls/ManualControl.cpp Thu Oct 20 15:30:21 2016 +0000
@@ -6,7 +6,7 @@
*****************************************************************************/
#include "ManualControl.h"
#include "mDot.h"
-#include "MbedJSONValue.h"
+#include "cJSON.h"
#include "ModbusMasterApi.h"
#include "global.h"
#include <string>
@@ -25,7 +25,6 @@
//
bool ManualControl::load(string _controlFile)
{
- MbedJSONValue json_value;
controlFile = _controlFile;
// open and read from the control file
@@ -47,28 +46,16 @@
GLOBAL_mdot->closeUserFile(file);
// 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;
- }
+ cJSON * root = cJSON_Parse(dataBuf);
- id = json_value ["id"].get<string>();
- output = json_value ["output"].get<string>();
- type = atoi(json_value["type"].get<string>().c_str());
- priority = atoi(json_value["priority"].get<string>().c_str());
- duration = atoi(json_value["duration"].get<string>().c_str());
- setpoint = atof(json_value["setpoint"].get<string>().c_str());
- state = atoi(json_value["state"].get<string>().c_str());
- percent = atoi(json_value["percent"].get<string>().c_str());
+ id = cJSON_GetObjectItem(root,"id")->valuestring;
+ output = cJSON_GetObjectItem(root,"output")->valuestring;
+ type = atoi(cJSON_GetObjectItem(root,"type")->valuestring);
+ priority = atoi(cJSON_GetObjectItem(root, "priority")->valuestring);
+ duration = atoi(cJSON_GetObjectItem(root, "duration")->valuestring);
+ setpoint = atof(cJSON_GetObjectItem(root, "setpoint")->valuestring);
+ state = atoi(cJSON_GetObjectItem(root, "state")->valuestring);
+ percent = atoi(cJSON_GetObjectItem(root, "percent")->valuestring);
return true;
}
