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:
- 3:078e9a1e8be3
- Parent:
- 2:3e7baa3e3fec
- Child:
- 4:86d0d04cc055
--- a/Initialization.cpp Thu Sep 18 23:38:11 2014 +0000 +++ b/Initialization.cpp Fri Sep 19 00:46:26 2014 +0000 @@ -2,6 +2,40 @@ #include "Motor.hpp" #include "VoltageDriver.hpp" + + +/**********************************************************************************************************************************/ +/**********************************************************************************************************************************/ +/************************** <MUST MODIFY> *************************/ +/**********************************************************************************************************************************/ +/**********************************************************************************************************************************/ + +// 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[] = {"VOLTAGE_DRIVER", "MOTOR"}; + +// ADD YOUR DEVICE TO THE LIST BELOW, CALLING YOUR DEVICE CLASS AS SHOWN +Device* Device::newDevice(int deviceFound, string _name, Line lineData){ + + switch (Device_Map[deviceFound]){ + case MOTOR: return new Motor(lineData); break; + case VOLTAGE_DRIVER: return new VoltageDriver(lineData); break; + + //********** ADD NEXT DEVICE ABOVE **************// + default: break; + } +} + +/************************** <MUST MODIFY> *************************/ +/**********************************************************************************************************************************/ +/**********************************************************************************************************************************/ + + + +/******************************************************************************/ +/*** <Global Initializations> ***/ +/******************************************************************************/ + //Initializations Timer timer; // general purpose timer I2C i2c( P0_10, P0_11 ); // I2C bus (SDA, SCL) @@ -13,43 +47,10 @@ const int MAX_LINE_LENGTH = 100; -//struct Line lineData; -Device* Device::newDevice(int deviceFound, string _name, Line lineData){ - - switch (Device_Map[deviceFound]){ - case MOTOR: - //Device::setName(_name); - //Device::setType(MOTOR); - return new Motor(lineData); - break; - case VOLTAGE_DRIVER: - //setName(_name); - //setType(MOTOR); - return new VoltageDriver(lineData); - break; - } -} -/* -void Device::setName(string _name){ - this->name = _name; -} -void Device::setType(DeviceType _type){ - this->type = _type; -}*/ - -const char *DeviceNames[] = {"MOTOR", "VOLTAGE_DRIVER"}; -int numDevices = sizeof(DeviceNames)/sizeof(DeviceNames[0]); -int currNumDevices = 0; - -vector<Device*> devices; -//Device devices[15]; - -void addDevice(int deviceFound, Line &lineData){ - - devices[currNumDevices] = Device::newDevice(deviceFound, lineData.word[1], lineData); - currNumDevices++; -} +/******************************************************************************/ +/*** <Function Initializations> ***/ +/******************************************************************************/ void fullInit() { @@ -67,3 +68,12 @@ lcd.printf("LCD Initialized"); } + +/******************************************************************************/ +/*** <Parent Device Class Initializations> ***/ +/******************************************************************************/ + +int numDevices = sizeof(DeviceNames)/sizeof(DeviceNames[0]); +int currNumDevices = 0; + +vector<Device*> devices; \ No newline at end of file