Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
170:f9406996ff5b
Parent:
164:7cecd731882e
Child:
196:78397baf0802
--- a/src/ControlTask/ControlTask.cpp	Mon Oct 03 21:33:58 2016 +0000
+++ b/src/ControlTask/ControlTask.cpp	Mon Oct 03 21:57:36 2016 +0000
@@ -4,6 +4,11 @@
 #include "ConfigurationHandler.h"
 #include "MTSLog.h"
 
+static void serviceManualControls(void);
+static void serviceTimerControls(void);
+static void serviceSetpointControls(void);
+
+
 /*****************************************************************************
  * Function:            ControlTask()
  * Description:         This task will loop through all of the configured
@@ -17,38 +22,79 @@
     printf("\r%s has started...\n", __func__);
 
     while ( true ) {
-        
-        // service the manual controls
-        if ( !manualTable.empty() ) {
-            StringManualMap::iterator pos;
-            for ( pos = manualTable.begin(); pos != manualTable.end(); ++pos ) {
-                pos->second->update();
-            }
+        serviceManualControls();
+
+        serviceTimerControls();
+
+        serviceSetpointControls();
+
+        // TODO: service the composite controls
+
+        Thread::wait(1000);     // do we need to wait?
+    }
+}
+
+/*****************************************************************************
+ * Function:            serviceManualControls()
+ * Description:         service the manual controls
+ *                      controls
+ *
+ * @param               none
+ * @return              none
+ *****************************************************************************/
+static void serviceManualControls(void)
+{
+    // service the manual controls
+    if ( !manualTable.empty() ) {
+        StringManualMap::iterator pos;
+        for ( pos = manualTable.begin(); pos != manualTable.end(); ++pos ) {
+            pos->second->update();
         }
-        // service the setpoint controls
-        if ( !setpointTable.empty() ) {
-            StringSetpointMap::iterator pos;
-            for ( pos = setpointTable.begin(); pos != setpointTable.end(); ++pos ) {
-                pos->second->update();
+    }
+}
+
+/*****************************************************************************
+ * Function:            serviceSetpointControls()
+ * Description:         service the setpoint controls
+ *                      controls
+ *
+ * @param               none
+ * @return              none
+ *****************************************************************************/
+static void serviceSetpointControls(void)
+{
+    // service the setpoint controls
+    if ( !setpointTable.empty() ) {
+        StringSetpointMap::iterator pos;
+        for ( pos = setpointTable.begin(); pos != setpointTable.end(); ++pos ) {
+            pos->second->update();
+        }
+    }
+}
+
+/*****************************************************************************
+ * Function:            serviceTimerControls()
+ * Description:         service the timer controls
+ *                      controls
+ *
+ * @param               none
+ * @return              none
+ *****************************************************************************/
+static void serviceTimerControls(void)
+{
+    // service the timer controls
+    if ( !timerTable.empty() ) {
+        StringVectorTimerMap::iterator pos;
+        for ( pos = timerTable.begin(); pos != timerTable.end(); ++pos ) {
+            // the timer vector is sorted by starttime, so we only need
+            // to service the first timer
+            TimerError_t rc = pos->second.front()->update();
+            if ( rc == TIMER_CONTROL_DESTROY ) {
+                // free the memory
+                delete pos->second.front();
+                pos->second.erase(pos->second.begin());
             }
         }
-        // service the timer controls
-        if ( !timerTable.empty() ) {
-            StringVectorTimerMap::iterator pos;
-            for ( pos = timerTable.begin(); pos != timerTable.end(); ++pos ) {
-                // the timer vector is sorted by starttime, so we only need
-                // to service the first timer
-                TimerError_t rc = pos->second.front()->update();
-                if ( rc == TIMER_CONTROL_DESTROY ) {
-                    // free the memory 
-                    delete pos->second.front();
-                    pos->second.erase(pos->second.begin());
-                }
-            }
-        }
-        
-        // service the composite controls 
-        
-        Thread::wait(1000);     // do we need to wait?
     }
+
 }
\ No newline at end of file