3rd year group project. Electronic and Electrical Engineering. Heriot-Watt University. This is the code for the mbed for the Automatic Little Object Organiser (ALOO).

Dependencies:   MCP23017 TCS3472_I2C WattBob_TextLCD mbed

Committer:
dreamselec
Date:
Sat Nov 28 23:28:22 2015 +0000
Revision:
23:db91aaa43a9e
Parent:
20:4e0f0944f28f
Child:
25:792540d69c49
Added break beam test mode, also values and status of tests are now synced with PC.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dreamselec 6:98fe30430194 1 //
dreamselec 6:98fe30430194 2 // commander.cpp
dreamselec 6:98fe30430194 3 // Created by Chandan Siyag on 14/11/2015.
dreamselec 6:98fe30430194 4 #include <iostream>
lordlycastle 5:6ef2d954fca3 5 #include <string>
dreamselec 2:7a55cb10259f 6 #include "commander.h"
dreamselec 2:7a55cb10259f 7
dreamselec 6:98fe30430194 8 using namespace std;
dreamselec 15:777390eb5afd 9 #define _DEBUG_
dreamselec 6:98fe30430194 10
dreamselec 9:dc8f155b71c8 11 //const int kCommandBufferSize = 40;
dreamselec 13:4f24da6e2f8e 12 const int kCommandValueBufferSize = 80;
dreamselec 8:e1da2ae62885 13 const int kObjectBufferSize = 20;
dreamselec 8:e1da2ae62885 14
dreamselec 23:db91aaa43a9e 15 string CommandObjectValue [6] = { "mbed", "pc", "colour_sensor", "servos", "port", "break_beam" };
dreamselec 23:db91aaa43a9e 16 string CommandObjectCommandsValue [6][kMaxCommandCount] = {
dreamselec 23:db91aaa43a9e 17 {"mbed", "haz-block", "read-current-block", "mode", "sort", "", "", "", "", ""},
dreamselec 23:db91aaa43a9e 18 {"pc", "connect", "disconnect", "", "", "", "", "", "reply-commands", "exit"},
dreamselec 23:db91aaa43a9e 19 {"colour_sensor", "i-time", "preview", "", "", "", "", "", "", ""},
dreamselec 23:db91aaa43a9e 20 {"servos", "test", "reset", "stop-test", "", "", "", "", "", ""},
dreamselec 23:db91aaa43a9e 21 {"port", "init", "b-rate", "parity", "", "", "", "", "", ""},
dreamselec 23:db91aaa43a9e 22 {"break_beam", "test", "", "", "", "", "", "", "", ""},
dreamselec 13:4f24da6e2f8e 23 };
dreamselec 8:e1da2ae62885 24
dreamselec 15:777390eb5afd 25 Commander::Commander()
dreamselec 15:777390eb5afd 26 {
dreamselec 23:db91aaa43a9e 27 replyCommands = false;
dreamselec 23:db91aaa43a9e 28 this->resetVariables();
dreamselec 6:98fe30430194 29 }
dreamselec 6:98fe30430194 30
dreamselec 15:777390eb5afd 31 Commander::~Commander()
dreamselec 15:777390eb5afd 32 {
dreamselec 12:f485796016f8 33
dreamselec 2:7a55cb10259f 34 }
dreamselec 2:7a55cb10259f 35
dreamselec 15:777390eb5afd 36 void Commander::decodeCommand(CommandTypeRaw type)
dreamselec 15:777390eb5afd 37 {
dreamselec 23:db91aaa43a9e 38 this->resetVariables();
dreamselec 23:db91aaa43a9e 39 this->typeRaw = type;
dreamselec 23:db91aaa43a9e 40 this->typeChar = CommandTypeValue[type];
dreamselec 14:cf2f255b5560 41
dreamselec 23:db91aaa43a9e 42 this->readCommandObject();
dreamselec 23:db91aaa43a9e 43 if (this->objectRaw == InvalidObject) {
dreamselec 23:db91aaa43a9e 44 pc.printf("DEBUG:Invalid command object.\n");
dreamselec 23:db91aaa43a9e 45 return;
dreamselec 23:db91aaa43a9e 46 }
dreamselec 6:98fe30430194 47
dreamselec 23:db91aaa43a9e 48 if (this->readCommand(this->objectRaw) == false) {
dreamselec 23:db91aaa43a9e 49 // this->description();
dreamselec 23:db91aaa43a9e 50 pc.printf("DEBUG:Invalid command.\n");
dreamselec 23:db91aaa43a9e 51 return;
dreamselec 23:db91aaa43a9e 52 } else if (connectedToPC == true || (this->typeRaw == Set && this->objectRaw == PC && this->commandIndex[0] == 1)) {
dreamselec 23:db91aaa43a9e 53 this->executeCommand();
dreamselec 23:db91aaa43a9e 54 if (this->replyCommands == true) {
dreamselec 23:db91aaa43a9e 55 pc.printf("VALUE:%s:VALUE\n", this->description().c_str());
dreamselec 23:db91aaa43a9e 56 }
dreamselec 23:db91aaa43a9e 57 //TODO: Send request with response descriptor.
dreamselec 23:db91aaa43a9e 58 // pc.("DEBUG:Finished executine command");
dreamselec 23:db91aaa43a9e 59 return;
dreamselec 23:db91aaa43a9e 60 }
dreamselec 16:4a41cb9e525f 61
dreamselec 23:db91aaa43a9e 62 pc.printf("INFO:Not connected to PC. %i\n", this->commandIndex[0]);
dreamselec 23:db91aaa43a9e 63 return;
dreamselec 8:e1da2ae62885 64 }
dreamselec 8:e1da2ae62885 65
dreamselec 15:777390eb5afd 66 std::string Commander::description()
dreamselec 15:777390eb5afd 67 {
dreamselec 23:db91aaa43a9e 68 string str;
dreamselec 23:db91aaa43a9e 69 str.append("Command type:\t");
dreamselec 23:db91aaa43a9e 70 str.append(&this->typeChar);
dreamselec 23:db91aaa43a9e 71 str.append("\nCommand object:\t" + this->object);
dreamselec 8:e1da2ae62885 72
dreamselec 23:db91aaa43a9e 73 for (int i = 0; i < sizeof(this->command)/sizeof(*this->command); i++) {
dreamselec 23:db91aaa43a9e 74 if (this->command[i] == "") {
dreamselec 23:db91aaa43a9e 75 break;
dreamselec 23:db91aaa43a9e 76 }
dreamselec 23:db91aaa43a9e 77 str.append("\nCommand:\t" + this->command[i] + "\nValue:\t" + this->commandValue[i].c_str() + " \n");
dreamselec 23:db91aaa43a9e 78 }
dreamselec 23:db91aaa43a9e 79 return str;
dreamselec 15:777390eb5afd 80 }
dreamselec 15:777390eb5afd 81
dreamselec 15:777390eb5afd 82 void Commander::readCommandObject()
dreamselec 15:777390eb5afd 83 {
dreamselec 23:db91aaa43a9e 84 char objectInitiator = '<';
dreamselec 23:db91aaa43a9e 85 char objectTerminator = '>';
dreamselec 15:777390eb5afd 86
dreamselec 23:db91aaa43a9e 87 char nextChar = '\0';
dreamselec 13:4f24da6e2f8e 88
dreamselec 23:db91aaa43a9e 89 do {
dreamselec 23:db91aaa43a9e 90 nextChar = pc.getc();
dreamselec 23:db91aaa43a9e 91 } while (nextChar != objectInitiator);
dreamselec 13:4f24da6e2f8e 92
dreamselec 23:db91aaa43a9e 93 char objectCharArray [kObjectBufferSize] = "";
dreamselec 23:db91aaa43a9e 94 int i = 0;
dreamselec 23:db91aaa43a9e 95 while (i < kObjectBufferSize) {
dreamselec 23:db91aaa43a9e 96 nextChar = pc.getc();
dreamselec 23:db91aaa43a9e 97 if (nextChar == '\n' || nextChar == '\r' || nextChar == ' ') {
dreamselec 23:db91aaa43a9e 98 continue;
dreamselec 23:db91aaa43a9e 99 }
dreamselec 23:db91aaa43a9e 100 if (nextChar == objectTerminator)
dreamselec 23:db91aaa43a9e 101 break;
dreamselec 23:db91aaa43a9e 102 objectCharArray[i] = nextChar;
dreamselec 23:db91aaa43a9e 103 i++;
dreamselec 23:db91aaa43a9e 104 }
dreamselec 23:db91aaa43a9e 105 string tempStr(objectCharArray);
dreamselec 23:db91aaa43a9e 106 this->object = tempStr;
dreamselec 8:e1da2ae62885 107
dreamselec 23:db91aaa43a9e 108 for (int i = 0; i < (sizeof(CommandObjectValue)/sizeof(*CommandObjectValue)); i++) {
dreamselec 23:db91aaa43a9e 109 if (CommandObjectValue[i] == this->object) {
dreamselec 23:db91aaa43a9e 110 this->objectRaw = static_cast<CommandObjectRaw>(i);
dreamselec 23:db91aaa43a9e 111 return;
dreamselec 23:db91aaa43a9e 112 }
dreamselec 23:db91aaa43a9e 113 }
dreamselec 8:e1da2ae62885 114
dreamselec 23:db91aaa43a9e 115 this->objectRaw = InvalidObject;
dreamselec 23:db91aaa43a9e 116 return;
dreamselec 13:4f24da6e2f8e 117 }
dreamselec 2:7a55cb10259f 118
dreamselec 15:777390eb5afd 119 bool Commander::readCommand(CommandObjectRaw objectRaw)
dreamselec 15:777390eb5afd 120 {
dreamselec 23:db91aaa43a9e 121 char nextChar = '\0';
dreamselec 23:db91aaa43a9e 122 char commandCharArray [kMaxCommandCount - 1][kCommandValueBufferSize] = { '\0' };
dreamselec 23:db91aaa43a9e 123 char commandValueArray [kMaxCommandCount -1][kCommandValueBufferSize] = { '\0' };
dreamselec 15:777390eb5afd 124
dreamselec 23:db91aaa43a9e 125 int charIndex = 0;
dreamselec 23:db91aaa43a9e 126 int valueCharIndex = 0;
dreamselec 23:db91aaa43a9e 127 int commandValueIndex = 0;
dreamselec 23:db91aaa43a9e 128 bool commandComplete = false;
dreamselec 23:db91aaa43a9e 129 while (charIndex < kCommandValueBufferSize - 1 && valueCharIndex < kCommandValueBufferSize - 1) {
dreamselec 23:db91aaa43a9e 130 nextChar = pc.getc();
dreamselec 16:4a41cb9e525f 131
dreamselec 23:db91aaa43a9e 132 if (nextChar == '\n' || nextChar == '\r' || nextChar == ' ') {
dreamselec 23:db91aaa43a9e 133 continue;
dreamselec 23:db91aaa43a9e 134 } else if (nextChar == kCommandTerminator) {
dreamselec 23:db91aaa43a9e 135 break;
dreamselec 23:db91aaa43a9e 136 } else if (nextChar == '=') {
dreamselec 23:db91aaa43a9e 137 commandComplete = true;
dreamselec 23:db91aaa43a9e 138 } else if (nextChar == ',') {
dreamselec 23:db91aaa43a9e 139 commandComplete = false;
dreamselec 23:db91aaa43a9e 140 commandValueIndex++;
dreamselec 23:db91aaa43a9e 141 charIndex = 0;
dreamselec 23:db91aaa43a9e 142 valueCharIndex = 0;
dreamselec 23:db91aaa43a9e 143 }
dreamselec 15:777390eb5afd 144
dreamselec 23:db91aaa43a9e 145 if (commandComplete == false && nextChar != ',') {
dreamselec 23:db91aaa43a9e 146 commandCharArray[commandValueIndex][charIndex] = nextChar;
dreamselec 23:db91aaa43a9e 147 charIndex++;
dreamselec 23:db91aaa43a9e 148 } else if (commandComplete == true && nextChar != '=') {
dreamselec 23:db91aaa43a9e 149 commandValueArray[commandValueIndex][valueCharIndex] = nextChar;
dreamselec 23:db91aaa43a9e 150 valueCharIndex++;
dreamselec 23:db91aaa43a9e 151 }
dreamselec 23:db91aaa43a9e 152 }
dreamselec 15:777390eb5afd 153
dreamselec 23:db91aaa43a9e 154 for (int i = 0; i < kMaxCommandCount - 1; i++) {
dreamselec 23:db91aaa43a9e 155 // pc.printf("i: %i\n", i);
dreamselec 23:db91aaa43a9e 156 if (commandCharArray[i][0] == '\0') {
dreamselec 23:db91aaa43a9e 157 break;
dreamselec 23:db91aaa43a9e 158 }
dreamselec 23:db91aaa43a9e 159 string tempCommandStr(commandCharArray[i]);
dreamselec 23:db91aaa43a9e 160 string tempValueStr(commandValueArray[i]);
dreamselec 23:db91aaa43a9e 161 // pc.printf("%s\n", tempCommandStr.c_str());
dreamselec 23:db91aaa43a9e 162 int row = this->objectRaw;
dreamselec 23:db91aaa43a9e 163 // pc.printf("Row: %i\n", this->objectRaw);
dreamselec 23:db91aaa43a9e 164 int column = 1;
dreamselec 23:db91aaa43a9e 165 // pc.printf("Column: %i\n", column);
dreamselec 23:db91aaa43a9e 166 for (; column < kMaxCommandCount - 1; column++) {
dreamselec 23:db91aaa43a9e 167 // pc.printf("%i\n", column);
dreamselec 23:db91aaa43a9e 168 if (CommandObjectCommandsValue[row][column] == tempCommandStr) {
dreamselec 23:db91aaa43a9e 169 // pc.printf("Found matching command.\n");
dreamselec 23:db91aaa43a9e 170 this->command[i] = tempCommandStr;
dreamselec 23:db91aaa43a9e 171 // pc.printf("%s\n", this->command[i].c_str());
dreamselec 23:db91aaa43a9e 172 this->commandIndex[i] = column;
dreamselec 23:db91aaa43a9e 173 // pc.printf("%i\n", this->commandIndex[i]);
dreamselec 23:db91aaa43a9e 174 this->commandValue[i] = tempValueStr;
dreamselec 23:db91aaa43a9e 175 // pc.printf("%s\n", this->commandValue[i].c_str());
dreamselec 23:db91aaa43a9e 176 // pc.printf("%s\n", this->description().c_str());
dreamselec 23:db91aaa43a9e 177 break;
dreamselec 23:db91aaa43a9e 178 }
dreamselec 23:db91aaa43a9e 179 }
dreamselec 23:db91aaa43a9e 180 if (this->commandIndex[i] == -1) {
dreamselec 23:db91aaa43a9e 181 // pc.printf("index = -1\n");
dreamselec 23:db91aaa43a9e 182 return false;
dreamselec 23:db91aaa43a9e 183 }
dreamselec 23:db91aaa43a9e 184 }
dreamselec 16:4a41cb9e525f 185
dreamselec 23:db91aaa43a9e 186 // pc.printf("Returning\n");
dreamselec 23:db91aaa43a9e 187 return true;
dreamselec 15:777390eb5afd 188 }
dreamselec 14:cf2f255b5560 189
dreamselec 15:777390eb5afd 190 void Commander::executeCommand()
dreamselec 15:777390eb5afd 191 {
dreamselec 23:db91aaa43a9e 192 switch (this->objectRaw) {
dreamselec 23:db91aaa43a9e 193 case MBED:
dreamselec 23:db91aaa43a9e 194 for (int i = 0; i < sizeof(this->command)/sizeof(*this->command); i++) {
dreamselec 23:db91aaa43a9e 195 if (this->commandIndex[i] == -1 || this->commandIndex[i] == 0) {
dreamselec 23:db91aaa43a9e 196 break;
dreamselec 23:db91aaa43a9e 197 }
dreamselec 23:db91aaa43a9e 198 if (this->commandIndex[i] == 1) {
dreamselec 23:db91aaa43a9e 199 hazBlock(this->typeRaw);
dreamselec 23:db91aaa43a9e 200 } else if (this->commandIndex[i] == 2) {
dreamselec 23:db91aaa43a9e 201 getCurrentBlock(this->typeRaw);
dreamselec 23:db91aaa43a9e 202 } else if (this->commandIndex[i] == 3) {
dreamselec 23:db91aaa43a9e 203 if (this->commandValue[i] == "maintanence") {
dreamselec 23:db91aaa43a9e 204 currentMode = Maintanence;
dreamselec 23:db91aaa43a9e 205 pc.printf("INFO:Running in maintanence mode.\n");
dreamselec 23:db91aaa43a9e 206 } else if (this->commandValue[i] == "normal") {
dreamselec 23:db91aaa43a9e 207 currentMode = Normal;
dreamselec 23:db91aaa43a9e 208 pc.printf("INFO:Running in nomal mode.\n");
dreamselec 23:db91aaa43a9e 209 } else if (this->commandValue[i] == "none") {
dreamselec 23:db91aaa43a9e 210 currentMode = None;
dreamselec 23:db91aaa43a9e 211 pc.printf("INOF:Running in none mode");
dreamselec 23:db91aaa43a9e 212 }
dreamselec 23:db91aaa43a9e 213 } else if (this->commandIndex[i] == 4 && currentMode == Normal) {
dreamselec 23:db91aaa43a9e 214 if (this->commandValue[i] == "start") {
dreamselec 23:db91aaa43a9e 215 currentState = Start;
dreamselec 23:db91aaa43a9e 216 pc.printf("INFO:Starting sorting.\n");
dreamselec 23:db91aaa43a9e 217 } else if (this->commandValue[i] == "pause") {
dreamselec 23:db91aaa43a9e 218 currentState = Pause;
dreamselec 23:db91aaa43a9e 219 pc.printf("INFO:Pausing sorting.\n");
dreamselec 23:db91aaa43a9e 220 }
dreamselec 23:db91aaa43a9e 221 }
dreamselec 23:db91aaa43a9e 222 }
dreamselec 23:db91aaa43a9e 223 break;
dreamselec 23:db91aaa43a9e 224 case PC:
dreamselec 23:db91aaa43a9e 225 for (int i = 0; i < sizeof(this->command)/sizeof(*this->command); i++) {
dreamselec 23:db91aaa43a9e 226 if (this->commandIndex[i] == -1 || this->commandIndex[i] == 0) {
dreamselec 23:db91aaa43a9e 227 break;
dreamselec 23:db91aaa43a9e 228 }
dreamselec 23:db91aaa43a9e 229 if (this->commandIndex[i] == 1) {
dreamselec 23:db91aaa43a9e 230 connectToPC(this->typeRaw);
dreamselec 23:db91aaa43a9e 231 } else if (this->commandIndex[i] == 2) {
dreamselec 23:db91aaa43a9e 232 disconnectToPC(this->typeRaw);
dreamselec 23:db91aaa43a9e 233 } else if (this->commandIndex[i] == 8) {
dreamselec 23:db91aaa43a9e 234 if (this->commandValue[i] == "ON") {
dreamselec 23:db91aaa43a9e 235 this->replyCommands = true;
dreamselec 23:db91aaa43a9e 236 } else if (this->commandValue[i] == "OFF") {
dreamselec 23:db91aaa43a9e 237 this->replyCommands = false;
dreamselec 23:db91aaa43a9e 238 }
dreamselec 23:db91aaa43a9e 239 }
dreamselec 23:db91aaa43a9e 240 }
dreamselec 23:db91aaa43a9e 241 break;
dreamselec 23:db91aaa43a9e 242 case ColourSensor:
dreamselec 23:db91aaa43a9e 243 for (int i = 0; i < sizeof(this->command)/sizeof(*this->command); i++) {
dreamselec 23:db91aaa43a9e 244 if (this->commandIndex[i] == -1 || this->commandIndex[i] == 0) {
dreamselec 23:db91aaa43a9e 245 break;
dreamselec 23:db91aaa43a9e 246 }
dreamselec 23:db91aaa43a9e 247 if (this->commandIndex[i] == 1) {
dreamselec 23:db91aaa43a9e 248 float integrationTime;
dreamselec 23:db91aaa43a9e 249 sscanf(this->commandValue[i].c_str(), "%f", &integrationTime);
dreamselec 23:db91aaa43a9e 250 if (integrationTime < 2.4 || integrationTime > 600) {
dreamselec 23:db91aaa43a9e 251 pc.printf("ERROR:Integration Time invalid: %.3f\n", integrationTime);
dreamselec 23:db91aaa43a9e 252 continue;
dreamselec 23:db91aaa43a9e 253 }
dreamselec 23:db91aaa43a9e 254 setIntegrationTimeTo(integrationTime);
dreamselec 23:db91aaa43a9e 255 } else if (this->commandIndex[i] == 2) {
dreamselec 23:db91aaa43a9e 256 if (this->commandValue[i] == "ON") {
dreamselec 23:db91aaa43a9e 257 previewOnPC(true);
dreamselec 23:db91aaa43a9e 258 } else if (this->commandValue[i] == "OFF") {
dreamselec 23:db91aaa43a9e 259 previewOnPC(false);
dreamselec 23:db91aaa43a9e 260 }
dreamselec 23:db91aaa43a9e 261 } else if (this->commandIndex[i] == 3) {
dreamselec 23:db91aaa43a9e 262 readColourSensor();
dreamselec 23:db91aaa43a9e 263 }
dreamselec 23:db91aaa43a9e 264 }
dreamselec 23:db91aaa43a9e 265 break;
dreamselec 23:db91aaa43a9e 266 case Servos:
dreamselec 23:db91aaa43a9e 267 for (int i = 0; i < sizeof(this->command)/sizeof(*this->command); i++) {
dreamselec 23:db91aaa43a9e 268 if (this->commandIndex[i] == -1 || this->commandIndex[i] == 0) {
dreamselec 23:db91aaa43a9e 269 break;
dreamselec 23:db91aaa43a9e 270 }
dreamselec 23:db91aaa43a9e 271 if (this->commandIndex[i] == 1) {
dreamselec 23:db91aaa43a9e 272 if (this->commandValue[i] == "start") {
dreamselec 23:db91aaa43a9e 273 testServos(Start);
dreamselec 23:db91aaa43a9e 274 } else if (this->commandValue[i] == "pause") {
dreamselec 23:db91aaa43a9e 275 testServos(Pause);
dreamselec 23:db91aaa43a9e 276 }
dreamselec 23:db91aaa43a9e 277 } else if (this->commandIndex[i] == 2) {
dreamselec 23:db91aaa43a9e 278 resetServos();
dreamselec 23:db91aaa43a9e 279 } else if (this->commandIndex[i] == 3) {
dreamselec 17:af373246bf80 280
dreamselec 23:db91aaa43a9e 281 }
dreamselec 23:db91aaa43a9e 282 }
dreamselec 23:db91aaa43a9e 283 break;
dreamselec 23:db91aaa43a9e 284 case Port:
dreamselec 23:db91aaa43a9e 285 for (int i = 0; i < sizeof(this->command)/sizeof(*this->command); i++) {
dreamselec 23:db91aaa43a9e 286 if (this->commandIndex[i] == -1 || this->commandIndex[i] == 0) {
dreamselec 23:db91aaa43a9e 287 break;
dreamselec 23:db91aaa43a9e 288 }
dreamselec 23:db91aaa43a9e 289 if (this->commandIndex[i] == 1) {
dreamselec 23:db91aaa43a9e 290 getPortInfo();
dreamselec 23:db91aaa43a9e 291 } else if (this->commandIndex[i] == 2) {
dreamselec 23:db91aaa43a9e 292 int baudRate;
dreamselec 23:db91aaa43a9e 293 sscanf(this->commandValue[i].c_str(), "%i", &baudRate);
dreamselec 23:db91aaa43a9e 294 setPortBaudRate(baudRate);
dreamselec 23:db91aaa43a9e 295 } else if (this->commandIndex[i] == 3) {
dreamselec 23:db91aaa43a9e 296 int parity = 0;
dreamselec 23:db91aaa43a9e 297 sscanf(this->commandValue[i].c_str(), "%i", &parity);
dreamselec 23:db91aaa43a9e 298 setPortParity(parity);
dreamselec 23:db91aaa43a9e 299 }
dreamselec 23:db91aaa43a9e 300 }
dreamselec 23:db91aaa43a9e 301 break;
dreamselec 23:db91aaa43a9e 302 case BreakBeam:
dreamselec 23:db91aaa43a9e 303 for (int i = 0; i < sizeof(this->command)/sizeof(*this->command); i++) {
dreamselec 23:db91aaa43a9e 304 if (this->commandIndex[i] == -1 || this->commandIndex[i] == 0) {
dreamselec 23:db91aaa43a9e 305 break;
dreamselec 23:db91aaa43a9e 306 }
dreamselec 23:db91aaa43a9e 307 if (this->commandIndex[i] == 1) {
dreamselec 23:db91aaa43a9e 308 if (this->commandValue[i] == "start"){
dreamselec 23:db91aaa43a9e 309 testBreakBeams(Start);
dreamselec 23:db91aaa43a9e 310 }else if (this->commandValue[i] == "pause"){
dreamselec 23:db91aaa43a9e 311 testBreakBeams(Pause);
dreamselec 23:db91aaa43a9e 312 }
dreamselec 23:db91aaa43a9e 313 }
dreamselec 23:db91aaa43a9e 314 }
dreamselec 23:db91aaa43a9e 315 default:
dreamselec 23:db91aaa43a9e 316 break;
dreamselec 23:db91aaa43a9e 317 }
dreamselec 23:db91aaa43a9e 318 return;
dreamselec 15:777390eb5afd 319 }
dreamselec 8:e1da2ae62885 320
dreamselec 13:4f24da6e2f8e 321
dreamselec 15:777390eb5afd 322 void Commander::resetVariables()
dreamselec 15:777390eb5afd 323 {
dreamselec 23:db91aaa43a9e 324 this->object = "";
dreamselec 23:db91aaa43a9e 325 this->objectRaw = InvalidObject;
dreamselec 23:db91aaa43a9e 326 for (int i = 0; i < sizeof(this->command)/sizeof(*this->command); i ++) {
dreamselec 23:db91aaa43a9e 327 this->command[i].clear();
dreamselec 23:db91aaa43a9e 328 this->commandValue[i].clear();
dreamselec 23:db91aaa43a9e 329 this->commandIndex[i] = -1;
dreamselec 23:db91aaa43a9e 330 }
dreamselec 23:db91aaa43a9e 331 this->typeRaw = InvalidType;
dreamselec 23:db91aaa43a9e 332 this->typeChar = '\0';
dreamselec 15:777390eb5afd 333 }