Component Test's Software to work with "Universal Controller Box" - Software is an interpreter or "compiler" for programs to be done with a .txt file and read off of the SD Card
Dependencies: BridgeDriver FrontPanelButtons MCP23017 SDFileSystem TextLCD mbed
Diff: main.cpp
- Revision:
- 13:899db9d635e5
- Parent:
- 12:2e3e86714243
- Child:
- 14:953820302fb7
diff -r 2e3e86714243 -r 899db9d635e5 main.cpp --- a/main.cpp Wed Oct 01 19:31:02 2014 +0000 +++ b/main.cpp Wed Oct 01 23:08:39 2014 +0000 @@ -607,6 +607,7 @@ /**********************************************************************************************************************************/ int interprettingErrorFlag = 0; +int enableErrors = 0; class ErrorCondition{ @@ -622,9 +623,9 @@ int interpretCommand(LineData &lineData){ - + //Monitors the conditions to watch for erroring, and pauses system if any of the conditions turn out to be true - if (!interprettingErrorFlag){ + if (!interprettingErrorFlag && enableErrors){ int j = 0, error = -1, numError = 0; for(j = 0; j < numErrorsConditions; j++){ int checkCondition = 0; @@ -639,9 +640,8 @@ //if the error has a Fix / Reset command, do it if (errorMonitors[j].hasFix){ - int returnValue; interprettingErrorFlag = 1; - returnValue = interpretCommand(errorMonitors[j].errorFix); //Fix / Reset the error based on how the user justified to do so + int returnValue = interpretCommand(errorMonitors[j].errorFix); //Fix / Reset the error based on how the user justified to do so interprettingErrorFlag = 0; if (returnValue == -1) return -1; @@ -658,7 +658,6 @@ char errorMsg[100] = "errorWatch! Item: "; strcat(errorMsg, errorMonitors[error].errorToWatch.word[0].c_str()); //Send the first word of the error condition to help find out what the error was ErrorOut(errorMsg, numError); - //errorFLAG = 1; //set error flag equal to 1 if error occurred //place all devices into the pause functionality int i = 0; @@ -724,7 +723,7 @@ else if (lineData.word[0].compare("errorWatch") == 0){ //line looks like: error, _Condition_, FIX(?), _Command_ //create a temp LineData variable to store the correct information of the error Condition (discluding the first "error" keyword - ErrorCondition tempError; + ErrorCondition tempError = ErrorCondition(); LineData tempLine; int i = 1, funcNumWords = 0; @@ -753,7 +752,7 @@ } //if the error has a fix, it means that it already process the "Error to Watch" but needs to process the "Error Fix" into the error condition - if (tempError.hasFix){ + if (tempError.hasFix == 1){ //Save the line as the "Error Fix" value tempLine.numWords = funcNumWords; tempLine.lineAddress = lineData.lineAddress; @@ -773,7 +772,12 @@ //if DummyMode, send error Condition to the interpretCommand so that we can check the syntax if (DummyMode){ int returnValue1 = interpretCommand(tempError.errorToWatch); - int returnValue2 = interpretCommand(tempError.errorFix); + + //if this error has a fix then check the syntax + int returnValue2 = 0; + if (tempError.hasFix) + returnValue2 = interpretCommand(tempError.errorFix); + if (returnValue1 == -1 || returnValue2 == -1) return -1; } @@ -916,23 +920,26 @@ /*** <Functionality: loop> ***/ /******************************************************************************/ - else if (lineData.word[0].compare("loop") == 0) + else if (lineData.word[0].compare("loop") == 0){ + enableErrors = 1; return loopCommand(lineData); //Process the loop command and return the value that it returns - + } /******************************************************************************/ /*** <Functionality: condition> ***/ /******************************************************************************/ - else if (lineData.word[0].compare("condition") == 0) + else if (lineData.word[0].compare("condition") == 0){ + enableErrors = 1; return conditionCommand(selectedFile, lineData); //Process the condition command and return the value that it returns - + } /******************************************************************************/ /*** <Functionality: cycle> ***/ /******************************************************************************/ - else if (lineData.word[0].compare("cycle") == 0) + else if (lineData.word[0].compare("cycle") == 0){ + enableErrors = 1; return cycleCommand(lineData, 1); //Sending 1 means it's initializing - + } /******************************************************************************/ /*** <Functionality: end> ***/ @@ -963,13 +970,8 @@ //not a keyword so check if it's a localName for a device else{ - -// lcd.setAddress(0,1); -// lcd.printf("wrd1: %s", lineData.word[0]); -// wait(1); - int i = 0, deviceFound = -1; - for (i = 0; i < devices.size(); i++){ + for (i = 0; i < devices.size(); i++){ if (lineData.word[0].compare(devices[i]->name) == 0) deviceFound = i; } @@ -978,9 +980,7 @@ if (deviceFound == -1){ ErrorOut("No device match found in the system", lineData.lineNumber); //Spaces make it look nice on LCD return -1; - } - - + } //Local Name matches a device, send line to that device in order to process the functionality else