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/ConfigurationHandler/Controls/ManualControl.h@217:d5a2ff093319, 2016-10-11 (annotated)
- Committer:
- jmarkel44
- Date:
- Tue Oct 11 12:24:28 2016 +0000
- Revision:
- 217:d5a2ff093319
- Parent:
- 164:7cecd731882e
- Child:
- 262:696cd48bb04a
more general cleanup;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jmarkel44 | 96:807f04bd5256 | 1 | /****************************************************************************** |
| jmarkel44 | 96:807f04bd5256 | 2 | * |
| jmarkel44 | 96:807f04bd5256 | 3 | * File: ManualControl.h |
| jmarkel44 | 96:807f04bd5256 | 4 | * Desciption: ICE Manual Control Class |
| jmarkel44 | 96:807f04bd5256 | 5 | * |
| jmarkel44 | 96:807f04bd5256 | 6 | *****************************************************************************/ |
| jmarkel44 | 96:807f04bd5256 | 7 | #ifndef MANUALCONTROL_H |
| jmarkel44 | 96:807f04bd5256 | 8 | #define MANUALCONTROL_H |
| jmarkel44 | 96:807f04bd5256 | 9 | |
| jmarkel44 | 96:807f04bd5256 | 10 | #include <string> |
| jmarkel44 | 96:807f04bd5256 | 11 | |
| jmarkel44 | 96:807f04bd5256 | 12 | using namespace std; |
| jmarkel44 | 96:807f04bd5256 | 13 | |
| jmarkel44 | 96:807f04bd5256 | 14 | class ManualControl |
| jmarkel44 | 96:807f04bd5256 | 15 | { |
| jmarkel44 | 96:807f04bd5256 | 16 | private: |
| jmarkel44 | 96:807f04bd5256 | 17 | string controlFile; // name of the control file |
| jmarkel44 | 96:807f04bd5256 | 18 | string id; // identifier |
| jmarkel44 | 97:5cf6ab71dcd0 | 19 | string output; // output |
| jmarkel44 | 96:807f04bd5256 | 20 | unsigned int type; // timed, continuous, setpoint |
| jmarkel44 | 96:807f04bd5256 | 21 | unsigned int priority; // control priority |
| jmarkel44 | 217:d5a2ff093319 | 22 | unsigned int duration; // in seconds (not implemented) |
| jmarkel44 | 217:d5a2ff093319 | 23 | float setpoint; // setpoint (not implemented) |
| jmarkel44 | 97:5cf6ab71dcd0 | 24 | unsigned int state; // ON or OFF |
| jmarkel44 | 96:807f04bd5256 | 25 | unsigned int percent; // analog/manual value |
| jmarkel44 | 96:807f04bd5256 | 26 | |
| jmarkel44 | 97:5cf6ab71dcd0 | 27 | enum State { |
| jmarkel44 | 217:d5a2ff093319 | 28 | STATE_INIT, // init |
| jmarkel44 | 217:d5a2ff093319 | 29 | STATE_STARTUP, // control has been started |
| jmarkel44 | 217:d5a2ff093319 | 30 | STATE_CONTROL_ON, // control is ON |
| jmarkel44 | 217:d5a2ff093319 | 31 | STATE_CONTROL_OFF // control is OFF |
| jmarkel44 | 97:5cf6ab71dcd0 | 32 | }; |
| jmarkel44 | 97:5cf6ab71dcd0 | 33 | State currentState; |
| jmarkel44 | 97:5cf6ab71dcd0 | 34 | |
| jmarkel44 | 96:807f04bd5256 | 35 | public: |
| jmarkel44 | 217:d5a2ff093319 | 36 | // ctor |
| jmarkel44 | 96:807f04bd5256 | 37 | ManualControl() {}; |
| jmarkel44 | 217:d5a2ff093319 | 38 | // dtor |
| jmarkel44 | 96:807f04bd5256 | 39 | ~ManualControl() { |
| jmarkel44 | 96:807f04bd5256 | 40 | printf("\r%s destructor invoked\n", __func__); |
| jmarkel44 | 96:807f04bd5256 | 41 | } |
| jmarkel44 | 96:807f04bd5256 | 42 | // load a control from the control file |
| jmarkel44 | 96:807f04bd5256 | 43 | bool load(string filename); |
| jmarkel44 | 217:d5a2ff093319 | 44 | |
| jmarkel44 | 217:d5a2ff093319 | 45 | // start a control |
| jmarkel44 | 217:d5a2ff093319 | 46 | void start(void); |
| jmarkel44 | 217:d5a2ff093319 | 47 | |
| jmarkel44 | 217:d5a2ff093319 | 48 | // update a control (this is called periodically) |
| jmarkel44 | 217:d5a2ff093319 | 49 | int update(void); |
| jmarkel44 | 217:d5a2ff093319 | 50 | |
| jmarkel44 | 217:d5a2ff093319 | 51 | // power an output |
| jmarkel44 | 217:d5a2ff093319 | 52 | int powerOutput(void); |
| jmarkel44 | 217:d5a2ff093319 | 53 | |
| jmarkel44 | 217:d5a2ff093319 | 54 | // unregister a control |
| jmarkel44 | 217:d5a2ff093319 | 55 | int unregisterControl(void); |
| jmarkel44 | 217:d5a2ff093319 | 56 | |
| jmarkel44 | 217:d5a2ff093319 | 57 | // display the control |
| jmarkel44 | 217:d5a2ff093319 | 58 | void display(void); |
| jmarkel44 | 217:d5a2ff093319 | 59 | |
| jmarkel44 | 96:807f04bd5256 | 60 | string getControlFile(void) const { |
| jmarkel44 | 96:807f04bd5256 | 61 | return controlFile; |
| jmarkel44 | 96:807f04bd5256 | 62 | } |
| jmarkel44 | 96:807f04bd5256 | 63 | |
| jmarkel44 | 217:d5a2ff093319 | 64 | string getId(void) const { |
| jmarkel44 | 217:d5a2ff093319 | 65 | return id; |
| jmarkel44 | 217:d5a2ff093319 | 66 | } |
| jmarkel44 | 217:d5a2ff093319 | 67 | |
| jmarkel44 | 217:d5a2ff093319 | 68 | string getOutput(void) const { |
| jmarkel44 | 217:d5a2ff093319 | 69 | return output; |
| jmarkel44 | 217:d5a2ff093319 | 70 | } |
| jmarkel44 | 217:d5a2ff093319 | 71 | |
| jmarkel44 | 217:d5a2ff093319 | 72 | unsigned int getType(void) const { |
| jmarkel44 | 217:d5a2ff093319 | 73 | return type; |
| jmarkel44 | 217:d5a2ff093319 | 74 | } |
| jmarkel44 | 217:d5a2ff093319 | 75 | |
| jmarkel44 | 217:d5a2ff093319 | 76 | unsigned int getPriority(void) const { |
| jmarkel44 | 217:d5a2ff093319 | 77 | return priority; |
| jmarkel44 | 217:d5a2ff093319 | 78 | } |
| jmarkel44 | 217:d5a2ff093319 | 79 | |
| jmarkel44 | 217:d5a2ff093319 | 80 | unsigned int getDuration(void) const { |
| jmarkel44 | 217:d5a2ff093319 | 81 | return duration; |
| jmarkel44 | 217:d5a2ff093319 | 82 | } |
| jmarkel44 | 217:d5a2ff093319 | 83 | |
| jmarkel44 | 217:d5a2ff093319 | 84 | float getSetpoint(void) const { |
| jmarkel44 | 217:d5a2ff093319 | 85 | return setpoint; |
| jmarkel44 | 217:d5a2ff093319 | 86 | } |
| jmarkel44 | 217:d5a2ff093319 | 87 | |
| jmarkel44 | 217:d5a2ff093319 | 88 | unsigned int getState(void) const { |
| jmarkel44 | 217:d5a2ff093319 | 89 | return state; |
| jmarkel44 | 217:d5a2ff093319 | 90 | } |
| jmarkel44 | 217:d5a2ff093319 | 91 | |
| jmarkel44 | 217:d5a2ff093319 | 92 | unsigned int getPercent(void) const { |
| jmarkel44 | 217:d5a2ff093319 | 93 | return percent; |
| jmarkel44 | 217:d5a2ff093319 | 94 | } |
| jmarkel44 | 96:807f04bd5256 | 95 | }; |
| jmarkel44 | 96:807f04bd5256 | 96 | |
| jmarkel44 | 96:807f04bd5256 | 97 | #endif |
