Erick / Mbed 2 deprecated ICE-F412

Dependencies:   mbed-rtos mbed

Committer:
jmarkel44
Date:
Tue Jan 24 19:05:33 2017 +0000
Revision:
0:61364762ee0e
Port from IAR to Nucleo-F412 board

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jmarkel44 0:61364762ee0e 1 /******************************************************************************
jmarkel44 0:61364762ee0e 2 *
jmarkel44 0:61364762ee0e 3 * File: Control.h
jmarkel44 0:61364762ee0e 4 * Desciption: interface file for the ICE Output Task Control
jmarkel44 0:61364762ee0e 5 *
jmarkel44 0:61364762ee0e 6 * Controls are sorted by priority on the output
jmarkel44 0:61364762ee0e 7 * vector. The highest priority control manipulates
jmarkel44 0:61364762ee0e 8 * the output via Modbus writes.
jmarkel44 0:61364762ee0e 9 *
jmarkel44 0:61364762ee0e 10 *****************************************************************************/
jmarkel44 0:61364762ee0e 11 #ifndef CONTROL_H
jmarkel44 0:61364762ee0e 12 #define CONTROL_H
jmarkel44 0:61364762ee0e 13
jmarkel44 0:61364762ee0e 14 #include <stdio.h>
jmarkel44 0:61364762ee0e 15 #include <string>
jmarkel44 0:61364762ee0e 16
jmarkel44 0:61364762ee0e 17 #include "OutputTask.h"
jmarkel44 0:61364762ee0e 18 #include "global.h"
jmarkel44 0:61364762ee0e 19
jmarkel44 0:61364762ee0e 20
jmarkel44 0:61364762ee0e 21 //! Control - implements a control (for use with the Output thread)
jmarkel44 0:61364762ee0e 22 class Control
jmarkel44 0:61364762ee0e 23 {
jmarkel44 0:61364762ee0e 24 private:
jmarkel44 0:61364762ee0e 25 std::string id; // control identifier
jmarkel44 0:61364762ee0e 26 Control_t controlType; // control type
jmarkel44 0:61364762ee0e 27 std::string input; // input
jmarkel44 0:61364762ee0e 28 unsigned int priority; // control priority
jmarkel44 0:61364762ee0e 29 ControlState state; // state (ON or OFF)
jmarkel44 0:61364762ee0e 30
jmarkel44 0:61364762ee0e 31 public:
jmarkel44 0:61364762ee0e 32 /// creates a control instance
jmarkel44 0:61364762ee0e 33 Control(std::string id,
jmarkel44 0:61364762ee0e 34 Control_t controlType,
jmarkel44 0:61364762ee0e 35 std::string input,
jmarkel44 0:61364762ee0e 36 unsigned int priority,
jmarkel44 0:61364762ee0e 37 ControlState state) :
jmarkel44 0:61364762ee0e 38 id(id), controlType(controlType), input(input), priority(priority), state(state) {}
jmarkel44 0:61364762ee0e 39 /// destroys a control instance
jmarkel44 0:61364762ee0e 40 ~Control() {
jmarkel44 0:61364762ee0e 41 //printf("\r%s invoked\n", __func__);
jmarkel44 0:61364762ee0e 42 }
jmarkel44 0:61364762ee0e 43
jmarkel44 0:61364762ee0e 44 /// display the pertinent data of a Control instance
jmarkel44 0:61364762ee0e 45 void display() {
jmarkel44 0:61364762ee0e 46 printf("[%-24s | %3s | %u] -> ",
jmarkel44 0:61364762ee0e 47 id.c_str(), (state == CONTROL_ON) ? "ON" : "OFF", priority);
jmarkel44 0:61364762ee0e 48 }
jmarkel44 0:61364762ee0e 49
jmarkel44 0:61364762ee0e 50 std::string getId() const {
jmarkel44 0:61364762ee0e 51 return id;
jmarkel44 0:61364762ee0e 52 }
jmarkel44 0:61364762ee0e 53
jmarkel44 0:61364762ee0e 54 Control_t getControlType(void) const {
jmarkel44 0:61364762ee0e 55 return controlType;
jmarkel44 0:61364762ee0e 56 }
jmarkel44 0:61364762ee0e 57
jmarkel44 0:61364762ee0e 58 std::string getInput(void) const {
jmarkel44 0:61364762ee0e 59 return input;
jmarkel44 0:61364762ee0e 60 }
jmarkel44 0:61364762ee0e 61
jmarkel44 0:61364762ee0e 62 unsigned int getPriority() const {
jmarkel44 0:61364762ee0e 63 return priority;
jmarkel44 0:61364762ee0e 64 }
jmarkel44 0:61364762ee0e 65
jmarkel44 0:61364762ee0e 66 ControlState getState(void) const {
jmarkel44 0:61364762ee0e 67 return state;
jmarkel44 0:61364762ee0e 68 }
jmarkel44 0:61364762ee0e 69
jmarkel44 0:61364762ee0e 70 int getMappedState(void) const;
jmarkel44 0:61364762ee0e 71
jmarkel44 0:61364762ee0e 72 void setState(ControlState _state) {
jmarkel44 0:61364762ee0e 73 state = _state;
jmarkel44 0:61364762ee0e 74 }
jmarkel44 0:61364762ee0e 75 };
jmarkel44 0:61364762ee0e 76
jmarkel44 0:61364762ee0e 77 #endif