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:
- 96:807f04bd5256
- Parent:
- 93:1553fb156915
- Child:
- 97:5cf6ab71dcd0
--- a/src/CommandParser/cmd.cpp Tue Sep 20 19:58:36 2016 +0000 +++ b/src/CommandParser/cmd.cpp Wed Sep 21 12:54:41 2016 +0000 @@ -55,10 +55,11 @@ // see cmd.h const command_table_t cmdlist[] = { {"?", "help command", cmd_help }, - {"create-control", "create a control", cmd_create }, + //{"create-control", "create a control", cmd_create }, + {"create-setpoint", "create a setpoint control", cmd_createSetpoint }, {"destroy-control", "destroy a control", cmd_destroy }, - {"ccf", "create a test control file", cmd_ccf }, {"cif", "create a test input file", cmd_cif }, + {"cmf", "create a manual control file", cmd_cmf }, {"cof", "create a test output file", cmd_cof }, {"heap", "show heap statistics", cmd_heap }, {"help", "help command", cmd_help }, @@ -362,18 +363,18 @@ } /***************************************************************************** - * Function: cmd_ccf + * Function: cmd_createSetpoint * Description: create control file * * @param argc-> number of args * @param argv-> filename * @return none *****************************************************************************/ -void cmd_ccf(int argc, char **argv) +void cmd_createSetpoint(int argc, char **argv) { - if ( argc != 6 ) { - printf("\rusage: ccf <filename> <id> <input> <output> <direction>\n"); - printf("\rexample: ccf control_sp_1.json SPC_01 i_tra01 o_rly1 1\n"); + if ( argc != 7 ) { + printf("\rusage: create-setpoint <filename> <id> <input> <output> <direction> <tolerance>\n"); + printf("\rexample: create-setpoint control_sp_1.json SPC_01 i_tra01 o_rly1 1 5\r\n"); return; } @@ -381,22 +382,38 @@ snprintf(data_buf, sizeof(data_buf), "{ " "\"id\": \"%s\", " - "\"priority\": \"800\", " + "\"priority\": \"800\"," "\"input\": \"%s\", " "\"output\": \"%s\", " - "\"setpoint\": \"100\", " - "\"prodfact\": \"100\", " + "\"setpoint\": \"100\"," + "\"prodfact\": \"100\"," "\"actingDir\": \"%s\", " - "\"halert\": \"115\", " + "\"halert\": \"115\"," "\"lalert\": \"85\", " - "\"hfs\": \"130\", " - "\"lfs\": \"70\", ", argv[2], argv[3], argv[4], argv[5] + "\"hfs\": \"130\"," + "\"lfs\": \"70\", " + "\"tol\": \"%s\" ", argv[2], argv[3], argv[4], argv[5], argv[6] ); bool status = GLOBAL_mdot->saveUserFile(argv[1], (void *)data_buf, 1024); if( status != true ) { logInfo("(%d)save file failed, status=%d", __LINE__, status); + 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_SETPOINT; + 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); + printf("\r\n"); + return; } /***************************************************************************** @@ -445,6 +462,42 @@ } /***************************************************************************** + * Function: cmd_cmf + * Description: create manual control file + * + * @param argc-> number of args + * @param argv-> filename + * @return none + *****************************************************************************/ +void cmd_cmf(int argc, char **argv) +{ + if ( argc != 2 ) { + printf("\rusage: cmf <filename> <relay\r\n"); + printf("\rexmaple: cmd control_mn_1.json o_rly1"); + return; + } + + char data_buf[1024]; + snprintf(data_buf, sizeof(data_buf), + "{ " + "\"id\": \"%s\", " + "\"type\": \"1\", " + "\"priority\": \"100\", " + "\"duration\": \"30\", " // seconds + "\"setpoint\": \"2000.0\", " + "\"state\": \"1\", " + "\"percent\": \"100\", ", argv[2] + + ); + + bool status = GLOBAL_mdot->saveUserFile(argv[1], (void *)data_buf, 1024); + if( status != true ) { + logInfo("(%d)save file failed, status=%d", __LINE__, status); + } +} + + +/***************************************************************************** * Function: cmd_cof * Description: create output file *