![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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
Initialization.hpp@11:bc9cd2869f95, 2014-10-01 (annotated)
- Committer:
- mehatfie
- Date:
- Wed Oct 01 18:11:38 2014 +0000
- Revision:
- 11:bc9cd2869f95
- Parent:
- 9:5a0c4c6e39c7
- Child:
- 12:2e3e86714243
- Latest revision is not a working copy, simply publishing all previous working copies to the server
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mehatfie | 0:22618cf06f45 | 1 | #ifndef INITIALIZATION_HPP |
mehatfie | 0:22618cf06f45 | 2 | #define INITIALIZATION_HPP |
mehatfie | 0:22618cf06f45 | 3 | |
mehatfie | 0:22618cf06f45 | 4 | #include "mbed.h" |
mehatfie | 0:22618cf06f45 | 5 | #include "LocalPinNames.h" |
mehatfie | 0:22618cf06f45 | 6 | #include "BridgeDriver.h" |
mehatfie | 0:22618cf06f45 | 7 | #include "FrontPanelButtons.h" |
mehatfie | 0:22618cf06f45 | 8 | #include "TextLCD.h" |
mehatfie | 0:22618cf06f45 | 9 | #include "SDFileSystem.h" |
mehatfie | 2:3e7baa3e3fec | 10 | #include <string> |
mehatfie | 2:3e7baa3e3fec | 11 | #include <vector> |
mehatfie | 0:22618cf06f45 | 12 | |
mehatfie | 3:078e9a1e8be3 | 13 | |
mehatfie | 3:078e9a1e8be3 | 14 | /**********************************************************************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 15 | /**********************************************************************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 16 | /************************** <MUST MODIFY> *************************/ |
mehatfie | 3:078e9a1e8be3 | 17 | /**********************************************************************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 18 | /**********************************************************************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 19 | |
mehatfie | 11:bc9cd2869f95 | 20 | enum DeviceType{MOTOR, VOLTAGE_DRIVER, PIN_IN, TIMER_DEVICE, CAN_DEVICE}; //ADD DEVICE NAME |
mehatfie | 11:bc9cd2869f95 | 21 | static const enum DeviceType Device_Map[] = {MOTOR, VOLTAGE_DRIVER, PIN_IN, TIMER_DEVICE, CAN_DEVICE}; //AND HERE ***NOTE TO KEEP SAME ORDER |
mehatfie | 3:078e9a1e8be3 | 22 | |
mehatfie | 3:078e9a1e8be3 | 23 | /************************** <MUST MODIFY> *************************/ |
mehatfie | 3:078e9a1e8be3 | 24 | /**********************************************************************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 25 | /**********************************************************************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 26 | |
mehatfie | 3:078e9a1e8be3 | 27 | |
mehatfie | 3:078e9a1e8be3 | 28 | |
mehatfie | 3:078e9a1e8be3 | 29 | /******************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 30 | /*** <Global Initializations> ***/ |
mehatfie | 3:078e9a1e8be3 | 31 | /******************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 32 | |
mehatfie | 0:22618cf06f45 | 33 | //Initializations |
mehatfie | 2:3e7baa3e3fec | 34 | extern Timer timer; // general purpose timer |
mehatfie | 2:3e7baa3e3fec | 35 | extern I2C i2c; // I2C bus (SDA, SCL) |
mehatfie | 2:3e7baa3e3fec | 36 | extern BridgeDriver bridges; // Bridge |
mehatfie | 2:3e7baa3e3fec | 37 | extern TextLCD_I2C lcd; // LCD |
mehatfie | 2:3e7baa3e3fec | 38 | extern SDFileSystem sd; // the pinout on the mbed LPC1768 |
mehatfie | 0:22618cf06f45 | 39 | |
mehatfie | 2:3e7baa3e3fec | 40 | extern DigitalIn killSw; |
mehatfie | 2:3e7baa3e3fec | 41 | |
mehatfie | 11:bc9cd2869f95 | 42 | //extern Ticker errorWatcher; |
mehatfie | 11:bc9cd2869f95 | 43 | |
mehatfie | 2:3e7baa3e3fec | 44 | extern const int MAX_LINE_LENGTH; |
mehatfie | 6:d1594fd2ec5a | 45 | extern int DummyMode; |
mehatfie | 11:bc9cd2869f95 | 46 | extern FILE *selectedFile; |
mehatfie | 11:bc9cd2869f95 | 47 | extern int errorFLAG; |
mehatfie | 11:bc9cd2869f95 | 48 | |
mehatfie | 11:bc9cd2869f95 | 49 | /******************************************************************************/ |
mehatfie | 11:bc9cd2869f95 | 50 | /*** <Line Data Struct Initializations> ***/ |
mehatfie | 11:bc9cd2869f95 | 51 | /******************************************************************************/ |
mehatfie | 11:bc9cd2869f95 | 52 | |
mehatfie | 11:bc9cd2869f95 | 53 | struct LineData{ |
mehatfie | 11:bc9cd2869f95 | 54 | |
mehatfie | 11:bc9cd2869f95 | 55 | int lineNumber; //current line number in the program txt file that is running |
mehatfie | 11:bc9cd2869f95 | 56 | string word[50]; //array of words from the line of text, assuming no more than 50 words will be in any given line |
mehatfie | 11:bc9cd2869f95 | 57 | //in this initialization there are 15 string (pointers) of size MAX_LINE_LENGTH each |
mehatfie | 11:bc9cd2869f95 | 58 | int numWords; //Number of words in the given line |
mehatfie | 11:bc9cd2869f95 | 59 | int lineAddress; //current line address in the SD Card |
mehatfie | 11:bc9cd2869f95 | 60 | }; |
mehatfie | 3:078e9a1e8be3 | 61 | |
mehatfie | 3:078e9a1e8be3 | 62 | /******************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 63 | /*** <Function Initializations> ***/ |
mehatfie | 3:078e9a1e8be3 | 64 | /******************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 65 | |
mehatfie | 3:078e9a1e8be3 | 66 | void fullInit(); //Perform and call any needed initializations |
mehatfie | 0:22618cf06f45 | 67 | |
mehatfie | 3:078e9a1e8be3 | 68 | void initLCD(void); //Initialize the LCD |
mehatfie | 3:078e9a1e8be3 | 69 | |
mehatfie | 9:5a0c4c6e39c7 | 70 | void ErrorOut(string, int); //Outputs error message, line number, and formatting to LCD |
mehatfie | 0:22618cf06f45 | 71 | |
mehatfie | 11:bc9cd2869f95 | 72 | int cyclePrograms(vector<string>, int, int, int); |
mehatfie | 11:bc9cd2869f95 | 73 | |
mehatfie | 11:bc9cd2869f95 | 74 | void resetLineData(LineData &); //reset and all variables of the Line Data Struct |
mehatfie | 11:bc9cd2869f95 | 75 | |
mehatfie | 11:bc9cd2869f95 | 76 | int interpretCommand(LineData &); |
mehatfie | 11:bc9cd2869f95 | 77 | |
mehatfie | 11:bc9cd2869f95 | 78 | int loopCommand(LineData &); |
mehatfie | 11:bc9cd2869f95 | 79 | |
mehatfie | 3:078e9a1e8be3 | 80 | /******************************************************************************/ |
mehatfie | 11:bc9cd2869f95 | 81 | /*** <GoTo Label Initializations> ***/ |
mehatfie | 3:078e9a1e8be3 | 82 | /******************************************************************************/ |
mehatfie | 0:22618cf06f45 | 83 | |
mehatfie | 11:bc9cd2869f95 | 84 | struct GoToLabel{ |
mehatfie | 11:bc9cd2869f95 | 85 | |
mehatfie | 11:bc9cd2869f95 | 86 | string name; //name of the GoTo Label |
mehatfie | 11:bc9cd2869f95 | 87 | int lineNumber; //line number of the GoTo Label |
mehatfie | 11:bc9cd2869f95 | 88 | int lineAddress; //line address of the GoTo Label |
mehatfie | 0:22618cf06f45 | 89 | }; |
mehatfie | 0:22618cf06f45 | 90 | |
mehatfie | 11:bc9cd2869f95 | 91 | extern vector<GoToLabel> GoToLabels; |
mehatfie | 0:22618cf06f45 | 92 | |
mehatfie | 2:3e7baa3e3fec | 93 | |
mehatfie | 11:bc9cd2869f95 | 94 | /******************************************************************************/ |
mehatfie | 11:bc9cd2869f95 | 95 | /*** <Cycle Struct Initializations> ***/ |
mehatfie | 11:bc9cd2869f95 | 96 | /******************************************************************************/ |
mehatfie | 11:bc9cd2869f95 | 97 | |
mehatfie | 11:bc9cd2869f95 | 98 | struct CycleWatch{ |
mehatfie | 11:bc9cd2869f95 | 99 | |
mehatfie | 11:bc9cd2869f95 | 100 | int numCycles; //number of cycles to go to |
mehatfie | 11:bc9cd2869f95 | 101 | int startAddress; //starting address to seek back to on loop |
mehatfie | 11:bc9cd2869f95 | 102 | int startLineNumber; //starting line number to reset to |
mehatfie | 11:bc9cd2869f95 | 103 | }; |
mehatfie | 2:3e7baa3e3fec | 104 | |
mehatfie | 3:078e9a1e8be3 | 105 | /******************************************************************************/ |
mehatfie | 3:078e9a1e8be3 | 106 | /*** <Parent Device Class Initializations> ***/ |
mehatfie | 3:078e9a1e8be3 | 107 | /******************************************************************************/ |
mehatfie | 2:3e7baa3e3fec | 108 | |
mehatfie | 3:078e9a1e8be3 | 109 | extern const string DeviceNames[]; |
mehatfie | 2:3e7baa3e3fec | 110 | extern int numDevices; |
mehatfie | 2:3e7baa3e3fec | 111 | extern int currNumDevices; |
mehatfie | 2:3e7baa3e3fec | 112 | |
mehatfie | 2:3e7baa3e3fec | 113 | |
mehatfie | 2:3e7baa3e3fec | 114 | class Device{ |
mehatfie | 2:3e7baa3e3fec | 115 | |
mehatfie | 2:3e7baa3e3fec | 116 | public: |
mehatfie | 2:3e7baa3e3fec | 117 | string name; |
mehatfie | 9:5a0c4c6e39c7 | 118 | int errorFlag; |
mehatfie | 2:3e7baa3e3fec | 119 | enum DeviceType type; |
mehatfie | 5:e36e0538a903 | 120 | static Device* newDevice(int, string, LineData); |
mehatfie | 5:e36e0538a903 | 121 | virtual int interpret(LineData&) = 0; |
mehatfie | 9:5a0c4c6e39c7 | 122 | virtual int off() = 0; |
mehatfie | 11:bc9cd2869f95 | 123 | virtual int pause() = 0; |
mehatfie | 11:bc9cd2869f95 | 124 | virtual int resume() = 0; |
mehatfie | 2:3e7baa3e3fec | 125 | }; |
mehatfie | 2:3e7baa3e3fec | 126 | |
mehatfie | 11:bc9cd2869f95 | 127 | extern vector<Device*> devices; //Initialize vector of devices |
mehatfie | 2:3e7baa3e3fec | 128 | |
mehatfie | 2:3e7baa3e3fec | 129 | |
mehatfie | 11:bc9cd2869f95 | 130 | /******************************************************************************/ |
mehatfie | 11:bc9cd2869f95 | 131 | /*** <Error Monitor Initializations> ***/ |
mehatfie | 11:bc9cd2869f95 | 132 | /******************************************************************************/ |
mehatfie | 11:bc9cd2869f95 | 133 | /* |
mehatfie | 11:bc9cd2869f95 | 134 | struct ErrorCondition{ |
mehatfie | 11:bc9cd2869f95 | 135 | |
mehatfie | 11:bc9cd2869f95 | 136 | LineData errorToWatch; |
mehatfie | 11:bc9cd2869f95 | 137 | LineData errorFix; |
mehatfie | 11:bc9cd2869f95 | 138 | int hasFix; |
mehatfie | 11:bc9cd2869f95 | 139 | }; |
mehatfie | 11:bc9cd2869f95 | 140 | |
mehatfie | 11:bc9cd2869f95 | 141 | //extern vector<ErrorCondition> errorMonitors; //Initialize vector of errors to monitor |
mehatfie | 11:bc9cd2869f95 | 142 | extern ErrorCondition errorMonitors[15]; |
mehatfie | 11:bc9cd2869f95 | 143 | extern int numErrorMonitors;*/ |
mehatfie | 11:bc9cd2869f95 | 144 | //void ErrorMonitor(); //Monitors the conditions to watch for erroring, and pauses system if any of the conditions turn out to be true |
mehatfie | 11:bc9cd2869f95 | 145 | |
mehatfie | 0:22618cf06f45 | 146 | #endif |