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:
- 230:11765008ff3a
- Parent:
- 229:0d6755d765fd
- Child:
- 231:f22901955e0c
--- a/src/CommandParser/cmd.cpp Tue Oct 18 14:18:30 2016 +0000
+++ b/src/CommandParser/cmd.cpp Tue Oct 18 20:23:31 2016 +0000
@@ -601,7 +601,7 @@
void cmd_createCAlg(int argc, char **argv)
{
- if ( argc != 2 ) {
+ if ( argc != 1 ) {
printf("\rusage: create-ca control_ca_equal.json");
return;
}
@@ -616,9 +616,9 @@
"\"false\": \"nothing\" "
"}");
- bool status = GLOBAL_mdot->saveUserFile(argv[1], (void *)data_buf, MAX_FILE_SIZE);
+ bool status = GLOBAL_mdot->saveUserFile("control_ca_eq1.json", (void *)data_buf, MAX_FILE_SIZE);
if ( status != true ) {
- printf("\rFailed to save user file %s\n", argv[1]);
+ printf("\rFailed to save user file %s\n", "control_ca_eq1.json");
return;
}
@@ -627,21 +627,51 @@
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);
+ strncpy(msg->controlFile, "control_ca_eq1.json", sizeof(msg->controlFile)-1);
+
+ MailBox.put(msg);
+
+ Thread::wait(2000);
+
+ // >= 1
+ snprintf(data_buf, sizeof(data_buf),
+ "{"
+ "\"id\": \"EQUAL_TO_129\", "
+ "\"opr\": \"129\", "
+ "\"op\": \"==\", "
+ "\"true\": \"responseA\", "
+ "\"false\": \"nothing\" "
+ "}");
+
+ status = GLOBAL_mdot->saveUserFile("control_ca_greq1.json", (void *)data_buf, MAX_FILE_SIZE);
+ if ( status != true ) {
+ printf("\rFailed to save user file %s\n", "control_ca_greq1.json");
+ return;
+ }
+
+ // send a message to the configuration handler to create the control
+ msg = MailBox.alloc();
+ memset(msg, 0, sizeof(Message_t));
+ msg->action = ACTION_CREATE;
+ msg->control = CONTROL_ALGORITHM;
+ strncpy(msg->controlFile, "control_ca_greq1.json", sizeof(msg->controlFile)-1);
MailBox.put(msg);
}
void cmd_createComposite(int argc, char **argv)
{
- if ( argc != 2 ) {
- printf("\rusage: create-comp control_comp_1.json\n");
+ if ( argc != 1 ) {
+ printf("\rusage: create-comp");
return;
}
+
+ char data_buf[MAX_FILE_SIZE];
+ bool status;
+ Message_t *msg = NULL;
+#if 0
+ // FLOW
char data_buf[MAX_FILE_SIZE];
snprintf(data_buf, sizeof(data_buf),
"{ "
@@ -662,21 +692,57 @@
"]"
"}"
);
- bool status = GLOBAL_mdot->saveUserFile(argv[1], (void *)data_buf, MAX_FILE_SIZE);
+ bool status = GLOBAL_mdot->saveUserFile("control_comp_flow.json", (void *)data_buf, MAX_FILE_SIZE);
if ( status != true ) {
- printf("\rFailed to save user file %s\n", argv[1]);
+ printf("\rFailed to save user file control_comp_flow.json\n");
return;
}
// send a message to the configuration handler to create the control
- Message_t *msg = MailBox.alloc();
+ msg = MailBox.alloc();
memset(msg, 0, sizeof(Message_t));
msg->action = ACTION_CREATE;
msg->control = CONTROL_COMPOSITE;
- strncpy(msg->controlFile, argv[1], sizeof(msg->controlFile)-1);
+ strncpy(msg->controlFile, "control_comp_flow.json", sizeof(msg->controlFile)-1);
+
+ printf("\rDEBUG: sending a request for composite control %s\n", msg->controlFile);
- printf("%s: Sending a create request for control %s type = %u\r\n",
- __func__, msg->controlFile, msg->control);
+ MailBox.put(msg);
+
+ Thread::wait(2000);
+
+#endif
+
+ // LOCKOUT
+ snprintf(data_buf, sizeof(data_buf),
+ "{ "
+ "\"id\": \"LOCKOUT_BLOWDOWN\", "
+ "\"tag\": \"o_rly01\", "
+ "\"ca\": \"EQUAL_TO_129\", "
+ "\"priority\": \"400\", "
+ "\"entries\": \"1\", "
+ "\"outputs\": [ "
+ "{"
+ "\"tag\": \"o_rly02\", "
+ "\"responseA\": \"fixed off\" "
+ "}"
+ "]"
+ "}"
+ );
+ status = GLOBAL_mdot->saveUserFile("control_comp_lockout.json", (void *)data_buf, MAX_FILE_SIZE);
+ if ( status != true ) {
+ printf("\rFailed to save user file control_comp_lockout.json\n");
+ return;
+ }
+
+ // send a message to the configuration handler to create the control
+ msg = MailBox.alloc();
+ memset(msg, 0, sizeof(Message_t));
+ msg->action = ACTION_CREATE;
+ msg->control = CONTROL_COMPOSITE;
+ strncpy(msg->controlFile, "control_comp_lockout.json", sizeof(msg->controlFile)-1);
+
+ printf("\rDEBUG: sending a request for composite control %s\n", msg->controlFile);
MailBox.put(msg);
}
@@ -1492,7 +1558,7 @@
"\"fmt\": \"%%.2f\", "
"\"vcmd\": \"\", "
"\"rfreq\": \"5\" }");
- bool rc = GLOBAL_mdot->saveUserFile("c", (void *)buf, MAX_FILE_SIZE);
+ bool rc = GLOBAL_mdot->saveUserFile("input_i_tra01.json", (void *)buf, MAX_FILE_SIZE);
if ( rc != true ) {
printf("\rFailed to save input_i_tra01.json\n");
return;
@@ -1732,6 +1798,7 @@
Thread::wait(5000);
+#if 0
snprintf(buf, sizeof(buf),
"{ "
"\"id\":\"%s\", "
@@ -1779,6 +1846,7 @@
ModbusMasterMailBox.put(mail);
Thread::wait(5000);
+#endif
// OUTPUT: Relay 01
snprintf(buf, sizeof(buf),
