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:
- 14:953820302fb7
- Parent:
- 13:899db9d635e5
- Child:
- 15:c944ee3c8a5b
--- a/main.cpp Wed Oct 01 23:08:39 2014 +0000
+++ b/main.cpp Thu Oct 02 23:49:44 2014 +0000
@@ -15,6 +15,8 @@
using std::string;
FrontPanelButtons buttons(&i2c);
+Timer cycleTimer;
+CycleWatch cycleWatch;
//extern "C" void mbed_reset(); //enable software reset of code
@@ -337,8 +339,6 @@
/**********************************************************************************************************************************/
/**********************************************************************************************************************************/
-Timer cycleTimer;
-CycleWatch cycleWatch;
int cycleCommand(LineData &lineData, int cycleState){
// if cycleState is 1, then initialize the cycle
@@ -414,6 +414,10 @@
ErrorOut("Init Cycle Failed to seek line", lineData.lineNumber); //Spaces make it look nice on the LCD
return -1;
}
+
+ //Restart the timer for the next cycle
+ cycleTimer.reset();
+ cycleTimer.start();
}
@@ -624,6 +628,37 @@
int interpretCommand(LineData &lineData){
+ //Monitor the Kill Switch, pause the system as needed
+ if(killSw == 1){
+ //place all devices into the pause functionality
+ int i = 0;
+ for(i = 0; i < devices.size(); i++)
+ devices[i]->pause();
+
+ cycleTimer.stop(); //pause the cycle timer
+
+ //Notify the User of the System Kill
+ lcd.setAddress(0,3);
+ lcd.printf(" Killed! ");
+
+ int flag = 0;
+ while (flag == 0){
+ while(killSw == 1);
+ wait(0.04);
+ if (killSw == 0)
+ flag = 1;
+ }
+
+ //place all devices into the resume functionality
+ for(i = 0; i < devices.size(); i++)
+ devices[i]->resume();
+
+ lcd.setAddress(0,3);
+ lcd.printf(" "); // Clear the Line using Spaces (Emptyness) - Note one line is 20 Characters
+ cycleTimer.start(); //start the cycle timer
+ }
+
+
//Monitors the conditions to watch for erroring, and pauses system if any of the conditions turn out to be true
if (!interprettingErrorFlag && enableErrors){
int j = 0, error = -1, numError = 0;
@@ -708,7 +743,7 @@
//since the constructor cannot return a value, it will trip the error Flag if something is wrong, check that flag, and return error if it has been tripped
if (devices.back()->errorFlag == 1){
- ErrorOut("Error initializing device", lineData.lineNumber);
+ ErrorOut("Error initializing device", lineData.lineNumber);
return -1;
}
}
@@ -1000,7 +1035,7 @@
/**********************************************************************************************************************************/
int main() {
-
+
fullInit(); //Initialize anything that's required to run the code (LCD)
LineData lineData;
@@ -1082,7 +1117,7 @@
/******************************************************************************/
/*** <Start Running through the Program txt File Lines> ***/
/******************************************************************************/
-
+while(1){
resetLineData(lineData); //Reset the values in the struct that holds the File / Line Data
lcd.cls(); //clear the display
@@ -1146,10 +1181,9 @@
lcd.printf("Press BACK");
while(!buttons.readBack());
-
- lcd.setAddress(0,1);
- //rewind(selectedFile);
+ rewind(selectedFile);
+}
}
\ No newline at end of file