Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
156:44f87c5a83ae
Parent:
126:c85ac6a8e9af
Child:
158:36b5a9de58a1
--- a/src/ConfigurationHandler/ConfigurationHandler.cpp	Fri Sep 30 12:27:14 2016 +0000
+++ b/src/ConfigurationHandler/ConfigurationHandler.cpp	Fri Sep 30 13:37:47 2016 +0000
@@ -8,10 +8,11 @@
 #include "global.h"
 #include "SetpointControl.h"
 #include "TimerControl.h"
+#include <algorithm>
 
-StringSetpointMap   setpointTable;          // setpoint control object table
-StringTimerMap      timerTable;             // timer control object table
-StringManualMap     manualTable;            // manual control object table
+StringSetpointMap       setpointTable;          // setpoint control object table
+StringVectorTimerMap    timerTable;             // timer control object table
+StringManualMap         manualTable;            // manual control object table
 
 // local function prototypes
 static int loadPersistentControls(void);
@@ -21,6 +22,10 @@
 static int modifyControl(const Message_t *msg);
 static int destroyControl(const Message_t *msg);
 
+bool compareStartTime(const TimerControl *lhs, const TimerControl *rhs) {
+    return (lhs->getStartTime() < rhs->getStartTime());
+}
+
 /*****************************************************************************
  * Function:            ConfigurationHandler()
  * Description:         The ICE Configuration Handler
@@ -78,9 +83,12 @@
 {
     if ( !timerTable.empty() ) {
         printf("\rTIMER CONTROLS\n");
-        StringTimerMap::iterator pos;
+        StringVectorTimerMap::iterator pos;
         for ( pos = timerTable.begin(); pos != timerTable.end(); ++pos ) {
-            pos->second->display();
+            vector<TimerControl *>::iterator it;
+            for ( it = pos->second.begin(); it != pos->second.end(); ++it ) {
+                (*it)->display();
+            }
         }
     }
 
@@ -116,7 +124,7 @@
 
         printf("\rLoading persistent controls: \n");
         std::vector<mDot::mdot_file> file_list = GLOBAL_mdot->listUserFiles();
-        
+
         loaded = true;
 
         for (std::vector<mDot::mdot_file>::iterator i = file_list.begin(); i != file_list.end(); ++i) {
@@ -186,8 +194,10 @@
                 logError("%s: failed to load %s\n", __func__, msg->controlFile);
                 delete timerControl;
             } else {
-                timerTable[msg->controlFile] = timerControl;
-                // start the timer control 
+                timerTable[timerControl->getOutput()].push_back(timerControl);
+                sort(timerTable[timerControl->getOutput()].begin(),
+                     timerTable[timerControl->getOutput()].end(),
+                     compareStartTime);
                 timerControl->start();
             }
             break;
@@ -254,12 +264,14 @@
             break;
         }
         case CONTROL_TIMER: {
+#if 0
             StringTimerMap::iterator pos;
             pos = timerTable.find(msg->controlFile);
             if ( pos != timerTable.end() ) {
                 delete (pos->second);
                 timerTable.erase(pos);
             }
+#endif
             break;
         }
         case CONTROL_MANUAL: {