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/SetpointControl.h@89:55ac65d7f206, 2016-09-20 (annotated)
- Committer:
- jmarkel44
- Date:
- Tue Sep 20 17:39:56 2016 +0000
- Revision:
- 89:55ac65d7f206
- Parent:
- 86:189c125d8878
- Child:
- 90:7d9731dec0da
setpoint control updates;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmarkel44 | 5:5e77a1db4d45 | 1 | /****************************************************************************** |
jmarkel44 | 5:5e77a1db4d45 | 2 | * |
jmarkel44 | 5:5e77a1db4d45 | 3 | * File: SetpointControl.h |
jmarkel44 | 5:5e77a1db4d45 | 4 | * Desciption: ICE Timer Control Class |
jmarkel44 | 5:5e77a1db4d45 | 5 | * |
jmarkel44 | 5:5e77a1db4d45 | 6 | *****************************************************************************/ |
jmarkel44 | 5:5e77a1db4d45 | 7 | #ifndef SETPOINTCONTROL_H |
jmarkel44 | 5:5e77a1db4d45 | 8 | #define SETPOINTCONTROL_H |
jmarkel44 | 5:5e77a1db4d45 | 9 | |
jmarkel44 | 28:c410a61238bb | 10 | #include "MbedJSONValue.h" |
jmarkel44 | 5:5e77a1db4d45 | 11 | #include <string> |
jmarkel44 | 46:4cb96ab2d1c8 | 12 | |
jmarkel44 | 13:c80c283f9db2 | 13 | using namespace std; |
jmarkel44 | 5:5e77a1db4d45 | 14 | |
jmarkel44 | 5:5e77a1db4d45 | 15 | class SetpointControl |
jmarkel44 | 5:5e77a1db4d45 | 16 | { |
jmarkel44 | 5:5e77a1db4d45 | 17 | private: |
jmarkel44 | 5:5e77a1db4d45 | 18 | string controlFile; // name of the control file |
jmarkel44 | 20:653923c2f37a | 19 | string id; // control identifier |
jmarkel44 | 28:c410a61238bb | 20 | int priority; // control priority |
jmarkel44 | 20:653923c2f37a | 21 | string input; // control input |
jmarkel44 | 28:c410a61238bb | 22 | string output; // control output |
jmarkel44 | 89:55ac65d7f206 | 23 | double setpoint; // setpoint value |
jmarkel44 | 30:738359dfdab1 | 24 | double productFactor; |
jmarkel44 | 30:738359dfdab1 | 25 | double highAlert; |
jmarkel44 | 30:738359dfdab1 | 26 | double lowAlert; |
jmarkel44 | 30:738359dfdab1 | 27 | double highFailsafe; |
jmarkel44 | 30:738359dfdab1 | 28 | double lowFailsafe; |
jmarkel44 | 51:66b820f203a5 | 29 | enum State { |
jmarkel44 | 51:66b820f203a5 | 30 | STATE_STARTUP, |
jmarkel44 | 51:66b820f203a5 | 31 | STATE_CONTROL_OFF, |
jmarkel44 | 51:66b820f203a5 | 32 | STATE_CONTROL_ON, |
jmarkel44 | 51:66b820f203a5 | 33 | STATE_DISABLE, |
jmarkel44 | 51:66b820f203a5 | 34 | STATE_PAUSE, |
jmarkel44 | 51:66b820f203a5 | 35 | STATE_MAX |
jmarkel44 | 51:66b820f203a5 | 36 | }; |
jmarkel44 | 51:66b820f203a5 | 37 | State currentState; |
jmarkel44 | 28:c410a61238bb | 38 | |
jmarkel44 | 5:5e77a1db4d45 | 39 | public: |
jmarkel44 | 51:66b820f203a5 | 40 | // ctor |
jmarkel44 | 19:9bc8fabeddfa | 41 | SetpointControl() {}; |
jmarkel44 | 51:66b820f203a5 | 42 | // dtor |
jmarkel44 | 12:ea87887ca7ad | 43 | ~SetpointControl() { |
jmarkel44 | 12:ea87887ca7ad | 44 | printf("\r%s destructor invoked\n", __func__); |
jmarkel44 | 86:189c125d8878 | 45 | // TODO: unregister the control with the output task |
jmarkel44 | 28:c410a61238bb | 46 | } |
jmarkel44 | 28:c410a61238bb | 47 | |
jmarkel44 | 86:189c125d8878 | 48 | // load the control data |
jmarkel44 | 28:c410a61238bb | 49 | bool load(string filename); |
jmarkel44 | 86:189c125d8878 | 50 | |
jmarkel44 | 86:189c125d8878 | 51 | // register the control with the output task |
jmarkel44 | 51:66b820f203a5 | 52 | void registerControl(void); |
jmarkel44 | 86:189c125d8878 | 53 | |
jmarkel44 | 51:66b820f203a5 | 54 | // unregister the control with the output task |
jmarkel44 | 86:189c125d8878 | 55 | void unregisterControl(void); |
jmarkel44 | 86:189c125d8878 | 56 | |
jmarkel44 | 86:189c125d8878 | 57 | // start the control |
jmarkel44 | 51:66b820f203a5 | 58 | void start(void); |
jmarkel44 | 86:189c125d8878 | 59 | |
jmarkel44 | 51:66b820f203a5 | 60 | // update the control |
jmarkel44 | 86:189c125d8878 | 61 | void update(void); |
jmarkel44 | 86:189c125d8878 | 62 | |
jmarkel44 | 51:66b820f203a5 | 63 | bool underLimit(); |
jmarkel44 | 51:66b820f203a5 | 64 | bool overLimit(); |
jmarkel44 | 86:189c125d8878 | 65 | |
jmarkel44 | 86:189c125d8878 | 66 | // state transition functions |
jmarkel44 | 51:66b820f203a5 | 67 | void startFeed(); |
jmarkel44 | 51:66b820f203a5 | 68 | void stopFeed(); |
jmarkel44 | 28:c410a61238bb | 69 | |
jmarkel44 | 86:189c125d8878 | 70 | string getControlFile(void) const { |
jmarkel44 | 12:ea87887ca7ad | 71 | return controlFile; |
jmarkel44 | 12:ea87887ca7ad | 72 | } |
jmarkel44 | 86:189c125d8878 | 73 | string getId(void) const { |
jmarkel44 | 28:c410a61238bb | 74 | return id; |
jmarkel44 | 28:c410a61238bb | 75 | } |
jmarkel44 | 86:189c125d8878 | 76 | unsigned int getPriority(void) const { |
jmarkel44 | 28:c410a61238bb | 77 | return priority; |
jmarkel44 | 28:c410a61238bb | 78 | } |
jmarkel44 | 86:189c125d8878 | 79 | string getInput(void) const { |
jmarkel44 | 28:c410a61238bb | 80 | return input; |
jmarkel44 | 28:c410a61238bb | 81 | } |
jmarkel44 | 86:189c125d8878 | 82 | string getOutput(void) const { |
jmarkel44 | 28:c410a61238bb | 83 | return output; |
jmarkel44 | 28:c410a61238bb | 84 | } |
jmarkel44 | 86:189c125d8878 | 85 | float getProductFactor(void) const { |
jmarkel44 | 28:c410a61238bb | 86 | return productFactor; |
jmarkel44 | 28:c410a61238bb | 87 | } |
jmarkel44 | 86:189c125d8878 | 88 | float getSetpoint(void) const { |
jmarkel44 | 86:189c125d8878 | 89 | return setpoint; |
jmarkel44 | 86:189c125d8878 | 90 | } |
jmarkel44 | 86:189c125d8878 | 91 | float getHighAlert(void) const { |
jmarkel44 | 28:c410a61238bb | 92 | return highAlert; |
jmarkel44 | 28:c410a61238bb | 93 | } |
jmarkel44 | 86:189c125d8878 | 94 | float getLowAlert(void) const { |
jmarkel44 | 28:c410a61238bb | 95 | return lowAlert; |
jmarkel44 | 28:c410a61238bb | 96 | } |
jmarkel44 | 86:189c125d8878 | 97 | float getHighFailsafe(void) const { |
jmarkel44 | 28:c410a61238bb | 98 | return highFailsafe; |
jmarkel44 | 28:c410a61238bb | 99 | } |
jmarkel44 | 86:189c125d8878 | 100 | float getLowFailsafe(void) const { |
jmarkel44 | 28:c410a61238bb | 101 | return lowFailsafe; |
jmarkel44 | 28:c410a61238bb | 102 | } |
jmarkel44 | 89:55ac65d7f206 | 103 | |
jmarkel44 | 86:189c125d8878 | 104 | State getCurrentState(void) const { |
jmarkel44 | 51:66b820f203a5 | 105 | return currentState; |
jmarkel44 | 51:66b820f203a5 | 106 | } |
jmarkel44 | 5:5e77a1db4d45 | 107 | }; |
jmarkel44 | 5:5e77a1db4d45 | 108 | |
jmarkel44 | 51:66b820f203a5 | 109 | #endif |