Erick / Mbed 2 deprecated ICE-F412

Dependencies:   mbed-rtos mbed

Revision:
0:61364762ee0e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ICE-Application/src/ConfigurationHandler/Controls/CompositeControl.h	Tue Jan 24 19:05:33 2017 +0000
@@ -0,0 +1,104 @@
+/******************************************************************************
+ *
+ * File:                CompositeControl.h
+ * Desciption:          ICE Composite Control Class
+ *
+ *****************************************************************************/
+#ifndef COMPOSITECONTROL_H
+#define COMPOSITECONTROL_H
+
+#include <string>
+#include <vector>
+#include <stdio.h>
+#include <stdlib.h>
+#include "global.h"
+#include "./Algorithms/CompositeAlgorithm.h"
+
+typedef enum {
+    COMPOSITE_CONTROL_OK,
+    COMPOSITE_CONTROL_UNK_STATE, 
+    COMPOSITE_CONTROL_ERROR,
+    COMPOSITE_CONTROL_DESTROY
+} CompositeControlError_t;
+
+//! Composite Control - used to implement a composite control
+class CompositeControl
+{
+private:
+    typedef struct oe_tag {
+        std::string     tag;
+        std::string     response;
+    } OutputElement;
+
+    std::string                 controlFile;    // the control file
+    std::string                 id;             // composite identifier
+    std::string                 tag;            // i/o tag to evaluate
+    unsigned int                priority;       // control priority
+    std::string                 ca;             // control algorithm
+    std::vector<OutputElement>  outputs;        // (virtual) output(s)
+
+    enum State {
+        STATE_INIT,
+        STATE_START,
+        STATE_CONTROL_OFF,
+        STATE_CONTROL_ON,
+        STATE_MAX
+    };
+    State                       currentState;   // current state
+        
+    bool        validateControlData(const char *buf);
+    void        copyControlData(const char *buf);
+
+    std::string executeCommand(void);
+    std::string executeOperation(const CompositeAlgorithm*);
+    void        triggerOutputs(std::string result);
+    void        sendMail(std::string io_tag, OutputAction action);
+
+public:
+    /// constructor
+    CompositeControl() { }
+    
+    /// destructor
+    ~CompositeControl() {
+        printf("\r%s invoked\n", __func__);
+    }
+
+    /// load a composite control from a JSON configuration file
+    bool load(std::string controlFile);
+
+    /// start a composite control instance
+    void start(void);
+
+    /// update a composite control instance 
+    CompositeControlError_t update(void);
+
+    /// unregister a composite control(s) instance 
+    void unregisterControls();
+
+    /// get the composite control's control filename 
+    std::string getControlFile(void) const {
+        return controlFile;
+    }
+    
+    /// get the composite control's identifier
+    std::string getId(void) const {
+        return id;
+    }
+
+    /// get the composite control's current state 
+    State getState(void) const {
+        return currentState;
+    }
+
+    /// get the composite control's tag 
+    std::string getTag(void) const {
+        return tag;
+    }
+    
+    /// get a list of a composite control's outputs
+    std::vector<std::string> getOutputs(void) const;
+
+    void display(void);
+};
+
+#endif