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