Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
70:7427f4959201
Parent:
67:49f266601d83
Child:
71:34856d21f2bf
--- a/src/OutputTask/OutputTask.cpp	Fri Sep 16 15:30:47 2016 +0000
+++ b/src/OutputTask/OutputTask.cpp	Fri Sep 16 17:54:51 2016 +0000
@@ -1,24 +1,54 @@
+/******************************************************************************
+ *
+ * File:                OutputTask.cpp
+ * Desciption:          source for the ICE Output task
+ *
+ *****************************************************************************/
 #include "OutputTask.h"
 #include "global.h"
 #include "MbedJSONValue.h"
+#include <vector>
 
+// locals
 static int  createOutput(const char *controlFile);
 static void loadPersistentOutputs(void);
 
+class Control
+{
+private:
+    string          id;
+    unsigned int    priority;
+    typedef enum { CONTROL_OFF = 0, CONTROL_ON = 1 } State;
+    State           state;
+public:
+    Control(string id, unsigned int priority, State state) :
+        id(id), priority(priority), state(state) {}
+};
+
+vector<Control> controlStack;
+
 typedef std::map<string, string> StringOutputVector_t;
 
 StringOutputVector_t outputMap;
 
+/*****************************************************************************
+ * Function:            OutputTask
+ * Description:         Main entry point for the Output Task
+ *
+ * @param               args -> not used
+ * @return              none
+ *****************************************************************************/
 void OutputTask(void const *args)
 {
     UNUSED(args);
-    
+
     printf("\r%s has started...\n", __func__);
 
     loadPersistentOutputs();
 
     while (true) {
         // wait for an event
+        printf("\r%s is waiting for an event\n", __func__);
         osEvent evt = OutputMasterMailBox.get();
         if (evt.status == osEventMail) {
             OutputControlMsg_t *msg = (OutputControlMsg_t*) evt.value.p;
@@ -26,6 +56,8 @@
             printf("\rmsg->relay    = %s\n", msg->output.c_str());
             printf("\rmsg->state    = %s\n", msg->state == ON ? "ON" : "OFF");
             printf("\rmsg->priority = %u\n", msg->priority);
+            
+            Thread::wait(2000);
 
             switch ( msg->action ) {
                 case ACTION_NEW:
@@ -43,6 +75,13 @@
     }
 }
 
+/*****************************************************************************
+ * Function:            DisplayOutputs
+ * Description:         Display a list of outputs and its controls
+ *
+ * @param               args -> not used
+ * @return              none
+ *****************************************************************************/
 void DisplayOutputs(void)
 {
     StringOutputVector_t::iterator pos;
@@ -78,9 +117,11 @@
 {
     bool status;
     MbedJSONValue json_value;
+    
+    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, OUTPUT_STR, strlen(OUTPUT_STR)) == 0 ) {
 
@@ -98,8 +139,8 @@
             parse( json_value, scratchBuf );
 
             string id = json_value["id"].get<string>();
-            printf("\r%s id = %s\n", __func__, id.c_str());
+            printf("\r   %s id = %s loaded\n", __func__, id.c_str());
             outputMap[id] = "Null for now";
         }
     }
-}
+}
\ No newline at end of file