You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#ifndef __BASIC_TNSPORT_HEADERS__
#define __BASIC_TNSPORT_HEADERS__
#include "basicLogCollection.h"
#include "basicMutex.h"
#include <algorithm>
#include <vector>
#include <queue>
#ifdef DEBUG
// #ifndef DUBUG_COMMUNICATION
// #define DUBUG_COMMUNICATION
// #endif
#endif
#define SERIAL_PING_PONG
#ifdef SERIAL_PING_PONG
class protocolParser;#endif
#ifndef MAXIMAL_SERIAL_IO_BUFFER_LENGTH
#define MAXIMAL_SERIAL_IO_BUFFER_LENGTH 102400
#endif
typedef struct S_SIO_TZ { bool wReplay; bool finished; bool success; int inp_size; int out_size;#ifdef SERIAL_PING_PONG
protocolParser * boundParser;#endif
uint8_t out_buffer[MAXIMAL_SERIAL_IO_BUFFER_LENGTH]; uint8_t inp_buffer[MAXIMAL_SERIAL_IO_BUFFER_LENGTH];} SIO_TZ;
typedef std::queue<SIO_TZ *> Q_SIO_TZ;
class protocolParser;
typedef std::vector<protocolParser *> parseQueue;
class basicTransport{ private:
basicLogCollection * m_pLog;
protected:
parseQueue m_vParsers; basicMutex m_mQueueProtectorMutex; basicMutex m_mBufferProtectorMutex;
CONNECTION_STATUS m_eConnectionStatus;
public:
basicTransport(); ~basicTransport();#ifdef SERIAL_PING_PONG
virtual bool sendData(unsigned char * Data, int DataSize, protocolParser *src = NULL )#else
virtual bool sendData(unsigned char * Data, int DataSize )#endif
{ if ( !Data ) return false; if ( !DataSize ) return false; return true; }
virtual bool reconnect(void) { return false; }
bool addRecipient(protocolParser * ProtoParser); bool removeRecipient(protocolParser * ProtoParser);
bool getStatus(void) { return m_eConnectionStatus == CS_CONNECTED; }
void setConnectionStatus(CONNECTION_STATUS ES); CONNECTION_STATUS getConnectionStatus(void);
virtual int getRawHandle(void) { return -1; }};
#endif
|