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/ConfigurationHandler.cpp
- Revision:
- 74:03ccf04998b5
- Parent:
- 72:3754b352f156
- Child:
- 75:96512ccc0443
--- a/src/ConfigurationHandler/ConfigurationHandler.cpp Fri Sep 16 21:44:38 2016 +0000 +++ b/src/ConfigurationHandler/ConfigurationHandler.cpp Mon Sep 19 12:54:55 2016 +0000 @@ -16,7 +16,7 @@ // local function prototypes static int loadPersistentControls(void); -// local helper functions +// local helper functions static int createControl(const Message_t *msg); static int modifyControl(const Message_t *msg); static int destroyControl(const Message_t *msg); @@ -84,7 +84,7 @@ pos->second->getControlFile().c_str()); } } - + if ( !setpointTable.empty() ) { printf("\rSETPOINT CONTROLS\n"); StringSetpointMap::iterator pos; @@ -122,8 +122,37 @@ static bool loaded = false; if ( !loaded ) { // lazy protection - // do something - loaded = true; + // loop through all the control files and create the controls + printf("\rLoading persistent controls\n"); + std::vector<mDot::mdot_file> file_list = GLOBAL_mdot->listUserFiles(); + + for (std::vector<mDot::mdot_file>::iterator i = file_list.begin(); i != file_list.end(); ++i) { + if( strncmp( i->name, CONTROL_SP_STR, strlen(CONTROL_SP_STR)) == 0 ) { + // load the setpoint control + Message_t msg; + msg.control = CONTROL_SETPOINT; + strncpy(msg.controlFile, i->name, sizeof(msg.controlFile)); + int rc = createControl(&msg); + if ( rc != 0 ) { + } else { + printf("\r control %s loaded.\n", msg.controlFile); + } + } else if ( strncmp( i->name, CONTROL_TM_STR, strlen(CONTROL_TM_STR)) == 0 ) { + // load the timer control + Message_t msg; + msg.control = CONTROL_TIMER; + strncpy(msg.controlFile, i->name, sizeof(msg.controlFile)); + int rc = createControl(&msg); + if ( rc != 0 ) { + } else { + printf("\r control %s loaded.\n", msg.controlFile); + } + } else if ( strncmp( i->name, CONTROL_MN_STR, strlen(CONTROL_MN_STR)) == 0 ) { + // TODO: load the manual control -> these may not persist + } else { + // not a control file + } + } } return 0; } @@ -148,8 +177,8 @@ delete setpointControl; } else { setpointTable[msg->controlFile] = setpointControl; - // start the setpoint control - setpointControl->start(); + // start the setpoint control + setpointControl->start(); } break; } @@ -219,7 +248,7 @@ StringSetpointMap::iterator pos; pos = setpointTable.find(msg->controlFile); if ( pos != setpointTable.end() ) { - pos->second->unregisterControl(); + pos->second->unregisterControl(); delete (pos->second); setpointTable.erase(pos); }