00001 #ifndef V24_H 00002 #define V24_H 1 00003 00004 #include "SimulationMainWindow.h" 00005 #include "V24_commands.h" 00006 #include "gui_debug.h" 00007 #include "qmessagebox.h" 00008 00009 #include "qextserialport.h" 00010 00011 00012 /******************************************************** 00013 * Einheitliche Kommandostruktur, welche die Kommando's 00014 * auf µC und GUI-Seite vereinheitlicht. 00015 *****************************************************/ 00016 typedef struct V24Command { 00017 unsigned char command; 00018 unsigned char dataLength; 00019 unsigned char data[18]; 00020 } V24COMMAND; 00021 00022 /****************************************************************************************** 00023 * Einheitliche Struktur, die einen Zustand darstellt. * 00024 * Diese Stuktur ist 12-Byte lang, da immer in 4-Byte Blöcken vom Compiler allokiert wird,* 00025 * aus diesem Grund wird die reele länge der bytes in STATESIZE angegeben 00026 ******************************************************************************************/ 00027 typedef struct State { 00028 float value; 00029 //unsigned char best_action; 00030 char feedback_up; 00031 char feedback_down; 00032 char feedback_left; 00033 char feedback_right; 00034 } STATE; 00035 #define STATESIZE 9 00036 00040 class V24Control { 00041 00042 public: 00043 V24Control(QMutex *_guiMutex, QMainWindow *_vater); 00044 00045 bool openDevice(); 00046 void closeDevice(); 00047 00048 bool transmitCommand (V24COMMAND *c); 00049 bool receiveCommand (V24COMMAND *c); 00050 bool receiveTransmitOKCommand(); 00051 00052 void parseFloatData (unsigned char *c, float *_data); 00053 void parseIntegerData (unsigned char *d, unsigned int *_data); 00054 bool setInterface (QString _interface); 00055 00056 private: 00057 bool transmit(unsigned char data); 00058 bool receive(unsigned char *data); 00059 bool transmitAndReceive(unsigned char tData, unsigned char rData); 00060 bool transmitting; 00061 bool receiving; 00062 QMainWindow *parent; 00063 void showErrorCode(unsigned long errorCode); 00064 00065 Posix_QextSerialPort *port; 00066 char filename[50]; 00067 QMutex *guiMutex; 00068 QMutex *conMutex; 00069 QString sDeviceInterface; 00070 bool rxtx; 00071 }; 00072 00073 00074 #endif 00075