Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
111:d31b3a347e6a
Parent:
46:4cb96ab2d1c8
--- a/src/ConfigurationHandler/Controls/TimerControl.cpp	Thu Sep 22 15:16:55 2016 +0000
+++ b/src/ConfigurationHandler/Controls/TimerControl.cpp	Thu Sep 22 16:12:12 2016 +0000
@@ -11,14 +11,21 @@
 
 extern mDot *GLOBAL_mdot;
 
+//
+// method:      load
+// description: load the pertienent data from the timer json file to this object
+//
+// @param       controlFile -> the timer control file
+// @return      true on success; false on failure
+
 bool TimerControl::load(string _controlFile)
-{   
-    MbedJSONValue json_value;           // json parsing element 
-    controlFile = _controlFile;    
- 
+{
+    MbedJSONValue json_value;           // json parsing element
+    controlFile = _controlFile;
+
     // try to open the control file
     mDot::mdot_file file = GLOBAL_mdot->openUserFile(controlFile.c_str(), mDot::FM_RDONLY);
-    if ( file.fd < 0 ) 
+    if ( file.fd < 0 )
         return false;
 
     // read the data into a buffer
@@ -29,38 +36,73 @@
         logError("%s: failed to read %d bytes from %s", __func__, sizeof(dataBuf), controlFile.c_str());
         return false;
     }
-    
-    // close the file 
+
+    // close the file
     GLOBAL_mdot->closeUserFile(file);
 
     parse(json_value, dataBuf);
 
-    // {
-    //  "tcontrol": {
-    //      "id": "Timer1",
-    //      "name": "Acid Cleaning Cycle",
-    //      "priority":"800",
-    //      "dow":"127",
-    //      "strtw":"1",
-    //      "output":"o_r4",
-    //      "freq":"1",
-    //      "tod": {
-    //          "start":"420",
-    //          "int":"1"
-    //  }
-    // } 
-    
-    // parse the json data 
-    id           = json_value["id"].get<string>();
-    name         = json_value["name"].get<string>();
-    priority     = atoi(json_value["priority"].get<string>().c_str());
-    dayOfWeek    = atoi(json_value["dow"].get<string>().c_str());
-    startWeek    = atoi(json_value["strtw"].get<string>().c_str());
-    output       = json_value["output"].get<string>().c_str();
-    freq         = atoi(json_value["freq"].get<string>().c_str());
-    
-    // TODO extract
-    tod.start = 0; tod.interval = 0;
-    
+    id          = json_value["id"].get<string>();
+    priority    = atoi(json_value["priority"].get<string>().c_str());
+    dayOfWeek   = atoi(json_value["dow"].get<string>().c_str());
+    startWeek   = atoi(json_value["startw"].get<string>().c_str());
+    output      = atoi(json_value["output"].get<string>().c_str());
+    startTime   = atoi(json_value["starttime"].get<string>().c_str());
+    duration    = atoi(json_value["duration"].get<string>().c_str());
+
     return true;
+}
+
+//
+// method:      start
+// description: start a timer control
+//
+// @param       none
+// @return      none
+int TimerControl::start(void)
+{
+    return 0;
+}
+
+//
+// method:      update
+// description: update a timer control
+//
+// @param       none
+// @return      none
+int TimerControl::update(void)
+{
+    return 0;
+}
+
+//
+// method:      unregisterControl
+// description: unregister a control with the output task
+//
+// @param       none
+// @return      none
+int TimerControl::unregisterControl(void)
+{
+    return 0;
+}
+
+//
+// method:      display
+// description: display the data
+//
+// @param       none
+// @return      none
+//
+void TimerControl::display(void)
+{
+    printf("\r      controlFile : %s   \n", controlFile.c_str());
+    printf("\r               id : %s   \n", id.c_str());
+    printf("\r         priority : %d   \n", priority);
+    printf("\r        dayOfWeek : %u   \n", dayOfWeek);
+    printf("\r        startWeek : %u   \n", startWeek);
+    printf("\r           output : %s   \n", output.c_str());
+    printf("\r        startTime : %u   \n", startTime);
+    printf("\r         duration : %u   \n", duration);
+
+    printf("\r\n");
 }
\ No newline at end of file