Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed
Fork of ICE by
src/OutputTask/Control.h@192:052a419837fa, 2016-10-06 (annotated)
- Committer:
- jmarkel44
- Date:
- Thu Oct 06 15:36:26 2016 +0000
- Revision:
- 192:052a419837fa
- Parent:
- 185:5ac6ab1ed875
- Child:
- 212:289f63158d2b
inclusion of .hasMember
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jmarkel44 | 185:5ac6ab1ed875 | 1 | #ifndef CONTROL_H |
| jmarkel44 | 185:5ac6ab1ed875 | 2 | #define CONTROL_H |
| jmarkel44 | 185:5ac6ab1ed875 | 3 | |
| jmarkel44 | 185:5ac6ab1ed875 | 4 | #include "global.h" |
| jmarkel44 | 185:5ac6ab1ed875 | 5 | #include <string> |
| jmarkel44 | 192:052a419837fa | 6 | #include "OutputTask.h" |
| jmarkel44 | 185:5ac6ab1ed875 | 7 | |
| jmarkel44 | 185:5ac6ab1ed875 | 8 | |
| jmarkel44 | 185:5ac6ab1ed875 | 9 | /***************************************************************************** |
| jmarkel44 | 185:5ac6ab1ed875 | 10 | * Control class |
| jmarkel44 | 185:5ac6ab1ed875 | 11 | * Contains the most pertinent control information to stack onto the output |
| jmarkel44 | 185:5ac6ab1ed875 | 12 | * entry |
| jmarkel44 | 185:5ac6ab1ed875 | 13 | ****************************************************************************/ |
| jmarkel44 | 185:5ac6ab1ed875 | 14 | class Control |
| jmarkel44 | 185:5ac6ab1ed875 | 15 | { |
| jmarkel44 | 185:5ac6ab1ed875 | 16 | private: |
| jmarkel44 | 185:5ac6ab1ed875 | 17 | std::string id; // control identifier |
| jmarkel44 | 185:5ac6ab1ed875 | 18 | Control_t controlType; // control type |
| jmarkel44 | 185:5ac6ab1ed875 | 19 | std::string input; // input |
| jmarkel44 | 185:5ac6ab1ed875 | 20 | unsigned int priority; // control priority |
| jmarkel44 | 185:5ac6ab1ed875 | 21 | ControlState state; // state (ON or OFF) |
| jmarkel44 | 185:5ac6ab1ed875 | 22 | |
| jmarkel44 | 185:5ac6ab1ed875 | 23 | public: |
| jmarkel44 | 185:5ac6ab1ed875 | 24 | // ctor |
| jmarkel44 | 185:5ac6ab1ed875 | 25 | Control(std::string id, Control_t controlType, std::string input, unsigned int priority, ControlState state) : |
| jmarkel44 | 185:5ac6ab1ed875 | 26 | id(id), controlType(controlType), input(input), priority(priority), state(state) {} |
| jmarkel44 | 185:5ac6ab1ed875 | 27 | // dtor |
| jmarkel44 | 185:5ac6ab1ed875 | 28 | ~Control() {} |
| jmarkel44 | 185:5ac6ab1ed875 | 29 | |
| jmarkel44 | 185:5ac6ab1ed875 | 30 | // displays a control's pertinents |
| jmarkel44 | 185:5ac6ab1ed875 | 31 | void display() { |
| jmarkel44 | 185:5ac6ab1ed875 | 32 | printf("[%-24s | %3s | %u]", |
| jmarkel44 | 185:5ac6ab1ed875 | 33 | id.c_str(), (state == CONTROL_ON) ? "ON" : "OFF", priority); |
| jmarkel44 | 185:5ac6ab1ed875 | 34 | } |
| jmarkel44 | 185:5ac6ab1ed875 | 35 | |
| jmarkel44 | 185:5ac6ab1ed875 | 36 | std::string getId() const { |
| jmarkel44 | 185:5ac6ab1ed875 | 37 | return id; |
| jmarkel44 | 185:5ac6ab1ed875 | 38 | } |
| jmarkel44 | 185:5ac6ab1ed875 | 39 | |
| jmarkel44 | 185:5ac6ab1ed875 | 40 | Control_t getControlType(void) const { |
| jmarkel44 | 185:5ac6ab1ed875 | 41 | return controlType; |
| jmarkel44 | 185:5ac6ab1ed875 | 42 | } |
| jmarkel44 | 185:5ac6ab1ed875 | 43 | |
| jmarkel44 | 185:5ac6ab1ed875 | 44 | std::string getInput(void) const { |
| jmarkel44 | 185:5ac6ab1ed875 | 45 | return input; |
| jmarkel44 | 185:5ac6ab1ed875 | 46 | } |
| jmarkel44 | 185:5ac6ab1ed875 | 47 | |
| jmarkel44 | 185:5ac6ab1ed875 | 48 | unsigned int getPriority() const { |
| jmarkel44 | 185:5ac6ab1ed875 | 49 | return priority; |
| jmarkel44 | 185:5ac6ab1ed875 | 50 | } |
| jmarkel44 | 185:5ac6ab1ed875 | 51 | |
| jmarkel44 | 185:5ac6ab1ed875 | 52 | ControlState getState(void) const { |
| jmarkel44 | 185:5ac6ab1ed875 | 53 | return state; |
| jmarkel44 | 185:5ac6ab1ed875 | 54 | } |
| jmarkel44 | 185:5ac6ab1ed875 | 55 | |
| jmarkel44 | 192:052a419837fa | 56 | int getMappedState(void) const; |
| jmarkel44 | 185:5ac6ab1ed875 | 57 | |
| jmarkel44 | 185:5ac6ab1ed875 | 58 | void setState(ControlState _state) { |
| jmarkel44 | 185:5ac6ab1ed875 | 59 | state = _state; |
| jmarkel44 | 185:5ac6ab1ed875 | 60 | } |
| jmarkel44 | 185:5ac6ab1ed875 | 61 | }; |
| jmarkel44 | 185:5ac6ab1ed875 | 62 | |
| jmarkel44 | 185:5ac6ab1ed875 | 63 | #endif |
