@@ -1,96 +1,96 | |||||
1 | #ifndef GR_ESB_BRIDGE_H |
|
1 | #ifndef GR_ESB_BRIDGE_H | |
2 | #define GR_ESB_BRIDGE_H |
|
2 | #define GR_ESB_BRIDGE_H | |
3 | #include "abstractspwbridge.h" |
|
3 | #include "abstractspwbridge.h" | |
4 | #include <QTcpSocket> |
|
4 | #include <QTcpSocket> | |
5 | #include <QThread> |
|
5 | #include <QThread> | |
6 | #include <QMutex> |
|
6 | #include <QMutex> | |
7 | #include <QSemaphore> |
|
7 | #include <QSemaphore> | |
8 | #include <QQueue> |
|
8 | #include <QQueue> | |
9 |
|
9 | |||
10 | struct gresb_Conf_str |
|
10 | struct gresb_Conf_str | |
11 | { |
|
11 | { | |
12 | qint32 Transmit_port; |
|
12 | qint32 Transmit_port; | |
13 | qint32 Receive_port; |
|
13 | qint32 Receive_port; | |
14 | }; |
|
14 | }; | |
15 |
|
15 | |||
16 |
|
16 | |||
17 | const struct gresb_Conf_str gresb_Conf[]= |
|
17 | const struct gresb_Conf_str gresb_Conf[]= | |
18 | { |
|
18 | { | |
19 | {3000,3001}, //Virtual link 0 |
|
19 | {3000,3001}, //Virtual link 0 | |
20 | {3002,3003}, //Virtual link 1 |
|
20 | {3002,3003}, //Virtual link 1 | |
21 | {3004,3005}, //Virtual link 2 |
|
21 | {3004,3005}, //Virtual link 2 | |
22 | {3006,3007}, //Virtual link 3 |
|
22 | {3006,3007}, //Virtual link 3 | |
23 | {3008,3009}, //Virtual link 4 |
|
23 | {3008,3009}, //Virtual link 4 | |
24 | {3010,3011} //Virtual link 5 |
|
24 | {3010,3011} //Virtual link 5 | |
25 | }; |
|
25 | }; | |
26 |
|
26 | |||
27 |
|
27 | |||
28 | class GR_ESB_Manager: public abstractSpwManager |
|
28 | class GR_ESB_Manager: public abstractSpwManager | |
29 | { |
|
29 | { | |
30 | Q_OBJECT |
|
30 | Q_OBJECT | |
31 |
|
31 | |||
32 | typedef struct packetBuffer_t |
|
32 | typedef struct packetBuffer_t | |
33 | { |
|
33 | { | |
34 | char* buffer; |
|
34 | char* buffer; | |
35 | int PacketLen; |
|
35 | int PacketLen; | |
36 | int index; |
|
36 | int index; | |
37 | bool complete; |
|
37 | bool complete; | |
38 | }packetBuffer_t; |
|
38 | }packetBuffer_t; | |
39 |
|
39 | |||
40 | public: |
|
40 | public: | |
41 | explicit GR_ESB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0); |
|
41 | explicit GR_ESB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0); | |
42 | ~GR_ESB_Manager(); |
|
42 | ~GR_ESB_Manager(); | |
43 | void run(); |
|
43 | void run(); | |
44 | bool connectBridge(); |
|
44 | bool connectBridge(); | |
45 | bool disconnectBridge(); |
|
45 | bool disconnectBridge(); | |
46 | bool sendPacket(char* packet,int size); |
|
46 | bool sendPacket(char* packet,int size); | |
47 |
|
47 | |||
48 | signals: |
|
48 | signals: | |
49 | void emitPacket(char* packet,int size); |
|
49 | void emitPacket(char* packet,int size); | |
50 | private: |
|
50 | private: | |
51 | void pushRmapPacket(char* packet,int len); |
|
51 | void pushRmapPacket(char* packet,int len); | |
52 | char* SPWPacketBuff; |
|
52 | char* SPWPacketBuff; | |
53 |
|
53 | |||
54 | void __processPacket(packetBuffer_t *packet); |
|
54 | void __processPacket(packetBuffer_t *packet); | |
55 | QByteArray __processData(const QByteArray &data, packetBuffer_t* buffer); |
|
55 | QByteArray __processData(const QByteArray &data, packetBuffer_t* buffer); | |
56 | private slots: |
|
56 | private slots: | |
57 | void readyRead(); |
|
57 | void readyRead(); | |
58 |
|
58 | |||
59 | public: |
|
59 | public: | |
60 | QTcpSocket Read_soc; |
|
60 | QTcpSocket Read_soc; | |
61 | QTcpSocket Write_soc; |
|
61 | QTcpSocket Write_soc; | |
62 | QMutex incomingPacketsMutex; |
|
62 | QMutex incomingPacketsMutex; | |
63 | QQueue<QByteArray> incomingPackets; |
|
63 | QQueue<QByteArray> incomingPackets; | |
64 | QString IP; |
|
64 | QString IP; | |
65 | int virtualLinkIndex; |
|
65 | int virtualLinkIndex; | |
66 | }; |
|
66 | }; | |
67 |
|
67 | |||
68 |
|
68 | |||
69 | class GR_ESB_bridge : public abstractSpwBridge |
|
69 | class GR_ESB_bridge : public abstractSpwBridge | |
70 | { |
|
70 | { | |
71 | Q_OBJECT |
|
71 | Q_OBJECT | |
72 | public: |
|
72 | public: | |
73 | explicit GR_ESB_bridge(socexplorerplugin *parent = 0); |
|
73 | explicit GR_ESB_bridge(socexplorerplugin *parent = 0); | |
74 | ~GR_ESB_bridge(); |
|
74 | ~GR_ESB_bridge(); | |
75 | signals: |
|
75 | signals: | |
76 |
|
76 | |||
77 |
|
77 | |||
78 | public slots: |
|
78 | public slots: | |
79 | void toggleBridgeConnection(); |
|
79 | void toggleBridgeConnection(); | |
80 | bool connectBridge(); |
|
80 | bool connectBridge(); | |
81 | bool disconnectBridge(); |
|
81 | bool disconnectBridge(); | |
82 | void setIP(QString ip); |
|
82 | void setIP(QString ip); | |
83 | void setVirtualLink(QString vlink); |
|
83 | void setVirtualLink(QString vlink); | |
84 | void setVirtualLink(qint32 vlink); |
|
84 | void setVirtualLink(qint32 vlink); | |
85 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
85 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); | |
86 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
86 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); | |
87 | int pushRMAPPacket(char* packet,int size); |
|
87 | int pushRMAPPacket(char* packet,int size); | |
88 | void packetReceived(); |
|
88 | //void packetReceived(); | |
89 |
|
89 | |||
90 | private: |
|
90 | private: | |
91 |
|
91 | |||
92 | GR_ESB_Manager* manager; |
|
92 | GR_ESB_Manager* manager; | |
93 |
|
93 | |||
94 | }; |
|
94 | }; | |
95 |
|
95 | |||
96 | #endif // GR_ESB_BRIDGE_H |
|
96 | #endif // GR_ESB_BRIDGE_H |
General Comments 0
You need to be logged in to leave comments.
Login now