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.
Diff: ICE-Application/src/CommandParser/sequence.cpp
- Revision:
- 2:02cb20446785
- Parent:
- 1:b2e90cda7a5a
--- a/ICE-Application/src/CommandParser/sequence.cpp Tue Jan 24 19:06:45 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,216 +0,0 @@ -#include "cmd_utils.h" -#include "cmd.h" - -void cmd_createSequence(int argc, char **argv) -{ - // - // This command will test the basic functionality of a sequence control - // - // virtual registers: - // v_slugSchedule -> start trigger for the slug dose - // v_alwaysTrue -> always set to 1 - // v_preBleedDone -> set to 1 when prebleed is done - // v_slugFeedDone -> set to 1 when the slug-feed is done - // v_pbTimer -> prebleed timer control output, set to 0 when finished - // - // physical outputs: - // o_rly01 -> blowdown controlled (higher pri setpoint) - // o_rly02 -> slug dose relay - // - // scripts: - // js_nor_regs.js -> performs nor operation of args a, b - // - // timer controls: - // pb-guard-timer -> prebleed guard timer - // - // setpoint controls: - // pre-bleed-sp -> pre-bleed setpoint control - // slug-dose-sp -> slug dose setpoint control - - // vreg: slug-schedule - VregFile_t vreg; - vreg.fname = "vreg_slugScheduleOn.json"; - vreg.id = "v_slugScheduleOn"; - vreg.value = 0; - createVregFile(vreg); - - // vreg: always true - vreg.fname = "vreg_alwaysTrue.json"; - vreg.id = "v_alwaysTrue"; - vreg.value = 1; - createVregFile(vreg); - - // vreg: pre-bleed done - vreg.fname = "vreg_preBleedDone.json"; - vreg.id = "v_preBleedDone"; - vreg.value = 0; - createVregFile(vreg); - - // vreg: slug-feed done - vreg.fname = "vreg_slugFeedDone.json"; - vreg.id = "v_slugFeedDone"; - vreg.value = 0; - createVregFile(vreg); - - // vreg: prebleed timer - vreg.fname = "vreg_pbTimer.json"; - vreg.id = "v_preBleedTimer"; - vreg.value = 0; - createVregFile(vreg); - - // Blowdown Control --------------------------------------------------- - // input - IOFile_t io_file; - memset(&io_file, 0, sizeof(IOFile_t)); - io_file.fname = "input_i_bdcond01.json"; - io_file.id = "i_bdcond01"; - io_file.name = "Tower Conductivity"; - io_file.min = 0; - io_file.max = 6000; - io_file.node = 21; - io_file.reg = 5; - io_file.type = 0; - io_file.regType = REG_TYPE_INPUT; - io_file.size = 2; - io_file.order = 2; - io_file.rfreq = 5; - createIOFile(io_file); - - // output - memset(&io_file, 0, sizeof(io_file)); - io_file.fname = "output_o_rly01.json"; - io_file.id = "o_rly01"; - io_file.name = "Blowdown-Relay"; - io_file.min = 0; - io_file.max = 100; - io_file.node = 0; - io_file.reg = 1; - io_file.type = 0; - io_file.regType = REG_TYPE_OUTPUT; - io_file.size = 2; - io_file.order = 2; - io_file.rfreq = 5; - createIOFile(io_file); - - // blowdown control - SetpointControlFile_t sp; - memset(&sp, 0, sizeof(sp)); - sp.controlFile = "seq_slug_dose_control_sp_prebleed.json"; - sp.actingDir = 1; - sp.id = "blowdown"; - sp.setpoint = 1750; - sp.input = "i_bdcond01"; - sp.output = "o_rly01"; - sp.priority = 750; // this is higher pri than a regular sp control - sp.tolerance = 30; - createSetpointControlFile(sp); - - // timer - TimerControlFile_t timer; - memset(&timer, 0, sizeof(timer)); - timer.controlFile = "seq_slug_dose_control_tm_prebleed.json"; - timer.priority = 750; - timer.output = "v_preBleedTimer"; - timer.id = "prebleed"; - timer.duration = 30; - timer.day = 0; - createTimerControlFile(timer); - - // sequence control - std::string filename = "control_seq_slug_dose.json"; - char buf[MAX_FILE_SIZE * 3]; - snprintf(buf, sizeof(buf), - "{ " - "\"id\": \"slug_dose\", " - "\"startTrigger\": \"v_slugScheduleOn\", " - "\"sequence\": " - "[" - // START PRE-BLEED elements - "{ \"startTrigger\":\"v_alwaysTrue\", " - "\"actions\": " - "[" - "{ \"action\": \"assign\", \"id\": \"v_preBleedTimer\", \"val\":\"1.0\" }," - "{ \"action\": \"assign\", \"id\": \"v_preBleedDone\", \"val\":\"0.0\" }," - "{ \"action\": \"createsp\", \"id\": \"prebleed\" }," - "{ \"action\": \"createtm\", \"id\": \"prebleed\" }" - "]," // end actions array - "\"stopTrigger\": \"v_preBleedDone\" }," - - // DELETE PRE-BLEED elements - "{ \"startTrigger\":\"v_alwaysTrue\", " - "\"actions\": " - "[" - "{ \"action\": \"deletesp\", \"id\": \"prebleed\" }, " - "{ \"action\": \"deletetm\", \"id\": \"prebleed\" }" - "]," - "\"stopTrigger\": \"v_alwaysTrue\" }" -#if 0 - // SLUG-FEED elements - "{ \"startTrigger\":\"v_alwaysTrue\", " - "\"actions\": " - "[" - "{ \"action\": \"createsp\", \"id\": \"SLUG-FEED-SP\" } " - "]," - "\"stopTrigger\": \"v_slugFeedDone\" }," - - // DELETE SLUG-FEED elements - "{ \"startTrigger\":\"v_alwaysTrue\", " - "\"actions\": " - "[" - "{ \"action\": \"deletesp\", \"id\": \"SLUG-FEED-SP\" } " - "]," - "\"stopTrigger\": \"v_alwaysTrue\" }" -#endif - "] " // end sequence array - "} "); - printf("\r[DEBUG: bytes = %u\n", (size_t)strlen(buf)); - bool rc = GLOBAL_mdot->saveUserFile(filename.c_str(), (void *)buf, sizeof(buf)); - if ( rc != true ) { - printf("\rFailed to save %s\n", filename.c_str()); - return; - } else { - printf("\r...generated %s\n", filename.c_str()); - } - - // JavaScript Executor: - // IN: o_rly01 - // IN: v_preBleedTimer - // OUT: v_preBleedDone - // - // Description: execute the js_nor_regs() script with arguments o_rly01 - // and v_pbTimer; stores the result in v_preBleedDone - // - filename = "exe_js_prebleed_done.js"; - snprintf(buf, sizeof(buf), - "{ " - "\"id\":\"PREBLEED_DONE\"," - "\"script\":\"nor_regs\"," - "\"args\":[{\"arg\":\"o_rly01\"},{\"arg\":\"v_preBleedTimer\"},{\"arg\":\"v_preBleedDone\"}]" - "};" - ); - rc = GLOBAL_mdot->saveUserFile(filename.c_str(), (void *)buf, MAX_FILE_SIZE); - if ( rc != true ) { - printf("\rFailed to save %s\n", filename.c_str()); - return; - } else { - printf("\r...generated %s\n", filename.c_str()); - } - - // JavaScript: nor_regs(a, b) => c - filename = "js_nor_regs.js"; - snprintf(buf, sizeof(buf), - "var nor_regs = function(a, b, c) {" - "res1 = getRegister(a);" - "res2 = getRegister(b);" - "if ( res1 == 0 || res2 == 0 ) { setRegister(c, 1); }" - "return 1;" - "};" - ); - rc = GLOBAL_mdot->saveUserFile(filename.c_str(), (void *)buf, MAX_FILE_SIZE); - if ( rc != true ) { - printf("\rFailed to save %s\n", filename.c_str()); - return; - } else { - printf("\r...generated %s\n", filename.c_str()); - } -}