##// END OF EJS Templates
Sync
Jeandet Alexis -
r24:f6b7bed80207 default
parent child
Show More
@@ -1,11 +1,15
1 #include "gr_esb_bridge.h"
1 #include "gr_esb_bridge.h"
2 #include "gr_esb_ui.h"
2 #include "gr_esb_ui.h"
3 #include <unistd.h>
3
4
4 GR_ESB_bridge::GR_ESB_bridge(socexplorerplugin *parent) :
5 GR_ESB_bridge::GR_ESB_bridge(socexplorerplugin *parent) :
5 abstractSpwBridge(parent)
6 abstractSpwBridge(parent)
6 {
7 {
7 this->p_GUI = new GR_ESB_ui();
8 this->p_GUI = new GR_ESB_ui();
8 this->soc = new QTcpSocket(this);
9 this->Read_soc = new QTcpSocket(this);
10 this->Write_soc = new QTcpSocket(this);
11 connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(ipchanged(QString)),this,SLOT(setIP(QString)));
12 connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(vlinkchanged(QString)),this,SLOT(setPort(QString)));
9 }
13 }
10
14
11 GR_ESB_bridge::~GR_ESB_bridge()
15 GR_ESB_bridge::~GR_ESB_bridge()
@@ -14,14 +18,66 GR_ESB_bridge::~GR_ESB_bridge()
14
18
15 bool GR_ESB_bridge::connectBridge()
19 bool GR_ESB_bridge::connectBridge()
16 {
20 {
17
21 int timeout=60;
22 if(this->Read_soc->state()==QTcpSocket::UnconnectedState)
23 {
24 this->Read_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Read_port);
25 this->Read_soc->waitForConnected(30000);
26 }
27 if(this->Write_soc->state()==QTcpSocket::UnconnectedState)
28 {
29 this->Write_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Write_port);
30 this->Write_soc->waitForConnected(30000);
31 }
32 while((this->Read_soc->state()!=QTcpSocket::ConnectedState) && (this->Write_soc->state()!=QTcpSocket::ConnectedState))
33 {
34 usleep(100000);
35 if(timeout--==0)return false;
36 }
37 return true;
18 }
38 }
19
39
20 bool GR_ESB_bridge::disconnectBridge()
40 bool GR_ESB_bridge::disconnectBridge()
21 {
41 {
42 int timeout=60;
43 if(this->Read_soc->state()!=QTcpSocket::UnconnectedState)
44 {
45 this->Read_soc->disconnectFromHost();
46 this->Read_soc->waitForDisconnected(30000);
47 while(this->Read_soc->state()!=QTcpSocket::UnconnectedState)
48 {
49 usleep(100000);
50 if(timeout--==0)return false;
51 }
52 }
53 return true;
54 }
22
55
56 void GR_ESB_bridge::setIP(QString ip)
57 {
58 this->IP = ip;
23 }
59 }
24
60
61 void GR_ESB_bridge::setVirtualLink(QString vlink)
62 {
63 vlink = vlink.section("Virtual link",0,0);
64 bool success;
65 int vlinkTmp = vlink.toInt(&success);
66 if(success)
67 {
68 setVirtualLink(vlinkTmp);
69 }
70 }
71
72 void GR_ESB_bridge::setVirtualLink(qint32 vlink)
73 {
74 if(vlink<6 && vlink>=0)
75 {
76 virtualLinkIndex = vlink;
77 }
78 }
79
80
25 unsigned int GR_ESB_bridge::Write(unsigned int *Value, unsigned int count, unsigned int address)
81 unsigned int GR_ESB_bridge::Write(unsigned int *Value, unsigned int count, unsigned int address)
26 {
82 {
27
83
@@ -3,6 +3,22
3 #include "abstractspwbridge.h"
3 #include "abstractspwbridge.h"
4 #include <QTcpSocket>
4 #include <QTcpSocket>
5
5
6 struct gresb_Conf_str
7 {
8 qint32 Read_port;
9 qint32 Write_port;
10 };
11
12 const struct gresb_Conf_str gresb_Conf[]=
13 {
14 {3000,3001}, //Virtual link 0
15 {3002,3003}, //Virtual link 1
16 {3004,3005}, //Virtual link 2
17 {3006,3007}, //Virtual link 3
18 {3008,3009}, //Virtual link 4
19 {3010,3011} //Virtual link 5
20 };
21
6 class GR_ESB_bridge : public abstractSpwBridge
22 class GR_ESB_bridge : public abstractSpwBridge
7 {
23 {
8 Q_OBJECT
24 Q_OBJECT
@@ -15,12 +31,19 signals:
15 public slots:
31 public slots:
16 bool connectBridge();
32 bool connectBridge();
17 bool disconnectBridge();
33 bool disconnectBridge();
34 void setIP(QString ip);
35 void setVirtualLink(QString vlink);
36 void setVirtualLink(qint32 vlink);
18 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
37 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
19 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
38 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
20 int pushRMAPPacket(char* packet,int size);
39 int pushRMAPPacket(char* packet,int size);
21 void packetReceived();
40 void packetReceived();
22
41
23 QTcpSocket* soc;
42 private:
43 QTcpSocket* Read_soc;
44 QTcpSocket* Write_soc;
45 QString IP;
46 int virtualLinkIndex;
24
47
25 };
48 };
26
49
@@ -1,14 +1,19
1 #include "gr_esb_ui.h"
1 #include "gr_esb_ui.h"
2 #include "ui_gr_esb_ui.h"
2 #include "ui_gr_esb_ui.h"
3 #include <QWebView>
3
4
4 GR_ESB_ui::GR_ESB_ui(QWidget *parent) :
5 GR_ESB_ui::GR_ESB_ui(QWidget *parent) :
5 QWidget(parent),
6 QWidget(parent),
6 ui(new Ui::GR_ESB_ui)
7 ui(new Ui::GR_ESB_ui)
7 {
8 {
8 ui->setupUi(this);
9 ui->setupUi(this);
10 connect(this->ui->GRESB_IP_lineEdit,SIGNAL(textChanged(QString)),this,SLOT(changeIp(QString)));
11 connect(this->ui->GRESB_Vlink_CmBx,SIGNAL(currentIndexChanged(QString)),this,SIGNAL(vlinkchanged(QString)));
9 }
12 }
10
13
11 GR_ESB_ui::~GR_ESB_ui()
14 void GR_ESB_ui::changeIp(QString ip)
12 {
15 {
13 delete ui;
16 this->ui->WebView->load(QUrl("http://"+ip));
17 emit this->ipchanged(ip);
14 }
18 }
19
@@ -13,8 +13,13 class GR_ESB_ui : public QWidget
13
13
14 public:
14 public:
15 explicit GR_ESB_ui(QWidget *parent = 0);
15 explicit GR_ESB_ui(QWidget *parent = 0);
16 ~GR_ESB_ui();
16
17 public slots:
18 void changeIp(QString ip);
17
19
20 signals:
21 void ipchanged(QString ip);
22 void vlinkchanged(QString vlink);
18 private:
23 private:
19 Ui::GR_ESB_ui *ui;
24 Ui::GR_ESB_ui *ui;
20 };
25 };
@@ -13,55 +13,127
13 <property name="windowTitle">
13 <property name="windowTitle">
14 <string>Form</string>
14 <string>Form</string>
15 </property>
15 </property>
16 <layout class="QGridLayout" name="gridLayout">
16 <layout class="QVBoxLayout" name="verticalLayout">
17 <item row="1" column="2">
17 <item>
18 <widget class="QLineEdit" name="GRESB_Port_lineEdit"/>
18 <widget class="QTabWidget" name="tabWidget">
19 </item>
19 <property name="toolTip">
20 <item row="1" column="0">
20 <string/>
21 <widget class="QLabel" name="GRESB_Port_Lbl">
22 <property name="text">
23 <string>GR-ESB Port</string>
24 </property>
21 </property>
25 </widget>
22 <property name="currentIndex">
26 </item>
23 <number>0</number>
27 <item row="0" column="2">
28 <widget class="QLineEdit" name="GRESB_IP_lineEdit"/>
29 </item>
30 <item row="0" column="0">
31 <widget class="QLabel" name="GRESB_IP_Lbl">
32 <property name="text">
33 <string>GR-ESB IP Address</string>
34 </property>
24 </property>
35 </widget>
25 <widget class="QWidget" name="Config">
36 </item>
26 <property name="toolTip">
37 <item row="2" column="0">
27 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The Config tab allows you to configure the Ethernet conncetion to the GR-ESB and some spacewire parameters.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
38 <widget class="QLabel" name="GRESB_LinkNum_Lbl">
39 <property name="text">
40 <string>Select link number</string>
41 </property>
42 </widget>
43 </item>
44 <item row="2" column="2">
45 <widget class="QComboBox" name="GRESB_LinkNum_CmBx">
46 <item>
47 <property name="text">
48 <string>SPW0</string>
49 </property>
28 </property>
50 </item>
29 <attribute name="title">
51 <item>
30 <string>Config</string>
52 <property name="text">
31 </attribute>
53 <string>SPW1</string>
32 <layout class="QGridLayout" name="gridLayout_2">
33 <item row="1" column="1">
34 <widget class="QComboBox" name="GRESB_Vlink_CmBx">
35 <item>
36 <property name="text">
37 <string>Virtual link 0</string>
38 </property>
39 </item>
40 <item>
41 <property name="text">
42 <string>Virtual link 1</string>
43 </property>
44 </item>
45 <item>
46 <property name="text">
47 <string>Virtual link 2</string>
48 </property>
49 </item>
50 <item>
51 <property name="text">
52 <string>Virtual link 3</string>
53 </property>
54 </item>
55 <item>
56 <property name="text">
57 <string>Virtual link 4</string>
58 </property>
59 </item>
60 <item>
61 <property name="text">
62 <string>Virtual link 5</string>
63 </property>
64 </item>
65 </widget>
66 </item>
67 <item row="1" column="0">
68 <widget class="QLabel" name="GRESB_Vlink_Lbl">
69 <property name="text">
70 <string>GR-ESB Virtual link</string>
71 </property>
72 </widget>
73 </item>
74 <item row="2" column="1">
75 <widget class="QComboBox" name="GRESB_LinkNum_CmBx">
76 <item>
77 <property name="text">
78 <string>SPW0</string>
79 </property>
80 </item>
81 <item>
82 <property name="text">
83 <string>SPW1</string>
84 </property>
85 </item>
86 <item>
87 <property name="text">
88 <string>SPW2</string>
89 </property>
90 </item>
91 </widget>
92 </item>
93 <item row="0" column="1">
94 <widget class="QLineEdit" name="GRESB_IP_lineEdit"/>
95 </item>
96 <item row="2" column="0">
97 <widget class="QLabel" name="GRESB_LinkNum_Lbl">
98 <property name="text">
99 <string>Select link number</string>
100 </property>
101 </widget>
102 </item>
103 <item row="0" column="0">
104 <widget class="QLabel" name="GRESB_IP_Lbl">
105 <property name="text">
106 <string>GR-ESB IP Address</string>
107 </property>
108 </widget>
109 </item>
110 </layout>
111 </widget>
112 <widget class="QWidget" name="Web">
113 <property name="toolTip">
114 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The Web tab gives access to the GR-ESB web interface.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
54 </property>
115 </property>
55 </item>
116 <attribute name="title">
56 <item>
117 <string>Web</string>
57 <property name="text">
118 </attribute>
58 <string>SPW2</string>
119 <layout class="QHBoxLayout" name="horizontalLayout">
59 </property>
120 <item>
60 </item>
121 <widget class="QWebView" name="WebView" native="true"/>
122 </item>
123 </layout>
124 </widget>
61 </widget>
125 </widget>
62 </item>
126 </item>
63 </layout>
127 </layout>
64 </widget>
128 </widget>
129 <customwidgets>
130 <customwidget>
131 <class>QWebView</class>
132 <extends>QWidget</extends>
133 <header location="global">QWebView</header>
134 <container>1</container>
135 </customwidget>
136 </customwidgets>
65 <resources/>
137 <resources/>
66 <connections/>
138 <connections/>
67 </ui>
139 </ui>
@@ -13,6 +13,9
13 <property name="windowTitle">
13 <property name="windowTitle">
14 <string>Form</string>
14 <string>Form</string>
15 </property>
15 </property>
16 <property name="toolTip">
17 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The spacewire plugin TCP server allows you to forward spacewire packets to any custom application, here you will configure the TCP connection and get some status information.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
18 </property>
16 <layout class="QVBoxLayout" name="verticalLayout">
19 <layout class="QVBoxLayout" name="verticalLayout">
17 <item>
20 <item>
18 <widget class="QGroupBox" name="configGroupBox">
21 <widget class="QGroupBox" name="configGroupBox">
@@ -45,7 +48,11
45 </widget>
48 </widget>
46 </item>
49 </item>
47 <item row="1" column="1">
50 <item row="1" column="1">
48 <widget class="QLineEdit" name="PortLineEdit"/>
51 <widget class="QLineEdit" name="PortLineEdit">
52 <property name="toolTip">
53 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set the port on which the server will listen and accept client connections.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
54 </property>
55 </widget>
49 </item>
56 </item>
50 <item row="2" column="1">
57 <item row="2" column="1">
51 <widget class="QPushButton" name="startServeQpb">
58 <widget class="QPushButton" name="startServeQpb">
@@ -37,7 +37,6 stardundeeSPW_USB::stardundeeSPW_USB(soc
37 stardundeeSPW_USB::~stardundeeSPW_USB()
37 stardundeeSPW_USB::~stardundeeSPW_USB()
38 {
38 {
39 this->manager->requestInterruption();
39 this->manager->requestInterruption();
40 delete this->p_GUI;
41 }
40 }
42
41
43 void stardundeeSPW_USB::toggleBridgeConnection()
42 void stardundeeSPW_USB::toggleBridgeConnection()
@@ -28,6 +28,11 abstractSpwBridge::abstractSpwBridge(soc
28 this->p_GUI=NULL;
28 this->p_GUI=NULL;
29 }
29 }
30
30
31 abstractSpwBridge::~abstractSpwBridge()
32 {
33 delete this->p_GUI;
34 }
35
31 QWidget *abstractSpwBridge::getGUI()
36 QWidget *abstractSpwBridge::getGUI()
32 {
37 {
33 return this->p_GUI;
38 return this->p_GUI;
@@ -32,6 +32,7 class abstractSpwBridge : public QObject
32 Q_OBJECT
32 Q_OBJECT
33 public:
33 public:
34 explicit abstractSpwBridge(socexplorerplugin *parent);
34 explicit abstractSpwBridge(socexplorerplugin *parent);
35 ~abstractSpwBridge();
35 QWidget *getGUI();
36 QWidget *getGUI();
36
37
37 public slots:
38 public slots:
@@ -4,7 +4,9
4 #-------------------------------------------------
4 #-------------------------------------------------
5
5
6 CONFIG += socexplorerplugin
6 CONFIG += socexplorerplugin
7 QT += network
7 QT += network webkit
8 greaterThan(QT_MAJOR_VERSION, 4): QT += webkitwidgets
9
8 win32:CONFIG += dll
10 win32:CONFIG += dll
9 win32:CONFIG -= static
11 win32:CONFIG -= static
10 CONFIG(debug, debug|release) {
12 CONFIG(debug, debug|release) {
General Comments 0
You need to be logged in to leave comments. Login now