Go to the documentation of this file.00001
00002 #ifndef ATRASRCLIENT_H
00003 #define ATRASRCLIENT_H
00004
00005 #include <QTcpSocket>
00006
00007
00008 #define ATRASR_FRAME_HEADER_SIZE 4
00009 #define ATRASR_FRAME_DATA_SIZE 320
00010 #define ATRASR_FRAME_SIZE (ATRASR_FRAME_HEADER_SIZE + ATRASR_FRAME_DATA_SIZE)
00011
00012 #define ATRASR_SEND_BUF_FRAME_COUNT 100 // 1 sec
00013 #define ATRASR_SEND_BUF_SIZE (ATRASR_FRAME_SIZE * ATRASR_SEND_BUF_FRAME_COUNT)
00014
00015 #define ATRASR_RECV_BUF_FRAME_COUNT 100 // 1 sec
00016 #define ATRASR_RECV_BUF_SIZE (ATRASR_FRAME_SIZE * ATRASR_RECV_BUF_FRAME_COUNT)
00017
00021 typedef enum
00022 {
00023 ATRASR_TOF = 9,
00024 ATRASR_START = 1,
00025 ATRASR_DATA = 0,
00026 ATRASR_END = 2,
00027 ATRASR_CANCEL= 6,
00028 ATRASR_EOF = 10
00029
00030 } ATRASR_FRAME_TYPE;
00031
00035 typedef struct
00036 {
00037 QTcpSocket *socket;
00038
00040 unsigned char sendBuf[ATRASR_SEND_BUF_SIZE + ATRASR_FRAME_SIZE];
00041 int curIndexSendBuf;
00042 int sendFrameCount;
00043
00045 unsigned char recvBuf[ATRASR_RECV_BUF_SIZE];
00046 int curIndexRecvBuf;
00047 int recvFrameCount;
00048
00049 char *logFilename;
00050
00051 } ATRASR_CLIENT;
00052
00060 int AtrasrConnect( ATRASR_CLIENT *client, const char *srvHost, int srvPort );
00061
00066 void AtrasrClose( ATRASR_CLIENT *client );
00067
00073 int AtrasrSendTOF( ATRASR_CLIENT *client );
00074
00080 int AtrasrSendEOF( ATRASR_CLIENT *client );
00081
00089 int AtrasrSendDATA( ATRASR_CLIENT *client, const char *data, size_t size );
00090
00096 int AtrasrSendSTARTPU( ATRASR_CLIENT *client );
00097
00103 int AtrasrSendENDPU( ATRASR_CLIENT *client );
00104
00110 int AtrasrSendCANCELPU( ATRASR_CLIENT *client );
00111
00117 void AtrasrSendDataFromFile( ATRASR_CLIENT *client, const char *fileName );
00118
00125 void AtrasrSendRawData( ATRASR_CLIENT *client, const char *data, size_t size );
00126
00132 int AtrasrReceiveFrame( ATRASR_CLIENT *client );
00133
00141 unsigned char *AtrasrParseFrame( ATRASR_CLIENT *client, int nIndex, long *type );
00142
00143 #endif