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:
- 46:4cb96ab2d1c8
- Parent:
- 37:7e6986b77f01
- Child:
- 51:66b820f203a5
--- a/src/ConfigurationHandler/ConfigurationHandler.cpp Mon Sep 12 14:38:39 2016 +0000
+++ b/src/ConfigurationHandler/ConfigurationHandler.cpp Tue Sep 13 11:59:34 2016 +0000
@@ -9,17 +9,14 @@
#include "SetpointControl.h"
#include "TimerControl.h"
-// setpoint control table
-typedef map<string, SetpointControl*> StringSetpointMap;
-static StringSetpointMap setpointTable;
-
-// timer control table
-typedef map<string, TimerControl*> StringTimerMap;
-static StringTimerMap timerTable;
+StringSetpointMap setpointTable; // setpoint control object table
+StringTimerMap timerTable; // timer control object table
+//StringManualMap manualTable; // manual control object table
// local function prototypes
static int loadPersistentControls(void);
+// local helper functions
static int createControl(const Message_t *msg);
static int modifyControl(const Message_t *msg);
static int destroyControl(const Message_t *msg);
@@ -82,13 +79,12 @@
if ( !timerTable.empty() ) {
printf("\rTIMER CONTROLS\n");
StringTimerMap::iterator pos;
- for ( pos = timerTable.begin();
- pos != timerTable.end();
- ++pos ) {
- printf("\r control file: %32s\n",
- pos->second->getControlFile().c_str());
+ for ( pos = timerTable.begin(); pos != timerTable.end(); ++pos ) {
+ printf("\r control file: %32s\n",
+ pos->second->getControlFile().c_str());
}
}
+
if ( !setpointTable.empty() ) {
printf("\rSETPOINT CONTROLS\n");
StringSetpointMap::iterator pos;
@@ -143,7 +139,7 @@
switch (msg->control) {
case CONTROL_SETPOINT: {
- SetpointControl *setpointControl = new SetpointControl();
+ SetpointControl *setpointControl = new SetpointControl;
bool rc = setpointControl->load(msg->controlFile);
if ( rc != true ) {
logError("%s: failed to load %s\n", __func__, msg->controlFile);
@@ -154,7 +150,7 @@
break;
}
case CONTROL_TIMER: {
- TimerControl *timerControl = new TimerControl();
+ TimerControl *timerControl = new TimerControl;
bool rc = timerControl->load(msg->controlFile);
if ( rc != true ) {
logError("%s: failed to load %s\n", __func__, msg->controlFile);
@@ -164,12 +160,24 @@
}
break;
}
+ case CONTROL_MANUAL: {
+#if 0
+ ManualControl *manualControl = new ManualControl;
+ bool rc = manualControl->load(msg->controlFile);
+ if ( rc != true ) {
+ logError("%s: failed to load %s\n", __func__, msg->controlFile);
+ delete manualControl;
+ } else {
+ manualTable[msg->controlFile] = manualControl;
+ }
+#endif
+ break;
+ }
case CONTROL_PID:
- case CONTROL_MANUAL:
case CONTROL_COMPOSITE:
default:
- logInfo("\r%s: control type %d not implemented yet...\n",
- __func__, msg->control);
+ logInfo("\r%s: control type %d not implemented yet...\n",
+ __func__, msg->control);
break;
}
return 0;
@@ -185,6 +193,8 @@
static int modifyControl(const Message_t *msg)
{
logInfo("\r%s invoked\n", __func__);
+
+ // TODO: can we delete the current object and start a new one?
return 0;
}
@@ -219,6 +229,17 @@
}
break;
}
+ case CONTROL_MANUAL: {
+#if 0
+ StringManualMap::iterator pos;
+ pos = manualTable.find(msg->controlFile);
+ if ( pos != manualTable.end() ) {
+ delete (pos->second);
+ manualTable.erase(pos);
+ }
+#endif
+ break;
+ }
default:
break;
}
