00001 #ifndef __V24_H__ 00002 #define __V24_H__ 00003 00004 #include "v24_commands.h" 00005 #include "ValueIteration.h" 00006 00007 /******************************************************** 00008 * uniform command structure 00009 *****************************************************/ 00010 typedef struct V24Command { 00011 unsigned char command; 00012 unsigned char dataLength; 00013 unsigned char data[18]; 00014 } V24COMMAND; 00015 00020 class V24Control { 00021 00022 public: 00023 V24Control(); 00024 ~V24Control(); 00025 void init(); 00026 void processCommand(); 00027 bool newDataReceived(); 00028 int getNewMainMode(int oldMainMode); 00029 00030 // used by main 00031 ValueIteration* vi; 00032 00033 // for testing in main-function 00034 void transmit(unsigned char data); 00035 bool receive(unsigned char*); 00036 00037 private: 00038 void setMainMode (int mainMode); 00039 bool receiveCommand (V24COMMAND *c); 00040 00041 00042 int newMainMode; 00043 int mainMode; 00044 bool transmitCommand (V24COMMAND *c); 00045 00046 bool processGetDebug(); 00047 bool processGetGamma(); 00048 bool processGetExplorationConfig(); 00049 void processSetGamma(V24COMMAND *cmd); 00050 bool processGetGridsize(); 00051 bool processSetGridsize(V24COMMAND *cmd); 00052 bool processGetState(V24COMMAND *cmd); 00053 bool processSetState(V24COMMAND *cmd); 00054 bool processSetMotorPosition(V24Command); 00055 // bool processGetIterations(); 00056 00057 00058 void flushReceiveBuffer(); 00059 bool transmitReceiveCommandProcessed(unsigned char _code, unsigned char _error); 00060 00061 //unsigned char loopCount; 00062 STATE tmpState; 00063 bool rxtx; 00064 bool newDataAvailable; 00065 00066 V24COMMAND tx_command, rx_command; 00067 }; 00068 00069 00070 #endif