Mitchell Hatfield / Mbed 2 deprecated Component_Test_Interface

Dependencies:   BridgeDriver FrontPanelButtons MCP23017 SDFileSystem TextLCD mbed

Revision:
2:3e7baa3e3fec
Parent:
1:5731f31f96be
Child:
3:078e9a1e8be3
--- a/DeviceClasses.h	Tue Sep 16 18:27:41 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,431 +0,0 @@
-/*#include "mbed.h"
-#include "LocalPinNames.h"
-#include "TextLCD.h"
-#include "BridgeDriver.h"
-*/
-#include "Device.hpp"
-
-
-/**********************************************************************************************************************************/
-/**********************************************************************************************************************************/
-/***************************                        <CLASS: Voltage_Driver>                            ****************************/
-/**********************************************************************************************************************************/
-/**********************************************************************************************************************************/
-
-class Voltage_Driver{
-    
-    public :
-        //uint8_t ch123; //Channel value this device is set to  
-        int ch; 
-        int test;
-        
-        int interpret();
-        int forceBrake();
-        //int forceFloat();
-        float drive();  
-         
-        //Voltage_Driver();          
-        void setChannel(int channel){
-            Voltage_Driver::ch = channel;
-        }
-            
-        int getChannel(){     
-            return Voltage_Driver::ch;
-        }
-};
-
-//Voltage_Driver::Voltage_Driver(void){
-//}
-
-//A line consists of [ __(Local_Name)__ __(function)__ __(parameter1)__ __(parameter2)__ __(parameter3)__ ... and so on]
-int Voltage_Driver::interpret(){
-    /*
-    lcd.cls(); //clear the display
-    lcd.setAddress(0,3);
-    lcd.printf("Test2    ");
-    lcd.setAddress(0,1);
-    lcd.printf("wrd1: %s", lineData.word[0]);
-    lcd.setAddress(0,2);
-    lcd.printf("wrd2: %s", lineData.word[1]);
-    wait(3);
-*/
-    
-            
-    char *firstWord = lineData.word[0]; //get the first word in the line
-/*
-    lcd.setAddress(0,2);
-    lcd.printf("fW: %s", firstWord);
-    lcd.setAddress(0,3);
-    lcd.printf("ch: %d", ch);
-    wait(3);*/
-    
-    //Initialize the class and device
-    if (strncmp(firstWord,"device", 6) == 0){
-        //Order of Line: Command, Local_Name, VOLTAGE_DRIVER, Channel(1,2,3,4,5,6,7,8)
-        
-        test = 10;
-        
-        if (lineData.numWords != 4){
-             //Error Check, incorrect number of parameter, error out
-            return 0;
-        }
-            
-        char *channel = lineData.word[3]; //Parameter is a number
-        int channelValue = atoi(channel);
-        
-        //Channel Value between 1 to 8
-        if (channelValue >= 1 && channelValue <= 8){
-            
-            setChannel(channelValue);
-            //ch = channelValue;
-            
-            lcd.setAddress(0,2);
-            lcd.printf("fW: %s", firstWord);
-            //lcd.setAddress(0,3);
-            //lcd.printf("ch: %d", getChannel());
-            lcd.setAddress(0,3);
-            lcd.printf("test: %d", test);
-            //lcd.setAddress(0,3);
-            //lcd.printf("chString: %s", chString);
-            wait(2);
-    
-            switch (channelValue){
-                case 1:
-                case 2:
-                    bridges.enablePwm(BridgeDriver::MOTOR_A, 0);
-                    break;
-                case 3:
-                case 4:
-                    bridges.enablePwm(BridgeDriver::MOTOR_B, 0);
-                    break;
-                case 5:
-                case 6:
-                    bridges.enablePwm(BridgeDriver::MOTOR_C, 0);
-                    break;
-                case 7:
-                case 8:
-                    bridges.enablePwm(BridgeDriver::MOTOR_D, 0);
-                    break;
-            }
-           /* lcd.setAddress(0,2);
-            lcd.printf("AchannelVal: %d", channelValue);
-            lcd.setAddress(0,3);
-            lcd.printf("Ach: %d", ch);
-            wait(3);*/
-    
-        }
-        else{
-            //ERROR Out
-            //Unacceptable channel, or conversion function failed when converting string to int
-        }
-    }
-    
-    //if the first word is not "device" it means that it's trying to perform a function to a specific Motor
-    else{
-        
-
-            
-        //Order of Line: Local_Name, Function_Name, Param1, Param2, Param3,.......
-        char *localname = lineData.word[0]; //just for the sake of following the variable easily and understanding 
-        char *func = lineData.word[1];
-                   
-        /******************************************************************************/
-        /***                       <Func: forceBrake>                               ***/
-        /******************************************************************************/
-        if (strncmp(func,"forceBrake", 10) == 0){
-            
-            if (lineData.numWords != 3){
-                 //Error Check, incorrect number of parameter, error out
-                return 0;
-            }
-            
-            bridges.forceBrake(ch);
-        }
-        
-        
-        /******************************************************************************/
-        /***                           <Func: drive>                                ***/
-        /******************************************************************************/
-        else if (strncmp(func,"drive", 5) == 0){
-            //Order of Line: Local_Name, drive
-            
-            lcd.setAddress(0,0);
-            lcd.printf("lclN: %s ", localname); 
-            lcd.setAddress(0,2);
-            lcd.printf("func: %s ", func);
-            //lcd.setAddress(0,3);
-            //lcd.printf("3ch: %d  ", getChannel());
-            lcd.setAddress(0,3);
-            lcd.printf("test: %d", test);
-            //lcd.setAddress(0,3);
-            //lcd.printf("chString: %s   ", chString);
-            wait(3);
-        
-            if (lineData.numWords != 2){
-                 //Error Check, incorrect number of parameter, error out
-                return 0;
-            }
-             /*           
-            int State = 2;
-            int channelValue = atoi(chString);
-            State = bridges.drive(channelValue, 1); //Turn channel on
-            lcd.setAddress(0,2);
-            lcd.printf("TEST ch: %d, State: %d", channelValue, State);
-            wait(3);*/
-            
-        }
-        
-        
-        /******************************************************************************/
-        /****                           <Func: off>                                ****/
-        /******************************************************************************/
-        else if (strncmp(func,"drive", 5) == 0){
-            //Order of Line: Local_Name, drive, duration
-            
-            if (lineData.numWords != 2){
-                 //Error Check, incorrect number of parameter, error out
-                return 0;
-            }
-            
-            bridges.drive(getChannel(), 0); //Turn channel off
-        }
-        
-        else {
-            return 0;
-            
-        }  
-    }  
-    /*
-    lcd.setAddress(0,3);
-    lcd.printf("ENDch: %d  ", getChannel());
-    wait(3);*/
-            
-    return 1;
-}
-
-
-
-/**********************************************************************************************************************************/
-/**********************************************************************************************************************************/
-/********************************                        <CLASS: Motor>                            ********************************/
-/**********************************************************************************************************************************/
-/**********************************************************************************************************************************/
-
-class Motor{
-    
-    enum BridgeDriver::Motors motor; 
-
-    public :
-        int interpret();
-        void enableBrake();
-        int forceBrake();
-        //int forceFloat();
-        float drive();  
-        
-        
-        void setMotor(BridgeDriver::Motors selectedMotor){
-            motor = selectedMotor;
-        }
-            
-        enum BridgeDriver::Motors getMotor(){     
-            return motor;
-        }
-    
-};
-
-//A line consists of [ __(Local_Name)__ __(function)__ __(parameter1)__ __(parameter2)__ __(parameter3)__ ... and so on]
-int Motor::interpret(){
-    /*
-    lcd.cls(); //clear the display
-    lcd.setAddress(0,3);
-    lcd.printf("Test2    ");
-    lcd.setAddress(0,1);
-    lcd.printf("wrd1: %s", lineData.word[0]);
-    lcd.setAddress(0,2);
-    lcd.printf("wrd2: %s", lineData.word[1]);
-    wait(3);
-*/
-    
-    lcd.setAddress(0,2);
-    lcd.printf("wrd1: %s", lineData.word[0]);
-    lcd.setAddress(0,3);
-    lcd.printf("TEST1  ");
-    wait(1);
-    
-    char *firstWord = lineData.word[0]; //splits the str based on a space delimeter 
-
-    if (strncmp(firstWord,"device", 6) == 0){
-        //Order of Line: Command, Local_Name, VOLTAGE_DRIVER, Channel(1,2,3,4,5,6,7,8)
-
-        if (lineData.numWords != 4){
-             //Error Check, incorrect number of parameter, error out
-            return 0;
-        }
-        
-        char channel = *lineData.word[3]; //Parameter is a single character, so dereference the point to the word
-    
-        switch (channel){
-            case 'A':
-            case 'a':
-                setMotor(BridgeDriver::MOTOR_A);
-                break;
-            case 'B':
-            case 'b':
-                setMotor(BridgeDriver::MOTOR_B);
-                break;
-            case 'C':
-            case 'c':
-                setMotor(BridgeDriver::MOTOR_C);
-                break;
-            case 'D':
-            case 'd':
-                setMotor(BridgeDriver::MOTOR_D);
-                break;
-        }
-    }
-    
-    //if the first word is not "device" it means that it's trying to perform a function to a specific Motor
-    else{
-        //Order of Line: Local_Name, Function_Name, Param1, Param2, Param3,.......
-        char *localname = lineData.word[0]; //just for the sake of following the variable easily and understanding 
-        char *func = lineData.word[1];
-            
-        /******************************************************************************/
-        /***                       <Func: enableBrake>                              ***/
-        /******************************************************************************/
-        if (strncmp(func,"enableBrake", 11) == 0){
-            
-            if (lineData.numWords != 4){
-                 //Error Check, incorrect number of parameter, error out
-                return 0;
-            }
-            
-            //Initialize and Convert Parameters
-            char *enable = lineData.word[2];
-            int enableValue = atoi(enable);
-            
-            bridges.enableBraking(getMotor(), enableValue);
-        }
-            
-        /******************************************************************************/
-        /***                       <Func: forceBrake>                               ***/
-        /******************************************************************************/
-        else if (strncmp(func,"forceBrake", 10) == 0){
-            
-            if (lineData.numWords != 3){
-                 //Error Check, incorrect number of parameter, error out
-                return 0;
-            }
-            
-            bridges.forceBrake(getMotor());
-        }
-        
-        
-        /******************************************************************************/
-        /***                           <Func: drive>                                ***/
-        /******************************************************************************/
-        else if (strncmp(func,"drive", 5) == 0){
-            
-            lcd.setAddress(0,2);
-            lcd.printf("wrd2: %s", lineData.word[1]);
-            lcd.setAddress(0,3);
-            lcd.printf("TEST2  ");
-            wait(1);
-    
-            if (lineData.numWords != 4){
-                 //Error Check, incorrect number of parameter, error out
-                return 0;
-            }
-                        
-            //Initialize Parameters
-            char *speed = lineData.word[2];
-            char *dir = lineData.word[3];
-            
-            lcd.setAddress(0,3);
-            lcd.printf("TEST3  ");
-            
-            //Initialize Convertion Variables if needed
-            float speedValue;
-            int dirValue = 0;
-    
-            lcd.setAddress(0,3);
-            lcd.printf("TEST4  ");
-            
-            //Convert string to usable values
-            //NOTE both atof and atoi functions return 0 if no valid conversion could be performed
-            speedValue = atof(speed) / 100;
-            
-            lcd.setAddress(0,3);
-            lcd.printf("TEST5  ");
-            
-            if (speedValue <= 0)
-                return 0; //Error Out because a value gives no functionality or is wrong
-            
-            lcd.setAddress(0,3);
-            lcd.printf("TEST6  ");
-            
-            if (strncmp(dir,"CC", 2) == 0 || strncmp(dir,"cc", 2) == 0)
-                dirValue = -1; //Turn Clockwise
-            else if (strncmp(dir,"C", 1) == 0 || strncmp(dir,"c", 1) == 0)
-                dirValue = 1; //Turn CounterClockwise
-            else
-                return 0; //Error Out since the parameter is incorrect
-                
-            lcd.setAddress(0,3);
-            lcd.printf("TEST7  ");
-            
-            bridges.drive(getMotor(), dirValue, speedValue); //Turn on the Motor
-            
-            lcd.setAddress(0,3);
-            lcd.printf("TEST8  ");
-            
-        }
-        /******************************************************************************/
-        /****                           <Func: off>                                ****/
-        /******************************************************************************/
-        else if (strncmp(func,"off", 3) == 0){
-            
-            lcd.setAddress(0,2);
-            lcd.printf("wrd2: %s", lineData.word[1]);
-            lcd.setAddress(0,3);
-            lcd.printf("TEST2  ");
-            wait(1);
-            
-            if (lineData.numWords != 2){
-                 //Error Check, incorrect number of parameter, error out
-                return 0;
-            }
-                 
-            bridges.drive(getMotor(), 0, 0); //Turn off the Motor
-        }
-        
-        else {
-            return 0;
-            
-        }  
-    }  
-    
-    return 1;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-