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/CompositeControl.cpp@221:2a5e9902003c, 2016-10-14 (annotated)
- Committer:
- jmarkel44
- Date:
- Fri Oct 14 21:30:21 2016 +0000
- Revision:
- 221:2a5e9902003c
- Parent:
- 220:dbe21411f962
- Child:
- 222:94ea9a091d99
composite control and composite algorithm implementation
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jmarkel44 | 164:7cecd731882e | 1 | /****************************************************************************** |
| jmarkel44 | 164:7cecd731882e | 2 | * |
| jmarkel44 | 164:7cecd731882e | 3 | * File: CompositeControl.cpp |
| jmarkel44 | 164:7cecd731882e | 4 | * Desciption: ICE Composite Control Class implementation |
| jmarkel44 | 164:7cecd731882e | 5 | * |
| jmarkel44 | 164:7cecd731882e | 6 | *****************************************************************************/ |
| jmarkel44 | 164:7cecd731882e | 7 | #include "CompositeControl.h" |
| jmarkel44 | 221:2a5e9902003c | 8 | #include "ConfigurationHandler.h" |
| jmarkel44 | 164:7cecd731882e | 9 | #include "mDot.h" |
| jmarkel44 | 164:7cecd731882e | 10 | #include "MbedJSONValue.h" |
| jmarkel44 | 164:7cecd731882e | 11 | #include "ModbusMasterApi.h" |
| jmarkel44 | 164:7cecd731882e | 12 | #include "global.h" |
| jmarkel44 | 164:7cecd731882e | 13 | #include <string> |
| jmarkel44 | 164:7cecd731882e | 14 | |
| jmarkel44 | 164:7cecd731882e | 15 | extern mDot *GLOBAL_mdot; |
| jmarkel44 | 164:7cecd731882e | 16 | |
| jmarkel44 | 221:2a5e9902003c | 17 | // |
| jmarkel44 | 221:2a5e9902003c | 18 | // method: load |
| jmarkel44 | 221:2a5e9902003c | 19 | // description: load a composite control |
| jmarkel44 | 221:2a5e9902003c | 20 | // |
| jmarkel44 | 221:2a5e9902003c | 21 | // @param none |
| jmarkel44 | 221:2a5e9902003c | 22 | // @return none |
| jmarkel44 | 221:2a5e9902003c | 23 | // |
| jmarkel44 | 220:dbe21411f962 | 24 | bool CompositeControl::load(std::string _controlFile) |
| jmarkel44 | 164:7cecd731882e | 25 | { |
| jmarkel44 | 220:dbe21411f962 | 26 | MbedJSONValue json_value; // JSON parsing element |
| jmarkel44 | 220:dbe21411f962 | 27 | controlFile = _controlFile; |
| jmarkel44 | 220:dbe21411f962 | 28 | |
| jmarkel44 | 221:2a5e9902003c | 29 | printf("\rDEBUG: attempting to load the composite control\n"); |
| jmarkel44 | 221:2a5e9902003c | 30 | Thread::wait(500); |
| jmarkel44 | 221:2a5e9902003c | 31 | |
| jmarkel44 | 220:dbe21411f962 | 32 | // open and read from the control file |
| jmarkel44 | 220:dbe21411f962 | 33 | mDot::mdot_file file = GLOBAL_mdot->openUserFile(controlFile.c_str(), mDot::FM_RDONLY); |
| jmarkel44 | 220:dbe21411f962 | 34 | if ( file.fd < 0 ) { |
| jmarkel44 | 220:dbe21411f962 | 35 | logError("%s: failed to open %s\n", __func__, controlFile.c_str()); |
| jmarkel44 | 220:dbe21411f962 | 36 | return false; |
| jmarkel44 | 220:dbe21411f962 | 37 | } |
| jmarkel44 | 220:dbe21411f962 | 38 | |
| jmarkel44 | 220:dbe21411f962 | 39 | // read the data into a buffer |
| jmarkel44 | 220:dbe21411f962 | 40 | char dataBuf[MAX_FILE_SIZE]; |
| jmarkel44 | 220:dbe21411f962 | 41 | |
| jmarkel44 | 220:dbe21411f962 | 42 | int bytes_read = GLOBAL_mdot->readUserFile(file, (void *)dataBuf, sizeof(dataBuf)); |
| jmarkel44 | 220:dbe21411f962 | 43 | if ( bytes_read != sizeof(dataBuf) ) { |
| jmarkel44 | 220:dbe21411f962 | 44 | logError("%s: failed to read %d bytes from %s", __func__, sizeof(dataBuf), controlFile.c_str()); |
| jmarkel44 | 220:dbe21411f962 | 45 | // caller should destroy the object |
| jmarkel44 | 220:dbe21411f962 | 46 | return false; |
| jmarkel44 | 220:dbe21411f962 | 47 | } |
| jmarkel44 | 220:dbe21411f962 | 48 | |
| jmarkel44 | 220:dbe21411f962 | 49 | // close the file |
| jmarkel44 | 220:dbe21411f962 | 50 | GLOBAL_mdot->closeUserFile(file); |
| jmarkel44 | 220:dbe21411f962 | 51 | |
| jmarkel44 | 220:dbe21411f962 | 52 | parse(json_value, dataBuf); |
| jmarkel44 | 220:dbe21411f962 | 53 | |
| jmarkel44 | 221:2a5e9902003c | 54 | if ( !json_value.hasMember("id") || |
| jmarkel44 | 221:2a5e9902003c | 55 | !json_value.hasMember("tag") || |
| jmarkel44 | 221:2a5e9902003c | 56 | !json_value.hasMember("priority") || |
| jmarkel44 | 221:2a5e9902003c | 57 | !json_value.hasMember("ca") || |
| jmarkel44 | 220:dbe21411f962 | 58 | !json_value.hasMember("entries") ) { |
| jmarkel44 | 220:dbe21411f962 | 59 | printf("\rComposite control is missing expected tags\n"); |
| jmarkel44 | 220:dbe21411f962 | 60 | return false; |
| jmarkel44 | 220:dbe21411f962 | 61 | } |
| jmarkel44 | 220:dbe21411f962 | 62 | |
| jmarkel44 | 221:2a5e9902003c | 63 | id = json_value ["id"].get<string>(); |
| jmarkel44 | 221:2a5e9902003c | 64 | tag = json_value ["tag"].get<string>(); |
| jmarkel44 | 220:dbe21411f962 | 65 | priority = atoi(json_value["priority"].get<string>().c_str()); |
| jmarkel44 | 221:2a5e9902003c | 66 | ca = json_value ["ca"].get<string>(); |
| jmarkel44 | 220:dbe21411f962 | 67 | |
| jmarkel44 | 220:dbe21411f962 | 68 | int entries = atoi(json_value["entries"].get<string>().c_str()); |
| jmarkel44 | 220:dbe21411f962 | 69 | |
| jmarkel44 | 220:dbe21411f962 | 70 | for ( int i = 0; i < entries; ++i ) { |
| jmarkel44 | 220:dbe21411f962 | 71 | std::string tag = json_value["outputs"][i]["tag"].get<string>(); |
| jmarkel44 | 221:2a5e9902003c | 72 | std::string response = json_value["outputs"][i]["responseA"].get<string>(); |
| jmarkel44 | 220:dbe21411f962 | 73 | if ( !tag.empty() && !response.empty() ) { |
| jmarkel44 | 220:dbe21411f962 | 74 | OutputElement x = { tag, response }; |
| jmarkel44 | 220:dbe21411f962 | 75 | outputs.push_back(x); |
| jmarkel44 | 220:dbe21411f962 | 76 | } else { |
| jmarkel44 | 220:dbe21411f962 | 77 | return false; |
| jmarkel44 | 220:dbe21411f962 | 78 | } |
| jmarkel44 | 220:dbe21411f962 | 79 | } |
| jmarkel44 | 220:dbe21411f962 | 80 | |
| jmarkel44 | 221:2a5e9902003c | 81 | printf("RETURN TRUE\n"); |
| jmarkel44 | 221:2a5e9902003c | 82 | |
| jmarkel44 | 164:7cecd731882e | 83 | return true; |
| jmarkel44 | 164:7cecd731882e | 84 | } |
| jmarkel44 | 164:7cecd731882e | 85 | |
| jmarkel44 | 221:2a5e9902003c | 86 | // |
| jmarkel44 | 221:2a5e9902003c | 87 | // method: start |
| jmarkel44 | 221:2a5e9902003c | 88 | // description: start the composite control |
| jmarkel44 | 221:2a5e9902003c | 89 | // |
| jmarkel44 | 221:2a5e9902003c | 90 | // @param none |
| jmarkel44 | 221:2a5e9902003c | 91 | // @return none |
| jmarkel44 | 221:2a5e9902003c | 92 | // |
| jmarkel44 | 221:2a5e9902003c | 93 | void CompositeControl::start(void) |
| jmarkel44 | 221:2a5e9902003c | 94 | { |
| jmarkel44 | 221:2a5e9902003c | 95 | currentState = STATE_START; |
| jmarkel44 | 221:2a5e9902003c | 96 | } |
| jmarkel44 | 221:2a5e9902003c | 97 | |
| jmarkel44 | 221:2a5e9902003c | 98 | // |
| jmarkel44 | 221:2a5e9902003c | 99 | // method: update |
| jmarkel44 | 221:2a5e9902003c | 100 | // description: updater for the composite control |
| jmarkel44 | 221:2a5e9902003c | 101 | // |
| jmarkel44 | 221:2a5e9902003c | 102 | // @param none |
| jmarkel44 | 221:2a5e9902003c | 103 | // @return none |
| jmarkel44 | 221:2a5e9902003c | 104 | // |
| jmarkel44 | 221:2a5e9902003c | 105 | void CompositeControl::update(void) |
| jmarkel44 | 164:7cecd731882e | 106 | { |
| jmarkel44 | 221:2a5e9902003c | 107 | std::string function; |
| jmarkel44 | 221:2a5e9902003c | 108 | |
| jmarkel44 | 221:2a5e9902003c | 109 | switch ( currentState ) { |
| jmarkel44 | 221:2a5e9902003c | 110 | case STATE_INIT: |
| jmarkel44 | 221:2a5e9902003c | 111 | // do nothing |
| jmarkel44 | 221:2a5e9902003c | 112 | break; |
| jmarkel44 | 221:2a5e9902003c | 113 | case STATE_START: |
| jmarkel44 | 221:2a5e9902003c | 114 | function = executeCommand(); |
| jmarkel44 | 221:2a5e9902003c | 115 | if ( function == "responseA" ) { |
| jmarkel44 | 221:2a5e9902003c | 116 | currentState = STATE_CONTROL_ON; |
| jmarkel44 | 221:2a5e9902003c | 117 | triggerOutputs(function); |
| jmarkel44 | 221:2a5e9902003c | 118 | } else if ( function == "nothing" ) { |
| jmarkel44 | 221:2a5e9902003c | 119 | currentState = STATE_CONTROL_OFF; |
| jmarkel44 | 221:2a5e9902003c | 120 | } |
| jmarkel44 | 221:2a5e9902003c | 121 | break; |
| jmarkel44 | 221:2a5e9902003c | 122 | case STATE_CONTROL_ON: |
| jmarkel44 | 221:2a5e9902003c | 123 | function = executeCommand(); |
| jmarkel44 | 221:2a5e9902003c | 124 | if ( function == "nothing" ) { |
| jmarkel44 | 221:2a5e9902003c | 125 | currentState = STATE_CONTROL_OFF; |
| jmarkel44 | 221:2a5e9902003c | 126 | unregisterControls(); |
| jmarkel44 | 221:2a5e9902003c | 127 | } else { |
| jmarkel44 | 221:2a5e9902003c | 128 | // do nothing |
| jmarkel44 | 221:2a5e9902003c | 129 | } |
| jmarkel44 | 221:2a5e9902003c | 130 | break; |
| jmarkel44 | 221:2a5e9902003c | 131 | case STATE_CONTROL_OFF: |
| jmarkel44 | 221:2a5e9902003c | 132 | function = executeCommand(); |
| jmarkel44 | 221:2a5e9902003c | 133 | if ( function == "responseA" ) { |
| jmarkel44 | 221:2a5e9902003c | 134 | currentState = STATE_CONTROL_ON; |
| jmarkel44 | 221:2a5e9902003c | 135 | triggerOutputs(function); |
| jmarkel44 | 221:2a5e9902003c | 136 | } else { |
| jmarkel44 | 221:2a5e9902003c | 137 | // do nothing |
| jmarkel44 | 221:2a5e9902003c | 138 | } |
| jmarkel44 | 221:2a5e9902003c | 139 | break; |
| jmarkel44 | 221:2a5e9902003c | 140 | default: |
| jmarkel44 | 221:2a5e9902003c | 141 | break; |
| jmarkel44 | 221:2a5e9902003c | 142 | } |
| jmarkel44 | 221:2a5e9902003c | 143 | } |
| jmarkel44 | 221:2a5e9902003c | 144 | |
| jmarkel44 | 221:2a5e9902003c | 145 | // |
| jmarkel44 | 221:2a5e9902003c | 146 | // method: executeCommand |
| jmarkel44 | 221:2a5e9902003c | 147 | // description: execute the command specified in the control algorithm |
| jmarkel44 | 221:2a5e9902003c | 148 | // |
| jmarkel44 | 221:2a5e9902003c | 149 | // @param none |
| jmarkel44 | 221:2a5e9902003c | 150 | // @return none |
| jmarkel44 | 221:2a5e9902003c | 151 | // |
| jmarkel44 | 221:2a5e9902003c | 152 | std::string CompositeControl::executeCommand(void) |
| jmarkel44 | 221:2a5e9902003c | 153 | { |
| jmarkel44 | 221:2a5e9902003c | 154 | // look up the algorithm |
| jmarkel44 | 221:2a5e9902003c | 155 | StringAlgorithmMap::iterator pos; |
| jmarkel44 | 221:2a5e9902003c | 156 | pos = algorithmTable.find(this->ca); |
| jmarkel44 | 221:2a5e9902003c | 157 | if ( pos != algorithmTable.end() ) { |
| jmarkel44 | 221:2a5e9902003c | 158 | // we found the control algorithm |
| jmarkel44 | 221:2a5e9902003c | 159 | return this->executeOperation(pos->second); |
| jmarkel44 | 221:2a5e9902003c | 160 | } |
| jmarkel44 | 221:2a5e9902003c | 161 | return "nothing"; |
| jmarkel44 | 220:dbe21411f962 | 162 | } |
| jmarkel44 | 220:dbe21411f962 | 163 | |
| jmarkel44 | 221:2a5e9902003c | 164 | // |
| jmarkel44 | 221:2a5e9902003c | 165 | // method: executeOperation |
| jmarkel44 | 221:2a5e9902003c | 166 | // description: execute an operations from the control equation |
| jmarkel44 | 221:2a5e9902003c | 167 | // |
| jmarkel44 | 221:2a5e9902003c | 168 | // @param ca -> composite control algorithm |
| jmarkel44 | 221:2a5e9902003c | 169 | // @return string to the result |
| jmarkel44 | 221:2a5e9902003c | 170 | // |
| jmarkel44 | 221:2a5e9902003c | 171 | std::string CompositeControl::executeOperation(const CompositeAlgorithm *ca) |
| jmarkel44 | 221:2a5e9902003c | 172 | { |
| jmarkel44 | 221:2a5e9902003c | 173 | // (this->tag) <op> <opr> = <result> |
| jmarkel44 | 221:2a5e9902003c | 174 | // |
| jmarkel44 | 221:2a5e9902003c | 175 | // example: |
| jmarkel44 | 221:2a5e9902003c | 176 | // this->tag = "i_flowswitch" |
| jmarkel44 | 221:2a5e9902003c | 177 | // opr = "1" |
| jmarkel44 | 221:2a5e9902003c | 178 | // op = "==" |
| jmarkel44 | 221:2a5e9902003c | 179 | // if true return "responseA" else return "nothing" |
| jmarkel44 | 221:2a5e9902003c | 180 | |
| jmarkel44 | 221:2a5e9902003c | 181 | ModbusValue value; |
| jmarkel44 | 221:2a5e9902003c | 182 | bool rc = ModbusMasterReadRegister(tag,&value); |
| jmarkel44 | 221:2a5e9902003c | 183 | if ( rc != true ) { |
| jmarkel44 | 221:2a5e9902003c | 184 | printf("\rDEBUG: %s cannot find tag\n", __func__); |
| jmarkel44 | 221:2a5e9902003c | 185 | return "nothing"; |
| jmarkel44 | 221:2a5e9902003c | 186 | } |
| jmarkel44 | 221:2a5e9902003c | 187 | |
| jmarkel44 | 221:2a5e9902003c | 188 | if ( ca->getOp() == "==" ) { |
| jmarkel44 | 221:2a5e9902003c | 189 | //printf("\rvalue = %f opr = %f\n", value.value, atof(ca->getOpr().c_str())); |
| jmarkel44 | 221:2a5e9902003c | 190 | if ( value.value == atof(ca->getOpr().c_str()) ) { |
| jmarkel44 | 221:2a5e9902003c | 191 | return ca->getResultTrue(); |
| jmarkel44 | 221:2a5e9902003c | 192 | } else { |
| jmarkel44 | 221:2a5e9902003c | 193 | return ca->getResultFalse(); |
| jmarkel44 | 221:2a5e9902003c | 194 | } |
| jmarkel44 | 221:2a5e9902003c | 195 | } |
| jmarkel44 | 221:2a5e9902003c | 196 | if ( ca->getOp() == "+" ) { |
| jmarkel44 | 221:2a5e9902003c | 197 | // do nothing |
| jmarkel44 | 221:2a5e9902003c | 198 | } |
| jmarkel44 | 221:2a5e9902003c | 199 | return "nothing"; |
| jmarkel44 | 221:2a5e9902003c | 200 | |
| jmarkel44 | 221:2a5e9902003c | 201 | } |
| jmarkel44 | 221:2a5e9902003c | 202 | |
| jmarkel44 | 221:2a5e9902003c | 203 | // |
| jmarkel44 | 221:2a5e9902003c | 204 | // method: triggerOutputs |
| jmarkel44 | 221:2a5e9902003c | 205 | // description: trigger the output(s) to do something |
| jmarkel44 | 221:2a5e9902003c | 206 | // |
| jmarkel44 | 221:2a5e9902003c | 207 | // @param result -> the result of the operation |
| jmarkel44 | 221:2a5e9902003c | 208 | // @return none |
| jmarkel44 | 221:2a5e9902003c | 209 | // |
| jmarkel44 | 221:2a5e9902003c | 210 | void CompositeControl::triggerOutputs(std::string result) |
| jmarkel44 | 221:2a5e9902003c | 211 | { |
| jmarkel44 | 221:2a5e9902003c | 212 | printf("\rTRIGGER THE OUTPUTS\n"); |
| jmarkel44 | 221:2a5e9902003c | 213 | |
| jmarkel44 | 221:2a5e9902003c | 214 | // loop through the list |
| jmarkel44 | 221:2a5e9902003c | 215 | StringAlgorithmMap::iterator pos; |
| jmarkel44 | 221:2a5e9902003c | 216 | pos = algorithmTable.find(this->ca); |
| jmarkel44 | 221:2a5e9902003c | 217 | if ( pos != algorithmTable.end() ) { |
| jmarkel44 | 221:2a5e9902003c | 218 | std::vector<OutputElement>::iterator it; |
| jmarkel44 | 221:2a5e9902003c | 219 | for ( it = outputs.begin(); it != outputs.end(); ++it ) { |
| jmarkel44 | 221:2a5e9902003c | 220 | if ( it->response == "fixed off" ) { |
| jmarkel44 | 221:2a5e9902003c | 221 | printf("\rSending an OFF control for %s\n", it->tag.c_str()); |
| jmarkel44 | 221:2a5e9902003c | 222 | sendMail(it->tag, ACTION_CONTROL_OFF); |
| jmarkel44 | 221:2a5e9902003c | 223 | } else if ( it->response == "fixed on" ) { |
| jmarkel44 | 221:2a5e9902003c | 224 | printf("\rSending an ON request for %s\n", it->tag.c_str()); |
| jmarkel44 | 221:2a5e9902003c | 225 | sendMail(it->tag, ACTION_CONTROL_ON); |
| jmarkel44 | 221:2a5e9902003c | 226 | } |
| jmarkel44 | 221:2a5e9902003c | 227 | } |
| jmarkel44 | 221:2a5e9902003c | 228 | } else { |
| jmarkel44 | 221:2a5e9902003c | 229 | logError("%s: failed to find the control algorithm %s\n", __func__, this->ca.c_str()); |
| jmarkel44 | 221:2a5e9902003c | 230 | } |
| jmarkel44 | 221:2a5e9902003c | 231 | } |
| jmarkel44 | 221:2a5e9902003c | 232 | |
| jmarkel44 | 221:2a5e9902003c | 233 | // |
| jmarkel44 | 221:2a5e9902003c | 234 | // method: sendMail |
| jmarkel44 | 221:2a5e9902003c | 235 | // description: send mail to the output task |
| jmarkel44 | 221:2a5e9902003c | 236 | // |
| jmarkel44 | 221:2a5e9902003c | 237 | // @param io_tag -> input/output tag |
| jmarkel44 | 221:2a5e9902003c | 238 | // @param action -> ON, OFF, UNREGISTER |
| jmarkel44 | 221:2a5e9902003c | 239 | // @return none |
| jmarkel44 | 221:2a5e9902003c | 240 | // |
| jmarkel44 | 221:2a5e9902003c | 241 | void CompositeControl::sendMail(const std::string io_tag, OutputAction action) |
| jmarkel44 | 221:2a5e9902003c | 242 | { |
| jmarkel44 | 221:2a5e9902003c | 243 | logInfo("%s: %s attempting to start feed on relay %s\n", |
| jmarkel44 | 221:2a5e9902003c | 244 | __func__, controlFile.c_str(), tag.c_str()); |
| jmarkel44 | 221:2a5e9902003c | 245 | |
| jmarkel44 | 221:2a5e9902003c | 246 | OutputControlMsg_t *output_mail = OutputMasterMailBox.alloc(); |
| jmarkel44 | 221:2a5e9902003c | 247 | memset(output_mail, 0, sizeof(OutputControlMsg_t)); |
| jmarkel44 | 221:2a5e9902003c | 248 | |
| jmarkel44 | 221:2a5e9902003c | 249 | output_mail->action = action; |
| jmarkel44 | 221:2a5e9902003c | 250 | output_mail->controlType = CONTROL_COMPOSITE; |
| jmarkel44 | 221:2a5e9902003c | 251 | strncpy(output_mail->input_tag, this->tag.c_str(), sizeof(output_mail->input_tag)-1); |
| jmarkel44 | 221:2a5e9902003c | 252 | strncpy(output_mail->output_tag, io_tag.c_str(), sizeof(output_mail->output_tag)-1); |
| jmarkel44 | 221:2a5e9902003c | 253 | output_mail->priority = this->priority; |
| jmarkel44 | 221:2a5e9902003c | 254 | strncpy(output_mail->id, this->id.c_str(), sizeof(output_mail->id)-1); |
| jmarkel44 | 221:2a5e9902003c | 255 | OutputMasterMailBox.put(output_mail); |
| jmarkel44 | 221:2a5e9902003c | 256 | } |
| jmarkel44 | 221:2a5e9902003c | 257 | |
| jmarkel44 | 221:2a5e9902003c | 258 | // |
| jmarkel44 | 221:2a5e9902003c | 259 | // method: unregisterControls |
| jmarkel44 | 221:2a5e9902003c | 260 | // description: unregister the control with the output task |
| jmarkel44 | 221:2a5e9902003c | 261 | // |
| jmarkel44 | 221:2a5e9902003c | 262 | // @param none |
| jmarkel44 | 221:2a5e9902003c | 263 | // @return none |
| jmarkel44 | 221:2a5e9902003c | 264 | // |
| jmarkel44 | 221:2a5e9902003c | 265 | void CompositeControl::unregisterControls(void) |
| jmarkel44 | 221:2a5e9902003c | 266 | { |
| jmarkel44 | 221:2a5e9902003c | 267 | // loop through the list |
| jmarkel44 | 221:2a5e9902003c | 268 | StringAlgorithmMap::iterator pos; |
| jmarkel44 | 221:2a5e9902003c | 269 | pos = algorithmTable.find(this->ca); |
| jmarkel44 | 221:2a5e9902003c | 270 | if ( pos != algorithmTable.end() ) { |
| jmarkel44 | 221:2a5e9902003c | 271 | std::vector<OutputElement>::iterator it; |
| jmarkel44 | 221:2a5e9902003c | 272 | for ( it = outputs.begin(); it != outputs.end(); ++it ) { |
| jmarkel44 | 221:2a5e9902003c | 273 | sendMail(it->tag, ACTION_CONTROL_UNREGISTER); |
| jmarkel44 | 221:2a5e9902003c | 274 | } |
| jmarkel44 | 221:2a5e9902003c | 275 | } else { |
| jmarkel44 | 221:2a5e9902003c | 276 | logError("%s: failed to find the control algorithm %s\n", __func__, this->ca.c_str()); |
| jmarkel44 | 221:2a5e9902003c | 277 | } |
| jmarkel44 | 221:2a5e9902003c | 278 | } |
| jmarkel44 | 221:2a5e9902003c | 279 | |
| jmarkel44 | 221:2a5e9902003c | 280 | // |
| jmarkel44 | 221:2a5e9902003c | 281 | // methid: display |
| jmarkel44 | 221:2a5e9902003c | 282 | // description: display the pertinents |
| jmarkel44 | 221:2a5e9902003c | 283 | // |
| jmarkel44 | 221:2a5e9902003c | 284 | // @param none |
| jmarkel44 | 221:2a5e9902003c | 285 | // @return none |
| jmarkel44 | 221:2a5e9902003c | 286 | // |
| jmarkel44 | 220:dbe21411f962 | 287 | void CompositeControl::display(void) |
| jmarkel44 | 220:dbe21411f962 | 288 | { |
| jmarkel44 | 221:2a5e9902003c | 289 | const char *mapper[] = { "INIT", |
| jmarkel44 | 221:2a5e9902003c | 290 | "START", |
| jmarkel44 | 221:2a5e9902003c | 291 | "CONTROL_OFF", |
| jmarkel44 | 221:2a5e9902003c | 292 | "CONTROL_ON" |
| jmarkel44 | 221:2a5e9902003c | 293 | }; |
| jmarkel44 | 221:2a5e9902003c | 294 | |
| jmarkel44 | 220:dbe21411f962 | 295 | printf("\r control file : %s\n", controlFile.c_str()); |
| jmarkel44 | 220:dbe21411f962 | 296 | printf("\r id : %s\n", id.c_str()); |
| jmarkel44 | 221:2a5e9902003c | 297 | printf("\r tag : %s\n", tag.c_str()); |
| jmarkel44 | 220:dbe21411f962 | 298 | printf("\r priority : %u\n", priority); |
| jmarkel44 | 220:dbe21411f962 | 299 | printf("\r ca : %s\n", ca.c_str()); |
| jmarkel44 | 221:2a5e9902003c | 300 | |
| jmarkel44 | 220:dbe21411f962 | 301 | vector<OutputElement>::iterator it; |
| jmarkel44 | 220:dbe21411f962 | 302 | printf("\r outputs :\n"); |
| jmarkel44 | 220:dbe21411f962 | 303 | for ( it = outputs.begin(); it != outputs.end(); ++it ) { |
| jmarkel44 | 220:dbe21411f962 | 304 | printf("\r tag-> %s\n", (*it).tag.c_str()); |
| jmarkel44 | 220:dbe21411f962 | 305 | printf("\r response-> %s\n", (*it).response.c_str()); |
| jmarkel44 | 220:dbe21411f962 | 306 | } |
| jmarkel44 | 221:2a5e9902003c | 307 | printf("\r current state : %s\n", mapper[currentState]); |
| jmarkel44 | 220:dbe21411f962 | 308 | printf("\r\n"); |
| jmarkel44 | 164:7cecd731882e | 309 | } |
