Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
217:d5a2ff093319
Parent:
212:289f63158d2b
Child:
223:1a03451c0870
--- a/src/OutputTask/OutputTask.cpp	Mon Oct 10 16:07:40 2016 +0000
+++ b/src/OutputTask/OutputTask.cpp	Tue Oct 11 12:24:28 2016 +0000
@@ -32,7 +32,7 @@
 //
 // outputMap["o_rly2"]-> Control<"SetpointControl_rly2",  800, ON >
 //
-// outputMap["o_rly3"]-> Control<"TimerControl_rly3",   500, ON>
+// outputMap["o_rly3"]-> Control<"TimerControl_rly3",     700, ON>
 //
 //
 // The Control Vector (per relay) is always sorted by priority, whereas
@@ -134,6 +134,9 @@
     ModbusValue output_value;
     memset(&ev, 0, sizeof(ev));
 
+    // if there's no control, that means the only control that was on
+    // the relay stack has been destroyed, so we'll send a NO CONTROL
+    // code.
     if ( !control ) {
         ev.eventReason = EVENT_REASON_NO_CONTROL;
         ModbusMasterReadRegister(output, &output_value);
@@ -199,7 +202,8 @@
  * Description:         send a message to the modbus master of who's in control
  *
  *
- * @param               args -> not used
+ * @param               id          -> control identifier
+ * @param               output_tag  -> the output to write
  * @return              none
  *****************************************************************************/
 static void writeOutputs(const std::string id, const std::string output_tag)
@@ -228,37 +232,10 @@
 }
 
 /*****************************************************************************
- * Function:            DisplayOutputs
- * Description:         Display a list of outputs and its controls
- *
- * @param               args -> not used
- * @return              none
- *****************************************************************************/
-void DisplayOutputs(void)
-{
-    StringOutputVector_t::iterator pos;
-    
-    for ( pos = outputMap.begin(); pos != outputMap.end(); ++pos ) {
-        if ( pos->second.empty() ) {
-            printf("\r  [%s]-> [no controls] \n", pos->first.c_str());
-        } else {
-            printf("\r  [%s]-> ", pos->first.c_str());
-            vector<Control>::iterator i;
-            for ( i = pos->second.begin(); i != pos->second.end(); ++i ) {
-                i->display();
-            }
-            printf("\n");
-        }
-    }
-    printf("\r\n");
-}
-
-
-/*****************************************************************************
  * Function:            createOutput
  * Description:
  *
- * @param               controlFile -> name of output file
+ * @param               outputFile -> name of output file
  * @return              none
  *****************************************************************************/
 static int createOutput(const char *outputFile)
@@ -290,10 +267,10 @@
 
 /*****************************************************************************
  * Function:            enableOutputReqHandler
- * Description:         handle a reques
+ * Description:         handle a request to enable an output
  *
- * @param               args -> not used
- * @return              none
+ * @param               msg -> the message request
+ * @return              -1 on error
  *****************************************************************************/
 static int enableOutputReqHandler(OutputControlMsg_t *msg)
 {
@@ -337,9 +314,9 @@
 
 /*****************************************************************************
  * Function:            disableOutputReqHandler
- * Description:
+ * Description:         handle a request to disable an output
  *
- * @param               args -> not used
+ * @param               msg -> the message request
  * @return              none
  *****************************************************************************/
 static int disableOutputReqHandler(OutputControlMsg_t *msg)
@@ -387,9 +364,9 @@
  * Function:            unregisterControl
  * Description:
  *
- * @param               id -> control identifier
- * @param               pri -> priority
- * @param               output -> output (e.g. "o_rly5)
+ * @param               id     -> control identifier
+ * @param               pri    -> priority
+ * @param               output -> output (e.g. "o_rly05")
  *
  * @return              0 on success; -1 on error
  *****************************************************************************/
@@ -426,9 +403,9 @@
 
 /*****************************************************************************
  * Function:            loadPersistentOutputs
- * Description:         pump up the output map based on persistent files
+ * Description:         build the output map
  *
- * @param               args -> not used
+ * @param               none
  * @return              none
  *****************************************************************************/
 static void loadPersistentOutputs(void)
@@ -441,17 +418,15 @@
     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) {
+        // load in all of the output files 
         if( strncmp( i->name, OUTPUT_STR, strlen(OUTPUT_STR)) == 0 ) {
-
-            logInfo("%s: FOUND OUTPUT FILE: %s", __func__, i->name);
-
             char scratchBuf[MAX_FILE_SIZE];
 
             status = GLOBAL_mdot->readUserFile(i->name, scratchBuf, MAX_FILE_SIZE);
             if( status != true ) {
-                logInfo("(%d)read file failed, status=%d", __LINE__, status);
+                logError("%s: failed to read %s", __func__, i->name);
             } else {
-                logInfo("(%d)Read File SUCCESS: %s", __LINE__, scratchBuf );
+                logInfo("%s: successfully read %s", __func__, i->name);
             }
 
             parse( json_value, scratchBuf );
@@ -470,3 +445,29 @@
         }
     }
 }
+
+/*****************************************************************************
+ * Function:            DisplayOutputs
+ * Description:         Display a list of outputs and their controls
+ *
+ * @param               none
+ * @return              none
+ *****************************************************************************/
+void DisplayOutputs(void)
+{
+    StringOutputVector_t::iterator pos;
+    
+    for ( pos = outputMap.begin(); pos != outputMap.end(); ++pos ) {
+        if ( pos->second.empty() ) {
+            printf("\r  [%s]-> [no controls] \n", pos->first.c_str());
+        } else {
+            printf("\r  [%s]-> ", pos->first.c_str());
+            vector<Control>::iterator i;
+            for ( i = pos->second.begin(); i != pos->second.end(); ++i ) {
+                i->display();
+            }
+            printf("\n");
+        }
+    }
+    printf("\r\n");
+}