Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
250:1cd8ec63e9e9
Parent:
232:8a86b5bf38f7
--- a/src/ConfigurationHandler/ConfigurationHandler.cpp	Thu Oct 20 17:59:18 2016 +0000
+++ b/src/ConfigurationHandler/ConfigurationHandler.cpp	Fri Oct 21 11:42:24 2016 +0000
@@ -16,6 +16,7 @@
 StringVectorTimerMap    timerTable;             // timer control object table
 StringManualMap         manualTable;            // manual control object table
 StringCompositeMap      compositeTable;         // composite control object table
+StringFailsafeMap       failsafeTable;          // failsafe control object table
 StringAlgorithmMap      algorithmTable;         // composite control algorithms
 
 // local function prototypes
@@ -97,7 +98,7 @@
             }
         }
     }
-    
+
     if ( !setpointTable.empty() ) {
         printf("\r\n");
         StringSetpointMap::iterator pos;
@@ -121,8 +122,23 @@
             pos->second->display();
         }
     }
+    
+    if ( !failsafeTable.empty() ) {
+        printf("\r\n");
+        StringFailsafeMap::iterator pos;
+        for ( pos = failsafeTable.begin(); pos != failsafeTable.end(); ++pos ) {
+            pos->second->display();
+        }
+    }
 }
 
+//
+// function:        ConfigurationHandler_showAlgorithms
+// description:     display the control algorithms
+//
+// @param           none
+// @return          none
+//
 void ConfigurationHandler_showAlgorithms(void)
 {
     StringAlgorithmMap::iterator pos;
@@ -194,6 +210,16 @@
                 } else {
                     printf("\r  control %s loaded.\n", msg.controlFile);
                 }
+            } else if ( strncmp( i->name, CONTROL_FS_STR, strlen(CONTROL_FS_STR)) == 0 ) {
+                Message_t msg;
+                msg.control = CONTROL_FAILSAFE;
+                strncpy(msg.controlFile, i->name, sizeof(msg.controlFile));
+                int rc = createControl(&msg);
+                if ( rc != 0 ) {
+                    logError("%s: failed to load %s\n", __func__, msg.controlFile);
+                } else {
+                    printf("\r  control %s loaded.\n", msg.controlFile);
+                }
             } else if ( strncmp( i->name, CONTROL_MN_STR, strlen(CONTROL_MN_STR)) == 0 ) {
                 // TODO: delete any timed manual control, not continuous...
                 GLOBAL_mdot->deleteUserFile(i->name);
@@ -267,11 +293,22 @@
                 delete compositeControl;
             } else {
                 compositeTable[msg->controlFile] = compositeControl;
-                // add this control to the table
                 compositeControl->start();
             }
             break;
         }
+        case CONTROL_FAILSAFE: {
+            FailsafeControl *failsafeControl = new FailsafeControl;
+            bool rc = failsafeControl->load(msg->controlFile);
+            if ( rc != true ) {
+                logError("%s: failed to load %s\n", __func__, msg->controlFile);
+                delete failsafeControl;
+            } else {
+                failsafeTable[msg->controlFile] = failsafeControl;
+                failsafeControl->start();
+            }
+            break;
+        }
         case CONTROL_ALGORITHM: {
             CompositeAlgorithm *compositeAlgorithm = new CompositeAlgorithm;
             bool rc = compositeAlgorithm->load(msg->controlFile);