|
|
#ifndef GR_ESB_BRIDGE_H
|
|
|
#define GR_ESB_BRIDGE_H
|
|
|
#include "abstractspwbridge.h"
|
|
|
#include <QTcpSocket>
|
|
|
#include <QThread>
|
|
|
#include <QMutex>
|
|
|
#include <QSemaphore>
|
|
|
#include <QQueue>
|
|
|
|
|
|
struct gresb_Conf_str
|
|
|
{
|
|
|
qint32 Transmit_port;
|
|
|
qint32 Receive_port;
|
|
|
};
|
|
|
|
|
|
|
|
|
const struct gresb_Conf_str gresb_Conf[]=
|
|
|
{
|
|
|
{3000,3001}, //Virtual link 0
|
|
|
{3002,3003}, //Virtual link 1
|
|
|
{3004,3005}, //Virtual link 2
|
|
|
{3006,3007}, //Virtual link 3
|
|
|
{3008,3009}, //Virtual link 4
|
|
|
{3010,3011} //Virtual link 5
|
|
|
};
|
|
|
|
|
|
|
|
|
class GR_ESB_Manager: public abstractSpwManager
|
|
|
{
|
|
|
Q_OBJECT
|
|
|
|
|
|
typedef struct packetBuffer_t
|
|
|
{
|
|
|
char* buffer;
|
|
|
int PacketLen;
|
|
|
int index;
|
|
|
bool complete;
|
|
|
}packetBuffer_t;
|
|
|
|
|
|
public:
|
|
|
explicit GR_ESB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0);
|
|
|
~GR_ESB_Manager();
|
|
|
void run();
|
|
|
bool connectBridge();
|
|
|
bool disconnectBridge();
|
|
|
bool sendPacket(char* packet,int size);
|
|
|
|
|
|
signals:
|
|
|
void emitPacket(char* packet,int size);
|
|
|
private:
|
|
|
void pushRmapPacket(char* packet,int len);
|
|
|
char* SPWPacketBuff;
|
|
|
|
|
|
void __processPacket(packetBuffer_t *packet);
|
|
|
QByteArray __processData(const QByteArray &data, packetBuffer_t* buffer);
|
|
|
private slots:
|
|
|
void readyRead();
|
|
|
|
|
|
public:
|
|
|
QTcpSocket Read_soc;
|
|
|
QTcpSocket Write_soc;
|
|
|
QMutex incomingPacketsMutex;
|
|
|
QQueue<QByteArray> incomingPackets;
|
|
|
QString IP;
|
|
|
int virtualLinkIndex;
|
|
|
};
|
|
|
|
|
|
|
|
|
class GR_ESB_bridge : public abstractSpwBridge
|
|
|
{
|
|
|
Q_OBJECT
|
|
|
public:
|
|
|
explicit GR_ESB_bridge(socexplorerplugin *parent = 0);
|
|
|
~GR_ESB_bridge();
|
|
|
signals:
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
void toggleBridgeConnection();
|
|
|
bool connectBridge();
|
|
|
bool disconnectBridge();
|
|
|
void setIP(QString ip);
|
|
|
void setVirtualLink(QString vlink);
|
|
|
void setVirtualLink(qint32 vlink);
|
|
|
unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
|
|
|
unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
|
|
|
int pushRMAPPacket(char* packet,int size);
|
|
|
//void packetReceived();
|
|
|
|
|
|
private:
|
|
|
|
|
|
GR_ESB_Manager* manager;
|
|
|
|
|
|
};
|
|
|
|
|
|
#endif // GR_ESB_BRIDGE_H
|
|
|
|