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: Initialization.cpp
- Revision:
- 11:bc9cd2869f95
- Parent:
- 9:5a0c4c6e39c7
- Child:
- 12:2e3e86714243
diff -r e8db892fbc52 -r bc9cd2869f95 Initialization.cpp --- a/Initialization.cpp Wed Sep 24 22:54:36 2014 +0000 +++ b/Initialization.cpp Wed Oct 01 18:11:38 2014 +0000 @@ -2,6 +2,7 @@ #include "Motor.hpp" #include "VoltageDriver.hpp" #include "PinIN.hpp" +#include "TimerDevice.hpp" /**********************************************************************************************************************************/ @@ -12,7 +13,7 @@ // ADD YOUR DEVICE NAME THE \\EXACT SAME WAY\\ AS THE ENUM NAME YOU DECLARED IN THE.hpp // Must Declare names in reverse order for some reason...., it's the way they're indexed I believe -const string DeviceNames[] = {"MOTOR", "VOLTAGE_DRIVER", "PIN_IN"}; +const string DeviceNames[] = {"MOTOR", "VOLTAGE_DRIVER", "PIN_IN", "TIMER_DEVICE", "CAN_DEVICE"}; // ADD YOUR DEVICE TO THE LIST BELOW, CALLING YOUR DEVICE CLASS AS SHOWN Device* Device::newDevice(int deviceFound, string _name, LineData lineData){ @@ -21,6 +22,7 @@ case MOTOR: return new Motor(lineData); break; case VOLTAGE_DRIVER: return new VoltageDriver(lineData); break; case PIN_IN: return new PinIN(lineData); break; + case TIMER_DEVICE: return new TimerDevice(lineData); break; //********** ADD NEXT DEVICE ABOVE **************// default: break; @@ -46,8 +48,15 @@ DigitalIn killSw(KILL); +//Ticker errorWatcher; + const int MAX_LINE_LENGTH = 100; int DummyMode = 0; // run through the code without performing actions +FILE *selectedFile; +int errorFLAG = 0; + +vector<GoToLabel> GoToLabels; //Initialize vector of struct for GoTo Labels +CycleWatch cycleWatch; /******************************************************************************/ /*** <Function Initializations> ***/ @@ -57,6 +66,10 @@ killSw.mode(PullUp); initLCD(); + + //Initialize the Error Watcher Interrupt / Ticker + //errorWatcher.attach(&ErrorMonitor, 0.5); + } void initLCD(void) { @@ -87,4 +100,48 @@ int numDevices = sizeof(DeviceNames)/sizeof(DeviceNames[0]); int currNumDevices = 0; -vector<Device*> devices; //create a vector to hold all of the devices \ No newline at end of file +vector<Device*> devices; //create a vector to hold all of the devices + + +/******************************************************************************/ +/*** <Error Monitor Initializations> ***/ +/******************************************************************************/ + +//vector<ErrorCondition> errorMonitors; //Initialize vector of errors to monitor +//ErrorCondition errorMonitors[15]; +//int numErrorMonitors = 0; +/* +//Monitors the conditions to watch for erroring, and pauses system if any of the conditions turn out to be true +void ErrorMonitor(){ + + int i = 0, error = -1, numError = 0; + for(i = 0; i < errorMonitors.size(); i++){ + int checkCondition = 0; + checkCondition = interpretCommand(errorMonitors[i].errorToWatch); + + //if Condition is true, that means the error occurred + if (checkCondition == 1){ + numError++; + + //if the error has a Fix / Reset command, do it + if (errorMonitors[i].hasFix){ + int returnValue; + interpretCommand(errorMonitors[i].errorFix); //Fix / Reset the error based on how the user justified to do so + } + + error = i; //Record index of error, will display only one error, but error will be last error that was true in the list + } + } + + if (numError){ + char errorMsg[100] = "Error Occurred!!! 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 + } + else + errorFLAG = 0; //set error flag equal to 0 if no errors occurred + +} +*/ +