##// END OF EJS Templates
Some work on GRESB driver for spwplugin.
Jeandet Alexis -
r25:8fdbbdd7a3a4 default
parent child
Show More
@@ -1,94 +1,202
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 #include <unistd.h>
4 #include "spw.h"
5 #include <socexplorerengine.h>
4
6
5 GR_ESB_bridge::GR_ESB_bridge(socexplorerplugin *parent) :
7 GR_ESB_bridge::GR_ESB_bridge(socexplorerplugin *parent) :
6 abstractSpwBridge(parent)
8 abstractSpwBridge(parent)
7 {
9 {
8 this->p_GUI = new GR_ESB_ui();
10 this->p_GUI = new GR_ESB_ui();
9 this->Read_soc = new QTcpSocket(this);
11 this->manager = new GR_ESB_Manager(parent,this);
10 this->Write_soc = new QTcpSocket(this);
12
11 connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(ipchanged(QString)),this,SLOT(setIP(QString)));
13 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)));
14 connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(vlinkchanged(QString)),this,SLOT(setVirtualLink(QString)));
15 connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection()));
16 this->manager->virtualLinkIndex = 0;
17 this->manager->start();
13 }
18 }
14
19
15 GR_ESB_bridge::~GR_ESB_bridge()
20 GR_ESB_bridge::~GR_ESB_bridge()
16 {
21 {
17 }
22 }
18
23
24 void GR_ESB_bridge::toggleBridgeConnection()
25 {
26 if(this->plugin->isConnected())
27 {
28 this->disconnectBridge();
29 }
30 else
31 {
32 this->connectBridge();
33 }
34 }
35
19 bool GR_ESB_bridge::connectBridge()
36 bool GR_ESB_bridge::connectBridge()
20 {
37 {
38 if(this->manager->connectBridge())
39 {
40 ((GR_ESB_ui*)this->p_GUI)->lock(true);
41 emit setConnected(true);
42 return true;
43 }
44 return false;
45 }
46
47 bool GR_ESB_bridge::disconnectBridge()
48 {
49 if(this->manager->disconnectBridge())
50 {
51 ((GR_ESB_ui*)this->p_GUI)->lock(false);
52 emit setConnected(false);
53 return true;
54 }
55 return false;
56 }
57
58 void GR_ESB_bridge::setIP(QString ip)
59 {
60 this->manager->IP = ip;
61 }
62
63 void GR_ESB_bridge::setVirtualLink(QString vlink)
64 {
65 vlink = vlink.section("Virtual link",0,0);
66 bool success;
67 int vlinkTmp = vlink.toInt(&success);
68 if(success)
69 {
70 setVirtualLink(vlinkTmp);
71 }
72 }
73
74 void GR_ESB_bridge::setVirtualLink(qint32 vlink)
75 {
76 if(vlink<6 && vlink>=0)
77 {
78 this->manager->virtualLinkIndex = vlink;
79 }
80 }
81
82
83 unsigned int GR_ESB_bridge::Write(unsigned int *Value, unsigned int count, unsigned int address)
84 {
85
86 }
87
88 unsigned int GR_ESB_bridge::Read(unsigned int *Value, unsigned int count, unsigned int address)
89 {
90
91 }
92
93 int GR_ESB_bridge::pushRMAPPacket(char *packet, int size)
94 {
95 return this->manager->sendPacket(packet,size);
96 }
97
98
99 GR_ESB_Manager::GR_ESB_Manager(socexplorerplugin *plugin, QObject *parent)
100 :QThread((QObject*)parent)
101 {
102 this->Read_soc = new QTcpSocket(this);
103 this->Write_soc = new QTcpSocket(this);
104 this->RMAPtimeout = 2000;
105 this->handleMutex = new QMutex(QMutex::NonRecursive);
106 this->RMAP_AnswersSem = new QSemaphore(0);
107 this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive);
108 this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive);
109 this->plugin = plugin;
110 connected = false;
111 this->moveToThread(this);
112 }
113
114 GR_ESB_Manager::~GR_ESB_Manager()
115 {
116
117 }
118
119 void GR_ESB_Manager::run()
120 {
121 SocExplorerEngine::message(this->plugin,"Starting GRESB pooling thread",1);
122 while (!this->isInterruptionRequested())
123 {
124 if(this->connected)
125 {
126 handleMutex->lock();
127 SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4);
128
129 }
130 else
131 {
132 //do some sanity checks!
133
134 usleep(RMAPtimeout/2);
135 }
136 usleep(1000);
137 }
138 SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1);
139 }
140
141 bool GR_ESB_Manager::connectBridge()
142 {
21 int timeout=60;
143 int timeout=60;
22 if(this->Read_soc->state()==QTcpSocket::UnconnectedState)
144 if(this->Read_soc->state()==QTcpSocket::UnconnectedState)
23 {
145 {
24 this->Read_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Read_port);
146 this->Read_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Read_port);
25 this->Read_soc->waitForConnected(30000);
147 this->Read_soc->waitForConnected(30000);
26 }
148 }
27 if(this->Write_soc->state()==QTcpSocket::UnconnectedState)
149 if(this->Write_soc->state()==QTcpSocket::UnconnectedState)
28 {
150 {
29 this->Write_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Write_port);
151 this->Write_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Write_port);
30 this->Write_soc->waitForConnected(30000);
152 this->Write_soc->waitForConnected(30000);
31 }
153 }
32 while((this->Read_soc->state()!=QTcpSocket::ConnectedState) && (this->Write_soc->state()!=QTcpSocket::ConnectedState))
154 while((this->Read_soc->state()!=QTcpSocket::ConnectedState) && (this->Write_soc->state()!=QTcpSocket::ConnectedState))
33 {
155 {
34 usleep(100000);
156 usleep(100000);
35 if(timeout--==0)return false;
157 if(timeout--==0)return false;
36 }
158 }
37 return true;
159 return true;
160
38 }
161 }
39
162
40 bool GR_ESB_bridge::disconnectBridge()
163 bool GR_ESB_Manager::disconnectBridge()
41 {
164 {
42 int timeout=60;
165 int timeout=60;
43 if(this->Read_soc->state()!=QTcpSocket::UnconnectedState)
166 if(this->Read_soc->state()!=QTcpSocket::UnconnectedState)
44 {
167 {
45 this->Read_soc->disconnectFromHost();
168 this->Read_soc->disconnectFromHost();
46 this->Read_soc->waitForDisconnected(30000);
169 this->Read_soc->waitForDisconnected(30000);
47 while(this->Read_soc->state()!=QTcpSocket::UnconnectedState)
170 }
48 {
171 if(this->Write_soc->state()!=QTcpSocket::UnconnectedState)
49 usleep(100000);
172 {
50 if(timeout--==0)return false;
173 this->Write_soc->disconnectFromHost();
51 }
174 this->Write_soc->waitForDisconnected(30000);
175 }
176 while((this->Read_soc->state()!=QTcpSocket::UnconnectedState) && (this->Write_soc->state()!=QTcpSocket::UnconnectedState))
177 {
178 usleep(100000);
179 if(timeout--==0)return false;
52 }
180 }
53 return true;
181 return true;
54 }
182 }
55
183
56 void GR_ESB_bridge::setIP(QString ip)
184 int GR_ESB_Manager::getRMAPtransactionID()
57 {
185 {
58 this->IP = ip;
186
59 }
187 }
60
188
61 void GR_ESB_bridge::setVirtualLink(QString vlink)
189 int GR_ESB_Manager::getRMAPanswer(int transactionID, char **buffer)
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
81 unsigned int GR_ESB_bridge::Write(unsigned int *Value, unsigned int count, unsigned int address)
82 {
190 {
83
191
84 }
192 }
85
193
86 unsigned int GR_ESB_bridge::Read(unsigned int *Value, unsigned int count, unsigned int address)
194 bool GR_ESB_Manager::sendPacket(char *packet, int size)
87 {
195 {
88
196
89 }
197 }
90
198
91 int GR_ESB_bridge::pushRMAPPacket(char *packet, int size)
199 void GR_ESB_Manager::pushRmapPacket(char *packet, int len)
92 {
200 {
93
201
94 }
202 }
@@ -1,50 +1,88
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>
6 #include <QMutex>
7 #include <QSemaphore>
5
8
6 struct gresb_Conf_str
9 struct gresb_Conf_str
7 {
10 {
8 qint32 Read_port;
11 qint32 Read_port;
9 qint32 Write_port;
12 qint32 Write_port;
10 };
13 };
11
14
15
12 const struct gresb_Conf_str gresb_Conf[]=
16 const struct gresb_Conf_str gresb_Conf[]=
13 {
17 {
14 {3000,3001}, //Virtual link 0
18 {3000,3001}, //Virtual link 0
15 {3002,3003}, //Virtual link 1
19 {3002,3003}, //Virtual link 1
16 {3004,3005}, //Virtual link 2
20 {3004,3005}, //Virtual link 2
17 {3006,3007}, //Virtual link 3
21 {3006,3007}, //Virtual link 3
18 {3008,3009}, //Virtual link 4
22 {3008,3009}, //Virtual link 4
19 {3010,3011} //Virtual link 5
23 {3010,3011} //Virtual link 5
20 };
24 };
21
25
26
27 class GR_ESB_Manager: public QThread
28 {
29 Q_OBJECT
30 public:
31 explicit GR_ESB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0);
32 ~GR_ESB_Manager();
33 void run();
34 bool connectBridge();
35 bool disconnectBridge();
36 int getRMAPtransactionID();
37 int getRMAPanswer(int transactionID,char** buffer);
38 bool sendPacket(char* packet,int size);
39
40 signals:
41 void emitPacket(char* packet,int size);
42 private:
43 QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx;
44 QSemaphore* RMAP_AnswersSem;
45 void pushRmapPacket(char* packet,int len);
46 socexplorerplugin* plugin;
47 bool connected;
48 char* SPWPacketBuff;
49 QList<RMAP_Answer*> RMAP_Answers;
50 QList<int> RMAP_pending_transaction_IDs;
51
52 public:
53 QTcpSocket* Read_soc;
54 QTcpSocket* Write_soc;
55 QString IP;
56 int virtualLinkIndex;
57 int RMAPtimeout;
58 };
59
60
22 class GR_ESB_bridge : public abstractSpwBridge
61 class GR_ESB_bridge : public abstractSpwBridge
23 {
62 {
24 Q_OBJECT
63 Q_OBJECT
25 public:
64 public:
26 explicit GR_ESB_bridge(socexplorerplugin *parent = 0);
65 explicit GR_ESB_bridge(socexplorerplugin *parent = 0);
27 ~GR_ESB_bridge();
66 ~GR_ESB_bridge();
28 signals:
67 signals:
29
68
30
69
31 public slots:
70 public slots:
71 void toggleBridgeConnection();
32 bool connectBridge();
72 bool connectBridge();
33 bool disconnectBridge();
73 bool disconnectBridge();
34 void setIP(QString ip);
74 void setIP(QString ip);
35 void setVirtualLink(QString vlink);
75 void setVirtualLink(QString vlink);
36 void setVirtualLink(qint32 vlink);
76 void setVirtualLink(qint32 vlink);
37 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
77 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
38 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
78 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
39 int pushRMAPPacket(char* packet,int size);
79 int pushRMAPPacket(char* packet,int size);
40 void packetReceived();
80 void packetReceived();
41
81
42 private:
82 private:
43 QTcpSocket* Read_soc;
83
44 QTcpSocket* Write_soc;
84 GR_ESB_Manager* manager;
45 QString IP;
46 int virtualLinkIndex;
47
85
48 };
86 };
49
87
50 #endif // GR_ESB_BRIDGE_H
88 #endif // GR_ESB_BRIDGE_H
@@ -1,19 +1,31
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 #include <QWebView>
4
4
5 GR_ESB_ui::GR_ESB_ui(QWidget *parent) :
5 GR_ESB_ui::GR_ESB_ui(QWidget *parent) :
6 QWidget(parent),
6 QWidget(parent),
7 ui(new Ui::GR_ESB_ui)
7 ui(new Ui::GR_ESB_ui)
8 {
8 {
9 ui->setupUi(this);
9 ui->setupUi(this);
10 connect(this->ui->GRESB_IP_lineEdit,SIGNAL(textChanged(QString)),this,SLOT(changeIp(QString)));
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)));
11 connect(this->ui->GRESB_Vlink_CmBx,SIGNAL(currentIndexChanged(QString)),this,SIGNAL(vlinkchanged(QString)));
12 connect(this->ui->connectQpb,SIGNAL(clicked()),this,SIGNAL(connectClicked()));
12 }
13 }
13
14
14 void GR_ESB_ui::changeIp(QString ip)
15 void GR_ESB_ui::changeIp(QString ip)
15 {
16 {
16 this->ui->WebView->load(QUrl("http://"+ip));
17 this->ui->WebView->load(QUrl("http://"+ip));
17 emit this->ipchanged(ip);
18 emit this->ipchanged(ip);
18 }
19 }
19
20
21 void GR_ESB_ui::lock(bool lock)
22 {
23 this->ui->GRESB_IP_lineEdit->setDisabled(lock);
24 this->ui->GRESB_LinkNum_CmBx->setDisabled(lock);
25 this->ui->GRESB_Vlink_CmBx->setDisabled(lock);
26 if(lock)
27 this->ui->connectQpb->setText("Disconnect");
28 else
29 this->ui->connectQpb->setText("Connect");
30 }
31
@@ -1,27 +1,28
1 #ifndef GR_ESB_UI_H
1 #ifndef GR_ESB_UI_H
2 #define GR_ESB_UI_H
2 #define GR_ESB_UI_H
3
3
4 #include <QWidget>
4 #include <QWidget>
5
5
6 namespace Ui {
6 namespace Ui {
7 class GR_ESB_ui;
7 class GR_ESB_ui;
8 }
8 }
9
9
10 class GR_ESB_ui : public QWidget
10 class GR_ESB_ui : public QWidget
11 {
11 {
12 Q_OBJECT
12 Q_OBJECT
13
13
14 public:
14 public:
15 explicit GR_ESB_ui(QWidget *parent = 0);
15 explicit GR_ESB_ui(QWidget *parent = 0);
16
16
17 public slots:
17 public slots:
18 void changeIp(QString ip);
18 void changeIp(QString ip);
19
19 void lock(bool lock);
20 signals:
20 signals:
21 void ipchanged(QString ip);
21 void ipchanged(QString ip);
22 void vlinkchanged(QString vlink);
22 void vlinkchanged(QString vlink);
23 void connectClicked();
23 private:
24 private:
24 Ui::GR_ESB_ui *ui;
25 Ui::GR_ESB_ui *ui;
25 };
26 };
26
27
27 #endif // GR_ESB_UI_H
28 #endif // GR_ESB_UI_H
@@ -1,139 +1,146
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
2 <ui version="4.0">
3 <class>GR_ESB_ui</class>
3 <class>GR_ESB_ui</class>
4 <widget class="QWidget" name="GR_ESB_ui">
4 <widget class="QWidget" name="GR_ESB_ui">
5 <property name="geometry">
5 <property name="geometry">
6 <rect>
6 <rect>
7 <x>0</x>
7 <x>0</x>
8 <y>0</y>
8 <y>0</y>
9 <width>489</width>
9 <width>968</width>
10 <height>295</height>
10 <height>392</height>
11 </rect>
11 </rect>
12 </property>
12 </property>
13 <property name="windowTitle">
13 <property name="windowTitle">
14 <string>Form</string>
14 <string>Form</string>
15 </property>
15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout">
16 <layout class="QVBoxLayout" name="verticalLayout">
17 <item>
17 <item>
18 <widget class="QTabWidget" name="tabWidget">
18 <widget class="QTabWidget" name="tabWidget">
19 <property name="toolTip">
19 <property name="toolTip">
20 <string/>
20 <string/>
21 </property>
21 </property>
22 <property name="currentIndex">
22 <property name="currentIndex">
23 <number>0</number>
23 <number>0</number>
24 </property>
24 </property>
25 <widget class="QWidget" name="Config">
25 <widget class="QWidget" name="Config">
26 <property name="toolTip">
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>
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>
28 </property>
29 <attribute name="title">
29 <attribute name="title">
30 <string>Config</string>
30 <string>Config</string>
31 </attribute>
31 </attribute>
32 <layout class="QGridLayout" name="gridLayout_2">
32 <layout class="QGridLayout" name="gridLayout_2">
33 <item row="1" column="1">
33 <item row="1" column="1">
34 <widget class="QComboBox" name="GRESB_Vlink_CmBx">
34 <widget class="QComboBox" name="GRESB_Vlink_CmBx">
35 <item>
35 <item>
36 <property name="text">
36 <property name="text">
37 <string>Virtual link 0</string>
37 <string>Virtual link 0</string>
38 </property>
38 </property>
39 </item>
39 </item>
40 <item>
40 <item>
41 <property name="text">
41 <property name="text">
42 <string>Virtual link 1</string>
42 <string>Virtual link 1</string>
43 </property>
43 </property>
44 </item>
44 </item>
45 <item>
45 <item>
46 <property name="text">
46 <property name="text">
47 <string>Virtual link 2</string>
47 <string>Virtual link 2</string>
48 </property>
48 </property>
49 </item>
49 </item>
50 <item>
50 <item>
51 <property name="text">
51 <property name="text">
52 <string>Virtual link 3</string>
52 <string>Virtual link 3</string>
53 </property>
53 </property>
54 </item>
54 </item>
55 <item>
55 <item>
56 <property name="text">
56 <property name="text">
57 <string>Virtual link 4</string>
57 <string>Virtual link 4</string>
58 </property>
58 </property>
59 </item>
59 </item>
60 <item>
60 <item>
61 <property name="text">
61 <property name="text">
62 <string>Virtual link 5</string>
62 <string>Virtual link 5</string>
63 </property>
63 </property>
64 </item>
64 </item>
65 </widget>
65 </widget>
66 </item>
66 </item>
67 <item row="1" column="0">
67 <item row="1" column="0">
68 <widget class="QLabel" name="GRESB_Vlink_Lbl">
68 <widget class="QLabel" name="GRESB_Vlink_Lbl">
69 <property name="text">
69 <property name="text">
70 <string>GR-ESB Virtual link</string>
70 <string>GR-ESB Virtual link</string>
71 </property>
71 </property>
72 </widget>
72 </widget>
73 </item>
73 </item>
74 <item row="2" column="1">
74 <item row="2" column="1">
75 <widget class="QComboBox" name="GRESB_LinkNum_CmBx">
75 <widget class="QComboBox" name="GRESB_LinkNum_CmBx">
76 <item>
76 <item>
77 <property name="text">
77 <property name="text">
78 <string>SPW0</string>
78 <string>SPW0</string>
79 </property>
79 </property>
80 </item>
80 </item>
81 <item>
81 <item>
82 <property name="text">
82 <property name="text">
83 <string>SPW1</string>
83 <string>SPW1</string>
84 </property>
84 </property>
85 </item>
85 </item>
86 <item>
86 <item>
87 <property name="text">
87 <property name="text">
88 <string>SPW2</string>
88 <string>SPW2</string>
89 </property>
89 </property>
90 </item>
90 </item>
91 </widget>
91 </widget>
92 </item>
92 </item>
93 <item row="0" column="1">
93 <item row="0" column="1">
94 <widget class="QLineEdit" name="GRESB_IP_lineEdit"/>
94 <widget class="QLineEdit" name="GRESB_IP_lineEdit"/>
95 </item>
95 </item>
96 <item row="2" column="0">
96 <item row="2" column="0">
97 <widget class="QLabel" name="GRESB_LinkNum_Lbl">
97 <widget class="QLabel" name="GRESB_LinkNum_Lbl">
98 <property name="text">
98 <property name="text">
99 <string>Select link number</string>
99 <string>Select link number</string>
100 </property>
100 </property>
101 </widget>
101 </widget>
102 </item>
102 </item>
103 <item row="0" column="0">
103 <item row="0" column="0">
104 <widget class="QLabel" name="GRESB_IP_Lbl">
104 <widget class="QLabel" name="GRESB_IP_Lbl">
105 <property name="text">
105 <property name="text">
106 <string>GR-ESB IP Address</string>
106 <string>GR-ESB IP Address</string>
107 </property>
107 </property>
108 </widget>
108 </widget>
109 </item>
109 </item>
110 <item row="3" column="0" colspan="2">
111 <widget class="QPushButton" name="connectQpb">
112 <property name="text">
113 <string>Connect</string>
114 </property>
115 </widget>
116 </item>
110 </layout>
117 </layout>
111 </widget>
118 </widget>
112 <widget class="QWidget" name="Web">
119 <widget class="QWidget" name="Web">
113 <property name="toolTip">
120 <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>
121 <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>
122 </property>
116 <attribute name="title">
123 <attribute name="title">
117 <string>Web</string>
124 <string>Web</string>
118 </attribute>
125 </attribute>
119 <layout class="QHBoxLayout" name="horizontalLayout">
126 <layout class="QHBoxLayout" name="horizontalLayout">
120 <item>
127 <item>
121 <widget class="QWebView" name="WebView" native="true"/>
128 <widget class="QWebView" name="WebView" native="true"/>
122 </item>
129 </item>
123 </layout>
130 </layout>
124 </widget>
131 </widget>
125 </widget>
132 </widget>
126 </item>
133 </item>
127 </layout>
134 </layout>
128 </widget>
135 </widget>
129 <customwidgets>
136 <customwidgets>
130 <customwidget>
137 <customwidget>
131 <class>QWebView</class>
138 <class>QWebView</class>
132 <extends>QWidget</extends>
139 <extends>QWidget</extends>
133 <header location="global">QWebView</header>
140 <header location="global">QWebView</header>
134 <container>1</container>
141 <container>1</container>
135 </customwidget>
142 </customwidget>
136 </customwidgets>
143 </customwidgets>
137 <resources/>
144 <resources/>
138 <connections/>
145 <connections/>
139 </ui>
146 </ui>
@@ -1,86 +1,115
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
2 <ui version="4.0">
3 <class>SpwTcpPacketServer</class>
3 <class>SpwTcpPacketServer</class>
4 <widget class="QWidget" name="SpwTcpPacketServer">
4 <widget class="QWidget" name="SpwTcpPacketServer">
5 <property name="geometry">
5 <property name="geometry">
6 <rect>
6 <rect>
7 <x>0</x>
7 <x>0</x>
8 <y>0</y>
8 <y>0</y>
9 <width>671</width>
9 <width>726</width>
10 <height>409</height>
10 <height>535</height>
11 </rect>
11 </rect>
12 </property>
12 </property>
13 <property name="windowTitle">
13 <property name="windowTitle">
14 <string>Form</string>
14 <string>Form</string>
15 </property>
15 </property>
16 <property name="toolTip">
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>
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>
18 </property>
19 <layout class="QVBoxLayout" name="verticalLayout">
19 <layout class="QVBoxLayout" name="verticalLayout">
20 <item>
20 <item>
21 <widget class="QGroupBox" name="configGroupBox">
21 <widget class="QGroupBox" name="configGroupBox">
22 <property name="title">
22 <property name="title">
23 <string>Configuration</string>
23 <string>Configuration</string>
24 </property>
24 </property>
25 <layout class="QFormLayout" name="formLayout_2">
25 <layout class="QFormLayout" name="formLayout_2">
26 <item row="0" column="0">
26 <item row="0" column="0">
27 <widget class="QLabel" name="IPLbl">
27 <widget class="QLabel" name="IPLbl">
28 <property name="text">
28 <property name="text">
29 <string>Server IP</string>
29 <string>Server IP</string>
30 </property>
30 </property>
31 </widget>
31 </widget>
32 </item>
32 </item>
33 <item row="0" column="1">
33 <item row="0" column="1">
34 <widget class="QLineEdit" name="IPLineEdit">
34 <widget class="QLineEdit" name="IPLineEdit">
35 <property name="maxLength">
35 <property name="maxLength">
36 <number>15</number>
36 <number>15</number>
37 </property>
37 </property>
38 <property name="readOnly">
38 <property name="readOnly">
39 <bool>true</bool>
39 <bool>true</bool>
40 </property>
40 </property>
41 </widget>
41 </widget>
42 </item>
42 </item>
43 <item row="1" column="0">
43 <item row="1" column="0">
44 <widget class="QLabel" name="PortLbl">
44 <widget class="QLabel" name="PortLbl">
45 <property name="text">
45 <property name="text">
46 <string>Server Port</string>
46 <string>Server Port</string>
47 </property>
47 </property>
48 </widget>
48 </widget>
49 </item>
49 </item>
50 <item row="1" column="1">
50 <item row="1" column="1">
51 <widget class="QLineEdit" name="PortLineEdit">
51 <widget class="QLineEdit" name="PortLineEdit">
52 <property name="toolTip">
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>
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>
54 </property>
55 </widget>
55 </widget>
56 </item>
56 </item>
57 <item row="2" column="1">
57 <item row="2" column="1">
58 <widget class="QPushButton" name="startServeQpb">
58 <widget class="QPushButton" name="startServeQpb">
59 <property name="text">
59 <property name="text">
60 <string>Start Server</string>
60 <string>Start Server</string>
61 </property>
61 </property>
62 </widget>
62 </widget>
63 </item>
63 </item>
64 </layout>
64 </layout>
65 </widget>
65 </widget>
66 </item>
66 </item>
67 <item>
67 <item>
68 <widget class="QGroupBox" name="clientListGroupBox_2">
68 <widget class="QGroupBox" name="groupBox">
69 <property name="title">
69 <property name="title">
70 <string>Connected clients</string>
70 <string>Server Statistics</string>
71 </property>
71 </property>
72 <property name="flat">
72 <layout class="QGridLayout" name="gridLayout">
73 <bool>false</bool>
73 <item row="2" column="0" colspan="2">
74 </property>
74 <widget class="QGroupBox" name="clientListGroupBox_2">
75 <layout class="QVBoxLayout" name="verticalLayout_2">
75 <property name="title">
76 <item>
76 <string>Connected clients</string>
77 <widget class="QListWidget" name="listWidget"/>
77 </property>
78 <property name="flat">
79 <bool>false</bool>
80 </property>
81 <layout class="QVBoxLayout" name="verticalLayout_2">
82 <item>
83 <widget class="QListWidget" name="listWidget"/>
84 </item>
85 </layout>
86 </widget>
87 </item>
88 <item row="0" column="1">
89 <widget class="QLCDNumber" name="lcdNumber"/>
90 </item>
91 <item row="0" column="0">
92 <widget class="QLabel" name="label">
93 <property name="text">
94 <string>Sended Packets</string>
95 </property>
96 </widget>
97 </item>
98 <item row="1" column="0">
99 <widget class="QLabel" name="label_2">
100 <property name="text">
101 <string>Received Packets</string>
102 </property>
103 </widget>
104 </item>
105 <item row="1" column="1">
106 <widget class="QLCDNumber" name="lcdNumber_2"/>
78 </item>
107 </item>
79 </layout>
108 </layout>
80 </widget>
109 </widget>
81 </item>
110 </item>
82 </layout>
111 </layout>
83 </widget>
112 </widget>
84 <resources/>
113 <resources/>
85 <connections/>
114 <connections/>
86 </ui>
115 </ui>
@@ -1,128 +1,116
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #ifndef STARDUNDEESPW_USB_H
22 #ifndef STARDUNDEESPW_USB_H
23 #define STARDUNDEESPW_USB_H
23 #define STARDUNDEESPW_USB_H
24
24
25 #include <QObject>
25 #include <QObject>
26 #include <spw_usb_api.h>
26 #include <spw_usb_api.h>
27 #include <spw_config_library.h>
27 #include <spw_config_library.h>
28 #include <socexplorerplugin.h>
28 #include <socexplorerplugin.h>
29 #include <abstractspwbridge.h>
29 #include <abstractspwbridge.h>
30 #include <QThread>
30 #include <QThread>
31 #include <QMutex>
31 #include <QMutex>
32 #include <QSemaphore>
32 #include <QSemaphore>
33 #include <QGridLayout>
33 #include <QGridLayout>
34 #include <QPushButton>
34 #include <QPushButton>
35 #include <QComboBox>
35 #include <QComboBox>
36 #include <QLabel>
36 #include <QLabel>
37 #include "stardundeegui.h"
37 #include "stardundeegui.h"
38
38
39 class RMAP_Answer
39
40 {
41 public:
42 RMAP_Answer(int ID,char* data,int len)
43 {
44 transactionID = ID;
45 this->data = data;
46 this->len = len;
47 }
48 int transactionID;
49 char* data;
50 int len;
51 };
52
40
53 class stardundeeSPW_USB_Manager: public QThread
41 class stardundeeSPW_USB_Manager: public QThread
54 {
42 {
55 Q_OBJECT
43 Q_OBJECT
56 public:
44 public:
57 explicit stardundeeSPW_USB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0);
45 explicit stardundeeSPW_USB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0);
58 ~stardundeeSPW_USB_Manager();
46 ~stardundeeSPW_USB_Manager();
59 void run();
47 void run();
60 bool connectBridge();
48 bool connectBridge();
61 bool disconnectBridge();
49 bool disconnectBridge();
62 int getRMAPtransactionID();
50 int getRMAPtransactionID();
63 int getRMAPanswer(int transactionID,char** buffer);
51 int getRMAPanswer(int transactionID,char** buffer);
64 bool sendPacket(char* packet,int size);
52 bool sendPacket(char* packet,int size);
65
53
66 signals:
54 signals:
67 void updateAvailableBrickCount(int count);
55 void updateAvailableBrickCount(int count);
68 void emitPacket(char* packet,int size);
56 void emitPacket(char* packet,int size);
69 private:
57 private:
70 QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx;
58 QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx;
71 QSemaphore* RMAP_AnswersSem;
59 QSemaphore* RMAP_AnswersSem;
72 void pushRmapPacket(char* packet,int len);
60 void pushRmapPacket(char* packet,int len);
73 star_device_handle hDevice;
61 star_device_handle hDevice;
74 socexplorerplugin* plugin;
62 socexplorerplugin* plugin;
75 bool connected;
63 bool connected;
76 char* SPWPacketBuff;
64 char* SPWPacketBuff;
77 QList<RMAP_Answer*> RMAP_Answers;
65 QList<RMAP_Answer*> RMAP_Answers;
78 QList<int> RMAP_pending_transaction_IDs;
66 QList<int> RMAP_pending_transaction_IDs;
79
67
80 public:
68 public:
81 int selectedBrick;
69 int selectedBrick;
82 int linkNumber;
70 int linkNumber;
83 int brickList;
71 int brickList;
84 int linkSpeed;
72 int linkSpeed;
85 int destinationKey;
73 int destinationKey;
86 int rmapAddress;
74 int rmapAddress;
87 int rmapKey;
75 int rmapKey;
88 int RMAPtimeout;
76 int RMAPtimeout;
89 };
77 };
90
78
91 class stardundeeSPW_USB : public abstractSpwBridge
79 class stardundeeSPW_USB : public abstractSpwBridge
92 {
80 {
93 Q_OBJECT
81 Q_OBJECT
94 public:
82 public:
95 explicit stardundeeSPW_USB(socexplorerplugin *parent = 0);
83 explicit stardundeeSPW_USB(socexplorerplugin *parent = 0);
96 ~stardundeeSPW_USB();
84 ~stardundeeSPW_USB();
97
85
98 signals:
86 signals:
99
87
100 void setRmapTimeout(const QString & timeout);
88 void setRmapTimeout(const QString & timeout);
101 void SelectBrick(int brickIndex);
89 void SelectBrick(int brickIndex);
102 void SelectLinkNumber(int linkIndex);
90 void SelectLinkNumber(int linkIndex);
103 void SelectLinkSpeed(int linkSpeed);
91 void SelectLinkSpeed(int linkSpeed);
104 void SetDestinationKey(const QString & destKey);
92 void SetDestinationKey(const QString & destKey);
105 void SetRmapAddress(const QString & address);
93 void SetRmapAddress(const QString & address);
106 void SetRmapKey(const QString & key);
94 void SetRmapKey(const QString & key);
107 void SetRmapTimeout(const QString & timeout);
95 void SetRmapTimeout(const QString & timeout);
108
96
109 public slots:
97 public slots:
110 void toggleBridgeConnection();
98 void toggleBridgeConnection();
111 bool connectBridge();
99 bool connectBridge();
112 bool disconnectBridge();
100 bool disconnectBridge();
113 int pushRMAPPacket(char* packet,int size);
101 int pushRMAPPacket(char* packet,int size);
114 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
102 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
115 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
103 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
116 void brickSelectionChanged(int brickIndex);
104 void brickSelectionChanged(int brickIndex);
117 void linkNumberSelectionChanged(int linkIndex);
105 void linkNumberSelectionChanged(int linkIndex);
118 void linkSpeedSelectionChanged(const QString & linkSpeed);
106 void linkSpeedSelectionChanged(const QString & linkSpeed);
119 void destinationKeyChanged(const QString & destKey);
107 void destinationKeyChanged(const QString & destKey);
120 void rmapAddressChanged(const QString & rmapaddress);
108 void rmapAddressChanged(const QString & rmapaddress);
121 void rmapKeyChanged(const QString & key);
109 void rmapKeyChanged(const QString & key);
122 void rmapTimeoutChanged(const QString & timeout);
110 void rmapTimeoutChanged(const QString & timeout);
123 private:
111 private:
124 void makeGUI(socexplorerplugin *parent);
112 void makeGUI(socexplorerplugin *parent);
125 stardundeeSPW_USB_Manager* manager;
113 stardundeeSPW_USB_Manager* manager;
126 };
114 };
127
115
128 #endif // STARDUNDEESPW_USB_H
116 #endif // STARDUNDEESPW_USB_H
@@ -1,54 +1,68
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #ifndef ABSTRACTSPWBRIDGE_H
22 #ifndef ABSTRACTSPWBRIDGE_H
23 #define ABSTRACTSPWBRIDGE_H
23 #define ABSTRACTSPWBRIDGE_H
24
24
25 #include <QObject>
25 #include <QObject>
26 #include <socexplorerplugin.h>
26 #include <socexplorerplugin.h>
27 #define RMAP_MAX_XFER_SIZE 4000 //slightly less than 16kBytes
27 #define RMAP_MAX_XFER_SIZE 4000 //slightly less than 16kBytes
28 #include <spw.h>
28 #include <spw.h>
29
29
30 class RMAP_Answer
31 {
32 public:
33 RMAP_Answer(int ID,char* data,int len)
34 {
35 transactionID = ID;
36 this->data = data;
37 this->len = len;
38 }
39 int transactionID;
40 char* data;
41 int len;
42 };
43
30 class abstractSpwBridge : public QObject
44 class abstractSpwBridge : public QObject
31 {
45 {
32 Q_OBJECT
46 Q_OBJECT
33 public:
47 public:
34 explicit abstractSpwBridge(socexplorerplugin *parent);
48 explicit abstractSpwBridge(socexplorerplugin *parent);
35 ~abstractSpwBridge();
49 ~abstractSpwBridge();
36 QWidget *getGUI();
50 QWidget *getGUI();
37
51
38 public slots:
52 public slots:
39 virtual bool connectBridge();
53 virtual bool connectBridge();
40 virtual bool disconnectBridge();
54 virtual bool disconnectBridge();
41 virtual unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0)=0;
55 virtual unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0)=0;
42 virtual unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0)=0;
56 virtual unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0)=0;
43 virtual int pushRMAPPacket(char* packet,int size)=0;
57 virtual int pushRMAPPacket(char* packet,int size)=0;
44 signals:
58 signals:
45 void setConnected(bool connected);
59 void setConnected(bool connected);
46 void pushPacketOverTCP(char* packet,int size);
60 void pushPacketOverTCP(char* packet,int size);
47 protected:
61 protected:
48 socexplorerplugin* plugin;
62 socexplorerplugin* plugin;
49 QWidget* p_GUI;
63 QWidget* p_GUI;
50 private:
64 private:
51
65
52 };
66 };
53
67
54 #endif // ABSTRACTSPWBRIDGE_H
68 #endif // ABSTRACTSPWBRIDGE_H
@@ -1,165 +1,166
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22
22
23 #include "spwplugin.h"
23 #include "spwplugin.h"
24 #include "stardundeespw_usb.h"
24 #include "stardundeespw_usb.h"
25 #include "gr_esb_bridge.h"
25 #include "gr_esb_bridge.h"
26 #include <socexplorerproxy.h>
26 #include <socexplorerproxy.h>
27 #include "spwpywrapper.h"
27 #include "spwpywrapper.h"
28
28
29
29 spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false)
30 spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false)
30 {
31 {
31 Q_UNUSED(parent)
32 Q_UNUSED(parent)
32 this->bridge = NULL;
33 this->bridge = NULL;
33 this->scanDone = false;
34 this->scanDone = false;
34 this->pyObject = new spwPyWrapper(this);
35 this->pyObject = new spwPyWrapper(this);
35 this->tcpServer = new SpwTcpPacketServer(this);
36 this->tcpServer = new SpwTcpPacketServer(this);
36 this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this);
37 this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this);
37 this->bridgeSelector = new QComboBox(this);
38 this->bridgeSelector = new QComboBox(this);
38 this->mainTabWidgt = new QTabWidget(this);
39 this->mainTabWidgt = new QTabWidget(this);
39 this->mainTabWidgt->addTab(this->mainGroupBox,"Bridge Configuration");
40 this->mainTabWidgt->addTab(this->mainGroupBox,"Bridge Configuration");
40 this->mainTabWidgt->addTab(this->tcpServer,"TCP Server");
41 this->mainTabWidgt->addTab(this->tcpServer,"TCP Server");
41 this->mainLayout = new QGridLayout(this->mainGroupBox);
42 this->mainLayout = new QGridLayout(this->mainGroupBox);
42 this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter);
43 this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter);
43 this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1);
44 this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1);
44 this->setWidget(this->mainTabWidgt);
45 this->setWidget(this->mainTabWidgt);
45 this->bridgeSelector->addItem("none");
46 this->bridgeSelector->addItem("none");
46 this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick");
47 this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick");
47 this->bridgeSelector->addItem("GR-ESB");
48 this->bridgeSelector->addItem("GR-ESB");
48 connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString)));
49 connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString)));
49 connect(((spwPyWrapper*)this->pyObject),SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString)));
50 connect(((spwPyWrapper*)this->pyObject),SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString)));
50 connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerConnect()),this->tcpServer,SLOT(connectServer()));
51 connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerConnect()),this->tcpServer,SLOT(connectServer()));
51 connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerDisconnect()),this->tcpServer,SLOT(disconnectServer()));
52 connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerDisconnect()),this->tcpServer,SLOT(disconnectServer()));
52 connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerSetPort(qint32)),this->tcpServer,SLOT(setServerPort(qint32)));
53 connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerSetPort(qint32)),this->tcpServer,SLOT(setServerPort(qint32)));
53 connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerSetIP(QString)),this->tcpServer,SLOT(setServerSetIP(QString)));
54 connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerSetIP(QString)),this->tcpServer,SLOT(setServerSetIP(QString)));
54 }
55 }
55
56
56
57
57 spwplugin::~spwplugin()
58 spwplugin::~spwplugin()
58 {
59 {
59
60
60 }
61 }
61
62
62
63
63
64
64 unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address)
65 unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address)
65 {
66 {
66 if(Connected)
67 if(Connected)
67 {
68 {
68 return bridge->Read(Value,count,address);
69 return bridge->Read(Value,count,address);
69 }
70 }
70 return 0;
71 return 0;
71 }
72 }
72
73
73 void spwplugin::bridgeSelectionChanged(const QString &text)
74 void spwplugin::bridgeSelectionChanged(const QString &text)
74 {
75 {
75 printf("test");
76 printf("test");
76 if(text=="none")
77 if(text=="none")
77 {
78 {
78 if(this->bridge!=NULL)
79 if(this->bridge!=NULL)
79 {
80 {
80 this->mainLayout->removeWidget(this->bridge->getGUI());
81 this->mainLayout->removeWidget(this->bridge->getGUI());
81 this->disconnect(this,SLOT(setConnected(bool)));
82 this->disconnect(this,SLOT(setConnected(bool)));
82 delete this->bridge;
83 delete this->bridge;
83 this->bridge= NULL;
84 this->bridge= NULL;
84 }
85 }
85 }
86 }
86 if(text=="STAR-Dundee Spw USB Brick")
87 if(text=="STAR-Dundee Spw USB Brick")
87 {
88 {
88 if(this->bridge!=NULL)
89 if(this->bridge!=NULL)
89 {
90 {
90 this->mainLayout->removeWidget(this->bridge->getGUI());
91 this->mainLayout->removeWidget(this->bridge->getGUI());
91 this->disconnect(this,SLOT(setConnected(bool)));
92 this->disconnect(this,SLOT(setConnected(bool)));
92 delete this->bridge;
93 delete this->bridge;
93 }
94 }
94 this->bridge = new stardundeeSPW_USB(this);
95 this->bridge = new stardundeeSPW_USB(this);
95 this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2);
96 this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2);
96 connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool)));
97 connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool)));
97 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int)));
98 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int)));
98 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int)));
99 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int)));
99 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int)));
100 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int)));
100 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString)));
101 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString)));
101 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapAddress(QString)));
102 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapAddress(QString)));
102 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapKey(QString)));
103 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapKey(QString)));
103 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString)));
104 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString)));
104 connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge()));
105 connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge()));
105 connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge()));
106 connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge()));
106 connect(this->bridge,SIGNAL(pushPacketOverTCP(char*,int)),this->tcpServer,SLOT(pushPacket(char*,int)));
107 connect(this->bridge,SIGNAL(pushPacketOverTCP(char*,int)),this->tcpServer,SLOT(pushPacket(char*,int)));
107 }
108 }
108 if(text=="GR-ESB")
109 if(text=="GR-ESB")
109 {
110 {
110 if(this->bridge!=NULL)
111 if(this->bridge!=NULL)
111 {
112 {
112 this->mainLayout->removeWidget(this->bridge->getGUI());
113 this->mainLayout->removeWidget(this->bridge->getGUI());
113 this->disconnect(this,SLOT(setConnected(bool)));
114 this->disconnect(this,SLOT(setConnected(bool)));
114 delete this->bridge;
115 delete this->bridge;
115 }
116 }
116 this->bridge = new GR_ESB_bridge(this);
117 this->bridge = new GR_ESB_bridge(this);
117 this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2);
118 this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2);
118 connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool)));
119 connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool)));
119 }
120 }
120 }
121 }
121
122
122
123
123 void spwplugin::selectBridge(const QString &text)
124 void spwplugin::selectBridge(const QString &text)
124 {
125 {
125
126
126 if(text=="none")
127 if(text=="none")
127 {
128 {
128 this->bridgeSelector->setCurrentIndex(0);
129 this->bridgeSelector->setCurrentIndex(0);
129 }
130 }
130 if(text=="STAR-Dundee Spw USB Brick")
131 if(text=="STAR-Dundee Spw USB Brick")
131 {
132 {
132 this->bridgeSelector->setCurrentIndex(1);
133 this->bridgeSelector->setCurrentIndex(1);
133 }
134 }
134 }
135 }
135
136
136 void spwplugin::setConnected(bool connected)
137 void spwplugin::setConnected(bool connected)
137 {
138 {
138 this->bridgeSelector->setDisabled(connected);
139 this->bridgeSelector->setDisabled(connected);
139 this->Connected = connected;
140 this->Connected = connected;
140 emit activateSig(connected);
141 emit activateSig(connected);
141 if(!this->scanDone)
142 if(!this->scanDone)
142 {
143 {
143 socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN");
144 socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN");
144 this->scanDone=true;
145 this->scanDone=true;
145 }
146 }
146 }
147 }
147
148
148
149
149
150
150 unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address)
151 unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address)
151 {
152 {
152 if(Connected)
153 if(Connected)
153 {
154 {
154 return bridge->Write(Value,count,address);
155 return bridge->Write(Value,count,address);
155 }
156 }
156 return 0;
157 return 0;
157 }
158 }
158
159
159
160
160
161
161
162
162
163
163
164
164
165
165
166
@@ -1,76 +1,79
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #ifndef spwplugin_H
22 #ifndef spwplugin_H
23 #define spwplugin_H
23 #define spwplugin_H
24 #include <QMenuBar>
24 #include <QMenuBar>
25 #include <QMenu>
25 #include <QMenu>
26 #include <QAction>
26 #include <QAction>
27 #include <QLayout>
27 #include <QLayout>
28 #include <QGroupBox>
28 #include <QGroupBox>
29 #include <QComboBox>
29 #include <QComboBox>
30 #include <QLabel>
30 #include <QLabel>
31 #include <QTabWidget>
31 #include <QTabWidget>
32
32
33 #include <abstractspwbridge.h>
33 #include <abstractspwbridge.h>
34 #include <socexplorerplugin.h>
34 #include <socexplorerplugin.h>
35
35
36 #include "SpwTcpPacketServer/spwtcppacketserver.h"
36 #include "SpwTcpPacketServer/spwtcppacketserver.h"
37
37
38 // TODO switch to a class factory approach with self registration
39
38 class spwplugin : public socexplorerplugin
40 class spwplugin : public socexplorerplugin
39 {
41 {
40 Q_OBJECT
42 Q_OBJECT
41 public:
43 public:
42 explicit spwplugin(QWidget *parent = 0);
44 explicit spwplugin(QWidget *parent = 0);
43 ~spwplugin();
45 ~spwplugin();
44 /* You can implement the folowing function if you want to overwrite
46 /* You can implement the folowing function if you want to overwrite
45 * their default behavior
47 * their default behavior
46 */
48 */
47 /*
49 /*
48 int registermenu(QMainWindow *menuHolder);
50 int registermenu(QMainWindow *menuHolder);
49 int isConnected();
51 int isConnected();
50 int connect();
52 int connect();
51 int VID(){return driver_VID;}
53 int VID(){return driver_VID;}
52 int PID(){return driver_PID;}
54 int PID(){return driver_PID;}
53 */
55 */
54
56
55 public slots:
57 public slots:
56 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
58 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
57 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
59 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
58
60
59 void bridgeSelectionChanged( const QString & text );
61 void bridgeSelectionChanged( const QString & text );
60 void selectBridge( const QString & text );
62 void selectBridge( const QString & text );
61 void setConnected(bool connected);
63 void setConnected(bool connected);
62
64
63 signals:
65 signals:
64
66
65 private:
67 private:
66 SpwTcpPacketServer* tcpServer;
68 SpwTcpPacketServer* tcpServer;
67 abstractSpwBridge* bridge;
69 abstractSpwBridge* bridge;
68 bool scanDone;
70 bool scanDone;
69 QTabWidget* mainTabWidgt;
71 QTabWidget* mainTabWidgt;
70 QGroupBox* mainGroupBox;
72 QGroupBox* mainGroupBox;
71 QComboBox* bridgeSelector;
73 QComboBox* bridgeSelector;
72 QGridLayout* mainLayout;
74 QGridLayout* mainLayout;
75
73 };
76 };
74
77
75 #endif // spwplugin_H
78 #endif // spwplugin_H
76
79
General Comments 0
You need to be logged in to leave comments. Login now