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/CommandParser/cmd.cpp
- Revision:
- 221:2a5e9902003c
- Parent:
- 220:dbe21411f962
- Child:
- 229:0d6755d765fd
--- a/src/CommandParser/cmd.cpp Fri Oct 14 13:32:47 2016 +0000
+++ b/src/CommandParser/cmd.cpp Fri Oct 14 21:30:21 2016 +0000
@@ -64,6 +64,7 @@
{"cmf", "create a manual control file", cmd_cmf },
{"cmt", "create multiple timers", cmd_cmt },
{"cof", "create a test output file", cmd_cof },
+ {"create-ca", "create a control algorithm file", cmd_createCAlg },
{"create-comp", "craete a composite control file", cmd_createComposite },
{"create-mn", "create a manual control", cmd_createManual },
{"create-sp", "create a setpoint control", cmd_createSetpoint },
@@ -88,6 +89,7 @@
{"rm", "remove a user file", cmd_rm },
{"rssi-stats", "get current rssi stats", cmd_rssiStats },
{"set-time", "set current time", cmd_settime },
+ {"show-ca", "show composite algorithms", cmd_ShowAlgorithms },
{"show-controls", "display active controls", cmd_ShowControls },
{"show-outputs", "dump outputs", cmd_outputs },
{"snr-stats", "get current SNR stats", cmd_snrStats },
@@ -298,6 +300,14 @@
}
+void cmd_ShowAlgorithms(int argc, char **argv)
+{
+ UNUSED(argc);
+ UNUSED(argv);
+ ConfigurationHandler_showAlgorithms();
+ printf("\r\n");
+}
+
/*****************************************************************************
* Function: cmd_reset
* Description: reset the cpu
@@ -403,6 +413,11 @@
return;
}
+void cmd_creatCAlg(int argc, char **argv)
+{
+
+}
+
/*****************************************************************************
* Function: cmd_createSetpoint
* Description: create control file
@@ -584,6 +599,42 @@
}
}
+void cmd_createCAlg(int argc, char **argv)
+{
+ if ( argc != 2 ) {
+ printf("\rusage: create-ca control_ca_equal.json");
+ return;
+ }
+
+ char data_buf[MAX_FILE_SIZE];
+ snprintf(data_buf, sizeof(data_buf),
+ "{"
+ "\"id\": \"EQUAL_TO_1\", "
+ "\"opr\": \"1\", "
+ "\"op\": \"==\", "
+ "\"true\": \"responseA\", "
+ "\"false\": \"nothing\" "
+ "}");
+
+ bool status = GLOBAL_mdot->saveUserFile(argv[1], (void *)data_buf, MAX_FILE_SIZE);
+ if ( status != true ) {
+ printf("\rFailed to save user file %s\n", argv[1]);
+ return;
+ }
+
+ // send a message to the configuration handler to create the control
+ Message_t *msg = MailBox.alloc();
+ memset(msg, 0, sizeof(Message_t));
+ msg->action = ACTION_CREATE;
+ msg->control = CONTROL_ALGORITHM;
+ strncpy(msg->controlFile, argv[1], sizeof(msg->controlFile)-1);
+
+ printf("%s: Sending a create request for control %s type = %u\r\n",
+ __func__, msg->controlFile, msg->control);
+
+ MailBox.put(msg);
+}
+
void cmd_createComposite(int argc, char **argv)
{
if ( argc != 2 ) {
@@ -595,18 +646,18 @@
snprintf(data_buf, sizeof(data_buf),
"{ "
"\"id\": \"FLOW_OVERRIDE\", "
- "\"input\": \"i_flowswitch\", "
+ "\"tag\": \"i_flowswitch\", "
"\"ca\": \"EQUAL_TO_1\", "
"\"priority\": \"400\", "
"\"entries\": \"2\", "
"\"outputs\": [ "
"{"
"\"tag\": \"o_rly01\", "
- "\"response\": \"fixed off\" "
+ "\"responseA\": \"fixed off\" "
"},"
"{"
"\"tag\": \"o_rly02\", "
- "\"response\": \"fixed off\" "
+ "\"responseA\": \"fixed off\" "
"}"
"]"
"}"
@@ -2185,7 +2236,6 @@
ModbusMasterMailBox.put(mail);
}
-
/*****************************************************************************
* Function: cmd_trimTemp
* Description: create register command
