##// END OF EJS Templates
Sync
Jeandet Alexis -
r24:f6b7bed80207 default
parent child
Show More
@@ -1,11 +1,15
1 1 #include "gr_esb_bridge.h"
2 2 #include "gr_esb_ui.h"
3 #include <unistd.h>
3 4
4 5 GR_ESB_bridge::GR_ESB_bridge(socexplorerplugin *parent) :
5 6 abstractSpwBridge(parent)
6 7 {
7 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 15 GR_ESB_bridge::~GR_ESB_bridge()
@@ -14,14 +18,66 GR_ESB_bridge::~GR_ESB_bridge()
14 18
15 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 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 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 3 #include "abstractspwbridge.h"
4 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 22 class GR_ESB_bridge : public abstractSpwBridge
7 23 {
8 24 Q_OBJECT
@@ -15,12 +31,19 signals:
15 31 public slots:
16 32 bool connectBridge();
17 33 bool disconnectBridge();
34 void setIP(QString ip);
35 void setVirtualLink(QString vlink);
36 void setVirtualLink(qint32 vlink);
18 37 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
19 38 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
20 39 int pushRMAPPacket(char* packet,int size);
21 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 1 #include "gr_esb_ui.h"
2 2 #include "ui_gr_esb_ui.h"
3 #include <QWebView>
3 4
4 5 GR_ESB_ui::GR_ESB_ui(QWidget *parent) :
5 6 QWidget(parent),
6 7 ui(new Ui::GR_ESB_ui)
7 8 {
8 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 14 public:
15 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 23 private:
19 24 Ui::GR_ESB_ui *ui;
20 25 };
@@ -13,35 +13,65
13 13 <property name="windowTitle">
14 14 <string>Form</string>
15 15 </property>
16 <layout class="QGridLayout" name="gridLayout">
17 <item row="1" column="2">
18 <widget class="QLineEdit" name="GRESB_Port_lineEdit"/>
16 <layout class="QVBoxLayout" name="verticalLayout">
17 <item>
18 <widget class="QTabWidget" name="tabWidget">
19 <property name="toolTip">
20 <string/>
21 </property>
22 <property name="currentIndex">
23 <number>0</number>
24 </property>
25 <widget class="QWidget" name="Config">
26 <property name="toolTip">
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>
28 </property>
29 <attribute name="title">
30 <string>Config</string>
31 </attribute>
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>
19 66 </item>
20 67 <item row="1" column="0">
21 <widget class="QLabel" name="GRESB_Port_Lbl">
68 <widget class="QLabel" name="GRESB_Vlink_Lbl">
22 69 <property name="text">
23 <string>GR-ESB Port</string>
70 <string>GR-ESB Virtual link</string>
24 71 </property>
25 72 </widget>
26 73 </item>
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>
35 </widget>
36 </item>
37 <item row="2" column="0">
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">
74 <item row="2" column="1">
45 75 <widget class="QComboBox" name="GRESB_LinkNum_CmBx">
46 76 <item>
47 77 <property name="text">
@@ -60,8 +90,50
60 90 </item>
61 91 </widget>
62 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>
63 110 </layout>
64 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>
115 </property>
116 <attribute name="title">
117 <string>Web</string>
118 </attribute>
119 <layout class="QHBoxLayout" name="horizontalLayout">
120 <item>
121 <widget class="QWebView" name="WebView" native="true"/>
122 </item>
123 </layout>
124 </widget>
125 </widget>
126 </item>
127 </layout>
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 137 <resources/>
66 138 <connections/>
67 139 </ui>
@@ -13,6 +13,9
13 13 <property name="windowTitle">
14 14 <string>Form</string>
15 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 19 <layout class="QVBoxLayout" name="verticalLayout">
17 20 <item>
18 21 <widget class="QGroupBox" name="configGroupBox">
@@ -45,7 +48,11
45 48 </widget>
46 49 </item>
47 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 56 </item>
50 57 <item row="2" column="1">
51 58 <widget class="QPushButton" name="startServeQpb">
@@ -37,7 +37,6 stardundeeSPW_USB::stardundeeSPW_USB(soc
37 37 stardundeeSPW_USB::~stardundeeSPW_USB()
38 38 {
39 39 this->manager->requestInterruption();
40 delete this->p_GUI;
41 40 }
42 41
43 42 void stardundeeSPW_USB::toggleBridgeConnection()
@@ -28,6 +28,11 abstractSpwBridge::abstractSpwBridge(soc
28 28 this->p_GUI=NULL;
29 29 }
30 30
31 abstractSpwBridge::~abstractSpwBridge()
32 {
33 delete this->p_GUI;
34 }
35
31 36 QWidget *abstractSpwBridge::getGUI()
32 37 {
33 38 return this->p_GUI;
@@ -32,6 +32,7 class abstractSpwBridge : public QObject
32 32 Q_OBJECT
33 33 public:
34 34 explicit abstractSpwBridge(socexplorerplugin *parent);
35 ~abstractSpwBridge();
35 36 QWidget *getGUI();
36 37
37 38 public slots:
@@ -4,7 +4,9
4 4 #-------------------------------------------------
5 5
6 6 CONFIG += socexplorerplugin
7 QT += network
7 QT += network webkit
8 greaterThan(QT_MAJOR_VERSION, 4): QT += webkitwidgets
9
8 10 win32:CONFIG += dll
9 11 win32:CONFIG -= static
10 12 CONFIG(debug, debug|release) {
General Comments 0
You need to be logged in to leave comments. Login now