@@ -1,163 +1,190 | |||||
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 | #include "spwtcppacketserver.h" |
|
22 | #include "spwtcppacketserver.h" | |
23 | #include "ui_spwtcppacketserver.h" |
|
23 | #include "ui_spwtcppacketserver.h" | |
24 | #include <QNetworkInterface> |
|
24 | #include <QNetworkInterface> | |
25 | #include <QByteArray> |
|
25 | #include <QByteArray> | |
26 |
|
26 | |||
27 | SpwTcpPacketServer::SpwTcpPacketServer(QWidget *parent) : |
|
27 | SpwTcpPacketServer::SpwTcpPacketServer(QWidget *parent) : | |
28 | QWidget(parent), |
|
28 | QWidget(parent), | |
29 | ui(new Ui::SpwTcpPacketServer) |
|
29 | ui(new Ui::SpwTcpPacketServer) | |
30 | { |
|
30 | { | |
31 | ui->setupUi(this); |
|
31 | ui->setupUi(this); | |
32 | this->p_bridge = NULL; |
|
32 | this->p_bridge = NULL; | |
33 | this->p_server = new QTcpServer(); |
|
33 | this->p_server = new QTcpServer(); | |
34 | connect(this->ui->startServeQpb,SIGNAL(clicked(bool)),SLOT(toggleServer())); |
|
34 | connect(this->ui->startServeQpb,SIGNAL(clicked(bool)),SLOT(toggleServer())); | |
35 | updateHostIP(); |
|
35 | updateHostIP(); | |
36 | this->ui->PortLineEdit->setText("2200"); |
|
36 | this->ui->PortLineEdit->setText("2200"); | |
37 | connect(this->p_server,SIGNAL(newConnection()),this,SLOT(newConnection())); |
|
37 | connect(this->p_server,SIGNAL(newConnection()),this,SLOT(newConnection())); | |
|
38 | resetStatististics(); | |||
38 | } |
|
39 | } | |
39 |
|
40 | |||
40 | SpwTcpPacketServer::~SpwTcpPacketServer() |
|
41 | SpwTcpPacketServer::~SpwTcpPacketServer() | |
41 | { |
|
42 | { | |
42 | delete ui; |
|
43 | delete ui; | |
43 | } |
|
44 | } | |
44 |
|
45 | |||
45 | void SpwTcpPacketServer::setBridge(abstractSpwBridge *bridge) |
|
46 | void SpwTcpPacketServer::setBridge(abstractSpwBridge *bridge) | |
46 | { |
|
47 | { | |
47 | if(this->p_bridge!=NULL) |
|
48 | if(this->p_bridge!=NULL) | |
48 | { |
|
49 | { | |
49 | disconnect(this,SLOT(pushPacket(char*,int))); |
|
50 | disconnect(this,SLOT(pushPacket(char*,int))); | |
50 | } |
|
51 | } | |
51 | this->p_bridge = bridge; |
|
52 | this->p_bridge = bridge; | |
52 | connect(bridge,SIGNAL(pushPacketOverTCP(char*,int)),SLOT(pushPacket(char*,int))); |
|
53 | connect(bridge,SIGNAL(pushPacketOverTCP(char*,int)),SLOT(pushPacket(char*,int))); | |
53 | } |
|
54 | } | |
54 |
|
55 | |||
55 | void SpwTcpPacketServer::pushPacket(char *packet, int size) |
|
56 | void SpwTcpPacketServer::pushPacket(char *packet, int size) | |
56 | { |
|
57 | { | |
57 | QByteArray data; |
|
58 | QByteArray data; | |
58 | char sizech[3]; |
|
59 | char sizech[3]; | |
59 | data.append((char)0); |
|
60 | data.append((char)0); | |
60 | sizech[0]=size & 0x0FF; |
|
61 | sizech[0]=size & 0x0FF; | |
61 | sizech[1]=(size>>8) & 0x0FF; |
|
62 | sizech[1]=(size>>8) & 0x0FF; | |
62 | sizech[2]=(size>>16) & 0x0FF; |
|
63 | sizech[2]=(size>>16) & 0x0FF; | |
63 | data.append(sizech,3); |
|
64 | data.append(sizech,3); | |
64 | data.append(packet,size); |
|
65 | data.append(packet,size); | |
65 | for(int i=0;i<connectedClients.count();i++) |
|
66 | for(int i=0;i<connectedClients.count();i++) | |
66 | { |
|
67 | { | |
67 | QTcpSocket* soc=connectedClients.at(i); |
|
68 | QTcpSocket* soc=connectedClients.at(i); | |
68 | if(soc->state()!=QAbstractSocket::ConnectedState) |
|
69 | if(soc->state()!=QAbstractSocket::ConnectedState) | |
69 | { |
|
70 | { | |
70 | connectedClients.removeAt(i); |
|
71 | connectedClients.removeAt(i); | |
71 | delete soc; |
|
72 | delete soc; | |
72 | } |
|
73 | } | |
73 | else |
|
74 | else | |
74 | { |
|
75 | { | |
75 | connectedClients.at(i)->write(data); |
|
76 | connectedClients.at(i)->write(data); | |
|
77 | onePacketTransmitted(); | |||
76 | } |
|
78 | } | |
77 | } |
|
79 | } | |
78 | free(packet); |
|
80 | free(packet); | |
79 | } |
|
81 | } | |
80 |
|
82 | |||
81 | void SpwTcpPacketServer::toggleServer() |
|
83 | void SpwTcpPacketServer::toggleServer() | |
82 | { |
|
84 | { | |
83 | if(this->p_server->isListening()) |
|
85 | if(this->p_server->isListening()) | |
84 | { |
|
86 | { | |
85 | disconnectServer(); |
|
87 | disconnectServer(); | |
86 | } |
|
88 | } | |
87 | else |
|
89 | else | |
88 | { |
|
90 | { | |
89 | connectServer(); |
|
91 | connectServer(); | |
90 | } |
|
92 | } | |
91 | } |
|
93 | } | |
92 |
|
94 | |||
93 | void SpwTcpPacketServer::connectServer() |
|
95 | void SpwTcpPacketServer::connectServer() | |
94 | { |
|
96 | { | |
95 | this->p_server->listen(QHostAddress::Any,this->ui->PortLineEdit->text().toInt()); |
|
97 | this->p_server->listen(QHostAddress::Any,this->ui->PortLineEdit->text().toInt()); | |
96 | this->ui->startServeQpb->setText("Stop Server"); |
|
98 | this->ui->startServeQpb->setText("Stop Server"); | |
|
99 | resetStatististics(); | |||
97 | } |
|
100 | } | |
98 |
|
101 | |||
99 | void SpwTcpPacketServer::disconnectServer() |
|
102 | void SpwTcpPacketServer::disconnectServer() | |
100 | { |
|
103 | { | |
101 | this->ui->startServeQpb->setText("Start Server"); |
|
104 | this->ui->startServeQpb->setText("Start Server"); | |
102 | this->p_server->close(); |
|
105 | this->p_server->close(); | |
103 | } |
|
106 | } | |
104 |
|
107 | |||
105 | void SpwTcpPacketServer::setServerPort(qint32 port) |
|
108 | void SpwTcpPacketServer::setServerPort(qint32 port) | |
106 | { |
|
109 | { | |
107 | this->ui->PortLineEdit->setText(QString("%1").arg(port)); |
|
110 | this->ui->PortLineEdit->setText(QString("%1").arg(port)); | |
108 | } |
|
111 | } | |
109 |
|
112 | |||
110 | void SpwTcpPacketServer::setServerSetIP(QString ip) |
|
113 | void SpwTcpPacketServer::setServerSetIP(QString ip) | |
111 | { |
|
114 | { | |
112 | this->ui->IPLineEdit->setText(ip); |
|
115 | this->ui->IPLineEdit->setText(ip); | |
113 | } |
|
116 | } | |
114 |
|
117 | |||
115 | void SpwTcpPacketServer::newConnection() |
|
118 | void SpwTcpPacketServer::newConnection() | |
116 | { |
|
119 | { | |
117 | QTcpSocket* soc=this->p_server->nextPendingConnection(); |
|
120 | QTcpSocket* soc=this->p_server->nextPendingConnection(); | |
118 | this->connectedClients.append(soc); |
|
121 | this->connectedClients.append(soc); | |
119 | this->ui->listWidget->addItem(this->connectedClients.last()->peerAddress().toString()); |
|
122 | this->ui->listWidget->addItem(this->connectedClients.last()->peerAddress().toString()); | |
120 | connect(soc,SIGNAL(readyRead()),this,SLOT(readReady())); |
|
123 | connect(soc,SIGNAL(readyRead()),this,SLOT(readReady())); | |
121 | } |
|
124 | } | |
122 |
|
125 | |||
123 | void SpwTcpPacketServer::readReady() |
|
126 | void SpwTcpPacketServer::readReady() | |
124 | { |
|
127 | { | |
125 | for(int i=0;i<connectedClients.count();i++) |
|
128 | for(int i=0;i<connectedClients.count();i++) | |
126 | { |
|
129 | { | |
127 | QTcpSocket* soc=connectedClients.at(i); |
|
130 | QTcpSocket* soc=connectedClients.at(i); | |
128 | if(soc->state()!=QAbstractSocket::ConnectedState) |
|
131 | if(soc->state()!=QAbstractSocket::ConnectedState) | |
129 | { |
|
132 | { | |
130 | connectedClients.removeAt(i); |
|
133 | connectedClients.removeAt(i); | |
131 | delete soc; |
|
134 | delete soc; | |
132 | } |
|
135 | } | |
133 | else |
|
136 | else | |
134 | { |
|
137 | { | |
135 | if(soc->bytesAvailable()!=0) |
|
138 | if(soc->bytesAvailable()!=0) | |
136 | { |
|
139 | { | |
137 | do |
|
140 | do | |
138 | { |
|
141 | { | |
139 | QByteArray data = soc->readAll(); |
|
142 | QByteArray data = soc->readAll(); | |
140 |
|
|
143 | onePacketReceived(); | |
|
144 | if(data[0]==0) // Protocole = 0 => Host to SpaceWire packet transmission | |||
141 | { |
|
145 | { | |
142 | int size = (data[1]*256*256) + (data[2]*256) + data[3]; |
|
146 | int size = (data[1]*256*256) + (data[2]*256) + data[3]; | |
143 | char* SPWpacket = (char*)malloc(size); |
|
147 | char* SPWpacket = (char*)malloc(size); | |
144 | memcpy(SPWpacket,data.data()+4,size); |
|
148 | memcpy(SPWpacket,data.data()+4,size); // 4 bytes will be added later to the packet | |
145 | emit sendSPWPacket(SPWpacket,size); |
|
149 | emit sendSPWPacket(SPWpacket,size); | |
146 | } |
|
150 | } | |
147 | }while(soc->bytesAvailable()!=0); |
|
151 | }while(soc->bytesAvailable()!=0); | |
148 | } |
|
152 | } | |
149 | } |
|
153 | } | |
150 | } |
|
154 | } | |
151 | } |
|
155 | } | |
152 |
|
156 | |||
|
157 | void SpwTcpPacketServer::resetStatististics() | |||
|
158 | { | |||
|
159 | receivedPackets = 0; | |||
|
160 | transmittedPackets = 0; | |||
|
161 | ||||
|
162 | this->ui->receivedPacketsNumber->display( QString::number(receivedPackets) ); | |||
|
163 | this->ui->transmittedPacketsNumber->display( QString::number(transmittedPackets) ); | |||
|
164 | } | |||
|
165 | ||||
153 | void SpwTcpPacketServer::updateHostIP() |
|
166 | void SpwTcpPacketServer::updateHostIP() | |
154 | { |
|
167 | { | |
155 | QList<QHostAddress> list = QNetworkInterface::allAddresses(); |
|
168 | QList<QHostAddress> list = QNetworkInterface::allAddresses(); | |
156 |
|
169 | |||
157 | for(int nIter=0; nIter<list.count(); nIter++) |
|
170 | for(int nIter=0; nIter<list.count(); nIter++) | |
158 | { |
|
171 | { | |
159 | if(!list[nIter].isLoopback()) |
|
172 | if(!list[nIter].isLoopback()) | |
160 | if (list[nIter].protocol() == QAbstractSocket::IPv4Protocol ) |
|
173 | if (list[nIter].protocol() == QAbstractSocket::IPv4Protocol ) | |
161 | this->ui->IPLineEdit->setText(list[nIter].toString()); |
|
174 | this->ui->IPLineEdit->setText(list[nIter].toString()); | |
162 | } |
|
175 | } | |
163 | } |
|
176 | } | |
|
177 | ||||
|
178 | void SpwTcpPacketServer::onePacketReceived() | |||
|
179 | { | |||
|
180 | receivedPackets = receivedPackets + 1; | |||
|
181 | ||||
|
182 | this->ui->receivedPacketsNumber->display( QString::number(receivedPackets) ); | |||
|
183 | } | |||
|
184 | ||||
|
185 | void SpwTcpPacketServer::onePacketTransmitted() | |||
|
186 | { | |||
|
187 | transmittedPackets = transmittedPackets + 1; | |||
|
188 | ||||
|
189 | this->ui->transmittedPacketsNumber->display( QString::number(transmittedPackets) ); | |||
|
190 | } |
@@ -1,63 +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 SPWTCPPACKETSERVER_H |
|
22 | #ifndef SPWTCPPACKETSERVER_H | |
23 | #define SPWTCPPACKETSERVER_H |
|
23 | #define SPWTCPPACKETSERVER_H | |
24 |
|
24 | |||
25 | #include <QWidget> |
|
25 | #include <QWidget> | |
26 | #include <abstractspwbridge.h> |
|
26 | #include <abstractspwbridge.h> | |
27 | #include <QTcpServer> |
|
27 | #include <QTcpServer> | |
28 | #include <QList> |
|
28 | #include <QList> | |
29 | #include <QTcpSocket> |
|
29 | #include <QTcpSocket> | |
30 |
|
30 | |||
31 | namespace Ui { |
|
31 | namespace Ui { | |
32 | class SpwTcpPacketServer; |
|
32 | class SpwTcpPacketServer; | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | class SpwTcpPacketServer : public QWidget |
|
35 | class SpwTcpPacketServer : public QWidget | |
36 | { |
|
36 | { | |
37 | Q_OBJECT |
|
37 | Q_OBJECT | |
38 |
|
38 | |||
39 | public: |
|
39 | public: | |
40 | explicit SpwTcpPacketServer(QWidget *parent = 0); |
|
40 | explicit SpwTcpPacketServer(QWidget *parent = 0); | |
41 | ~SpwTcpPacketServer(); |
|
41 | ~SpwTcpPacketServer(); | |
42 |
|
42 | |||
43 | void setBridge(abstractSpwBridge* bridge); |
|
43 | void setBridge(abstractSpwBridge* bridge); | |
44 | signals: |
|
44 | signals: | |
45 | void sendSPWPacket(char* packet,int size); |
|
45 | void sendSPWPacket(char* packet,int size); | |
46 | public slots: |
|
46 | public slots: | |
47 | void pushPacket(char* packet,int size); |
|
47 | void pushPacket(char* packet,int size); | |
48 | void toggleServer(); |
|
48 | void toggleServer(); | |
49 | void connectServer(); |
|
49 | void connectServer(); | |
50 | void disconnectServer(); |
|
50 | void disconnectServer(); | |
51 | void setServerPort(qint32 port); |
|
51 | void setServerPort(qint32 port); | |
52 | void setServerSetIP(QString ip); |
|
52 | void setServerSetIP(QString ip); | |
53 | void newConnection(); |
|
53 | void newConnection(); | |
54 | void readReady(); |
|
54 | void readReady(); | |
|
55 | void resetStatististics(); | |||
55 | private: |
|
56 | private: | |
56 | void updateHostIP(); |
|
57 | void updateHostIP(); | |
|
58 | void onePacketReceived(); | |||
|
59 | void onePacketTransmitted(); | |||
57 | Ui::SpwTcpPacketServer *ui; |
|
60 | Ui::SpwTcpPacketServer *ui; | |
58 | abstractSpwBridge* p_bridge; |
|
61 | abstractSpwBridge* p_bridge; | |
59 | QTcpServer* p_server; |
|
62 | QTcpServer* p_server; | |
60 | QList<QTcpSocket*> connectedClients; |
|
63 | QList<QTcpSocket*> connectedClients; | |
|
64 | unsigned int receivedPackets; | |||
|
65 | unsigned int transmittedPackets; | |||
61 | }; |
|
66 | }; | |
62 |
|
67 | |||
63 | #endif // SPWTCPPACKETSERVER_H |
|
68 | #endif // SPWTCPPACKETSERVER_H |
@@ -1,115 +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>726</width> |
|
9 | <width>726</width> | |
10 | <height>535</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><html><head/><body><p>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.</p></body></html></string> |
|
17 | <string><html><head/><body><p>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.</p></body></html></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><html><head/><body><p>Set the port on which the server will listen and accept client connections.</p></body></html></string> |
|
53 | <string><html><head/><body><p>Set the port on which the server will listen and accept client connections.</p></body></html></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="groupBox"> |
|
68 | <widget class="QGroupBox" name="groupBox"> | |
69 | <property name="title"> |
|
69 | <property name="title"> | |
70 | <string>Server Statistics</string> |
|
70 | <string>Server Statistics</string> | |
71 | </property> |
|
71 | </property> | |
72 | <layout class="QGridLayout" name="gridLayout"> |
|
72 | <layout class="QGridLayout" name="gridLayout"> | |
73 | <item row="2" column="0" colspan="2"> |
|
73 | <item row="2" column="0" colspan="2"> | |
74 | <widget class="QGroupBox" name="clientListGroupBox_2"> |
|
74 | <widget class="QGroupBox" name="clientListGroupBox_2"> | |
75 | <property name="title"> |
|
75 | <property name="title"> | |
76 | <string>Connected clients</string> |
|
76 | <string>Connected clients</string> | |
77 | </property> |
|
77 | </property> | |
78 | <property name="flat"> |
|
78 | <property name="flat"> | |
79 | <bool>false</bool> |
|
79 | <bool>false</bool> | |
80 | </property> |
|
80 | </property> | |
81 | <layout class="QVBoxLayout" name="verticalLayout_2"> |
|
81 | <layout class="QVBoxLayout" name="verticalLayout_2"> | |
82 | <item> |
|
82 | <item> | |
83 | <widget class="QListWidget" name="listWidget"/> |
|
83 | <widget class="QListWidget" name="listWidget"/> | |
84 | </item> |
|
84 | </item> | |
85 | </layout> |
|
85 | </layout> | |
86 | </widget> |
|
86 | </widget> | |
87 | </item> |
|
87 | </item> | |
88 | <item row="0" column="1"> |
|
88 | <item row="0" column="1"> | |
89 |
<widget class="QLCDNumber" name=" |
|
89 | <widget class="QLCDNumber" name="transmittedPacketsNumber"/> | |
90 | </item> |
|
90 | </item> | |
91 | <item row="0" column="0"> |
|
91 | <item row="0" column="0"> | |
92 | <widget class="QLabel" name="label"> |
|
92 | <widget class="QLabel" name="label"> | |
93 | <property name="text"> |
|
93 | <property name="text"> | |
94 |
<string> |
|
94 | <string>Transmitted Packets</string> | |
95 | </property> |
|
95 | </property> | |
96 | </widget> |
|
96 | </widget> | |
97 | </item> |
|
97 | </item> | |
98 | <item row="1" column="0"> |
|
98 | <item row="1" column="0"> | |
99 | <widget class="QLabel" name="label_2"> |
|
99 | <widget class="QLabel" name="label_2"> | |
100 | <property name="text"> |
|
100 | <property name="text"> | |
101 | <string>Received Packets</string> |
|
101 | <string>Received Packets</string> | |
102 | </property> |
|
102 | </property> | |
103 | </widget> |
|
103 | </widget> | |
104 | </item> |
|
104 | </item> | |
105 | <item row="1" column="1"> |
|
105 | <item row="1" column="1"> | |
106 |
<widget class="QLCDNumber" name=" |
|
106 | <widget class="QLCDNumber" name="receivedPacketsNumber"/> | |
107 | </item> |
|
107 | </item> | |
108 | </layout> |
|
108 | </layout> | |
109 | </widget> |
|
109 | </widget> | |
110 | </item> |
|
110 | </item> | |
111 | </layout> |
|
111 | </layout> | |
112 | </widget> |
|
112 | </widget> | |
113 | <resources/> |
|
113 | <resources/> | |
114 | <connections/> |
|
114 | <connections/> | |
115 | </ui> |
|
115 | </ui> |
@@ -1,188 +1,284 | |||||
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>StarDundeeUI</class> |
|
3 | <class>StarDundeeUI</class> | |
4 | <widget class="QWidget" name="StarDundeeUI"> |
|
4 | <widget class="QWidget" name="StarDundeeUI"> | |
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>397</width> |
|
9 | <width>397</width> | |
10 |
<height> |
|
10 | <height>467</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="QFormLayout" name="formLayout"> |
|
16 | <layout class="QFormLayout" name="formLayout"> | |
17 | <item row="0" column="0"> |
|
17 | <item row="0" column="0"> | |
18 | <widget class="QLabel" name="selectBrickLbl"> |
|
18 | <widget class="QLabel" name="selectBrickLbl"> | |
19 | <property name="text"> |
|
19 | <property name="text"> | |
20 | <string>Select Brick</string> |
|
20 | <string>Select Brick</string> | |
21 | </property> |
|
21 | </property> | |
22 | </widget> |
|
22 | </widget> | |
23 | </item> |
|
23 | </item> | |
24 | <item row="0" column="1"> |
|
24 | <item row="0" column="1"> | |
25 | <widget class="QComboBox" name="selectBrickCmbx"> |
|
25 | <widget class="QComboBox" name="selectBrickCmbx"> | |
26 | <property name="toolTip"> |
|
26 | <property name="toolTip"> | |
27 | <string><html><head/><body><p>Select the brick you want to use.</p></body></html></string> |
|
27 | <string><html><head/><body><p>Select the brick you want to use.</p></body></html></string> | |
28 | </property> |
|
28 | </property> | |
29 | <property name="whatsThis"> |
|
29 | <property name="whatsThis"> | |
30 | <string/> |
|
30 | <string/> | |
31 | </property> |
|
31 | </property> | |
32 | <item> |
|
32 | <item> | |
33 | <property name="text"> |
|
33 | <property name="text"> | |
34 | <string>None</string> |
|
34 | <string>None</string> | |
35 | </property> |
|
35 | </property> | |
36 | </item> |
|
36 | </item> | |
37 | </widget> |
|
37 | </widget> | |
38 | </item> |
|
38 | </item> | |
39 | <item row="1" column="0"> |
|
39 | <item row="1" column="0"> | |
40 | <widget class="QLabel" name="selectLinkLbl"> |
|
40 | <widget class="QLabel" name="selectLinkLbl"> | |
41 | <property name="text"> |
|
41 | <property name="text"> | |
42 | <string>Select link number</string> |
|
42 | <string>Select link number</string> | |
43 | </property> |
|
43 | </property> | |
44 | </widget> |
|
44 | </widget> | |
45 | </item> |
|
45 | </item> | |
46 | <item row="1" column="1"> |
|
46 | <item row="1" column="1"> | |
47 | <widget class="QComboBox" name="selectLinkCmbx"> |
|
47 | <widget class="QComboBox" name="selectLinkCmbx"> | |
48 | <property name="toolTip"> |
|
48 | <property name="toolTip"> | |
49 | <string><html><head/><body><p>Select the link number you want to use.</p><p>The link number correspond to the numbers on the brick:</p><p><img src=":/imgs/stardundee.tif"/></p><p><br/></p></body></html></string> |
|
49 | <string><html><head/><body><p>Select the link number you want to use.</p><p>The link number correspond to the numbers on the brick:</p><p><img src=":/imgs/stardundee.tif"/></p><p><br/></p></body></html></string> | |
50 | </property> |
|
50 | </property> | |
51 | <item> |
|
51 | <item> | |
52 | <property name="text"> |
|
52 | <property name="text"> | |
53 | <string>1</string> |
|
53 | <string>1</string> | |
54 | </property> |
|
54 | </property> | |
55 | </item> |
|
55 | </item> | |
56 | <item> |
|
56 | <item> | |
57 | <property name="text"> |
|
57 | <property name="text"> | |
58 | <string>2</string> |
|
58 | <string>2</string> | |
59 | </property> |
|
59 | </property> | |
60 | </item> |
|
60 | </item> | |
61 | </widget> |
|
61 | </widget> | |
62 | </item> |
|
62 | </item> | |
63 | <item row="2" column="0"> |
|
63 | <item row="2" column="0"> | |
64 | <widget class="QLabel" name="selectLinkSpeedLbl"> |
|
64 | <widget class="QLabel" name="selectLinkSpeedLbl"> | |
65 | <property name="text"> |
|
65 | <property name="text"> | |
66 | <string>Link Speed</string> |
|
66 | <string>Link Speed</string> | |
67 | </property> |
|
67 | </property> | |
68 | </widget> |
|
68 | </widget> | |
69 | </item> |
|
69 | </item> | |
70 | <item row="2" column="1"> |
|
70 | <item row="2" column="1"> | |
71 | <widget class="QComboBox" name="setLinkSpeedCmbx"> |
|
71 | <widget class="QComboBox" name="setLinkSpeedCmbx"> | |
72 | <property name="toolTip"> |
|
72 | <property name="toolTip"> | |
73 | <string><html><head/><body><p>Select the Space Wire link speed you want to use.</p></body></html></string> |
|
73 | <string><html><head/><body><p>Select the Space Wire link speed you want to use.</p></body></html></string> | |
74 | </property> |
|
74 | </property> | |
75 | <item> |
|
75 | <item> | |
76 | <property name="text"> |
|
76 | <property name="text"> | |
77 | <string>10MHz</string> |
|
77 | <string>10MHz</string> | |
78 | </property> |
|
78 | </property> | |
79 | </item> |
|
79 | </item> | |
80 | </widget> |
|
80 | </widget> | |
81 | </item> |
|
81 | </item> | |
82 | <item row="3" column="0"> |
|
82 | <item row="3" column="0"> | |
83 | <widget class="QLabel" name="setDestKeyLbl"> |
|
83 | <widget class="QLabel" name="setDestKeyLbl"> | |
84 | <property name="text"> |
|
84 | <property name="text"> | |
85 |
<string> |
|
85 | <string>Source address</string> | |
86 | </property> |
|
86 | </property> | |
87 | </widget> |
|
87 | </widget> | |
88 | </item> |
|
88 | </item> | |
89 | <item row="3" column="1"> |
|
89 | <item row="3" column="1"> | |
90 | <widget class="QLineEdit" name="destKeyLineEdit"> |
|
90 | <widget class="QLineEdit" name="destKeyLineEdit"> | |
91 | <property name="toolTip"> |
|
91 | <property name="toolTip"> | |
92 | <string><html><head/><body><p>Set the Space Wire Brick destination Key, the default value is 32 (0x20).</p></body></html></string> |
|
92 | <string><html><head/><body><p>Set the Space Wire Brick destination Key, the default value is 32 (0x20).</p></body></html></string> | |
93 | </property> |
|
93 | </property> | |
94 | <property name="inputMask"> |
|
94 | <property name="inputMask"> | |
95 | <string comment="ddD"/> |
|
95 | <string comment="ddD"/> | |
96 | </property> |
|
96 | </property> | |
97 | <property name="text"> |
|
97 | <property name="text"> | |
98 | <string>32</string> |
|
98 | <string>32</string> | |
99 | </property> |
|
99 | </property> | |
100 | <property name="maxLength"> |
|
100 | <property name="maxLength"> | |
101 | <number>3</number> |
|
101 | <number>3</number> | |
102 | </property> |
|
102 | </property> | |
103 | </widget> |
|
103 | </widget> | |
104 | </item> |
|
104 | </item> | |
105 | <item row="4" column="0"> |
|
105 | <item row="4" column="0"> | |
106 | <widget class="QLabel" name="RMAPaddressLbl"> |
|
106 | <widget class="QLabel" name="RMAPaddressLbl"> | |
107 | <property name="text"> |
|
107 | <property name="text"> | |
108 |
<string> |
|
108 | <string>Destination address</string> | |
109 | </property> |
|
109 | </property> | |
110 | </widget> |
|
110 | </widget> | |
111 | </item> |
|
111 | </item> | |
112 | <item row="4" column="1"> |
|
112 | <item row="4" column="1"> | |
113 | <widget class="QLineEdit" name="RMAPAddresslineEdit"> |
|
113 | <widget class="QLineEdit" name="RMAPAddresslineEdit"> | |
114 | <property name="toolTip"> |
|
114 | <property name="toolTip"> | |
115 | <string><html><head/><body><p>Set the RMAP target address, this address will be used as destination address for all the RMAP transfers.</p><p>This is you SOC spw address.</p></body></html></string> |
|
115 | <string><html><head/><body><p>Set the RMAP target address, this address will be used as destination address for all the RMAP transfers.</p><p>This is you SOC spw address.</p></body></html></string> | |
116 | </property> |
|
116 | </property> | |
117 | <property name="inputMask"> |
|
117 | <property name="inputMask"> | |
118 | <string comment="ddD"/> |
|
118 | <string comment="ddD"/> | |
119 | </property> |
|
119 | </property> | |
120 | <property name="text"> |
|
120 | <property name="text"> | |
121 | <string>254</string> |
|
121 | <string>254</string> | |
122 | </property> |
|
122 | </property> | |
123 | <property name="maxLength"> |
|
123 | <property name="maxLength"> | |
124 | <number>3</number> |
|
124 | <number>3</number> | |
125 | </property> |
|
125 | </property> | |
126 | </widget> |
|
126 | </widget> | |
127 | </item> |
|
127 | </item> | |
128 | <item row="5" column="0"> |
|
128 | <item row="5" column="0"> | |
129 | <widget class="QLabel" name="RMAPKeyLbl"> |
|
129 | <widget class="QLabel" name="RMAPKeyLbl"> | |
130 | <property name="text"> |
|
130 | <property name="text"> | |
131 |
<string> |
|
131 | <string>Destination key</string> | |
132 | </property> |
|
132 | </property> | |
133 | </widget> |
|
133 | </widget> | |
134 | </item> |
|
134 | </item> | |
135 | <item row="5" column="1"> |
|
135 | <item row="5" column="1"> | |
136 | <widget class="QLineEdit" name="RMAPKeylineEdit"> |
|
136 | <widget class="QLineEdit" name="RMAPKeylineEdit"> | |
137 | <property name="toolTip"> |
|
137 | <property name="toolTip"> | |
138 | <string><html><head/><body><p>Set the RMAP target key, this key will be used for all the RMAP transfers.</p><p>This is you SOC spw key.</p></body></html></string> |
|
138 | <string><html><head/><body><p>Set the RMAP target key, this key will be used for all the RMAP transfers.</p><p>This is you SOC spw key.</p></body></html></string> | |
139 | </property> |
|
139 | </property> | |
140 | <property name="inputMask"> |
|
140 | <property name="inputMask"> | |
141 | <string comment="ddD"/> |
|
141 | <string comment="ddD"/> | |
142 | </property> |
|
142 | </property> | |
143 | <property name="text"> |
|
143 | <property name="text"> | |
144 | <string comment="ddD">2</string> |
|
144 | <string comment="ddD">2</string> | |
145 | </property> |
|
145 | </property> | |
146 | <property name="maxLength"> |
|
146 | <property name="maxLength"> | |
147 | <number>3</number> |
|
147 | <number>3</number> | |
148 | </property> |
|
148 | </property> | |
149 | </widget> |
|
149 | </widget> | |
150 | </item> |
|
150 | </item> | |
151 | <item row="7" column="1"> |
|
|||
152 | <widget class="QPushButton" name="connectQpb"> |
|
|||
153 | <property name="text"> |
|
|||
154 | <string>Connect</string> |
|
|||
155 | </property> |
|
|||
156 | </widget> |
|
|||
157 | </item> |
|
|||
158 | <item row="6" column="1"> |
|
151 | <item row="6" column="1"> | |
159 | <widget class="QLineEdit" name="RMAPTimeoutLineEdit"> |
|
152 | <widget class="QLineEdit" name="RMAPTimeoutLineEdit"> | |
160 | <property name="toolTip"> |
|
153 | <property name="toolTip"> | |
161 | <string><html><head/><body><p>Set the RMAP timeout, when waiting for a RMAP answer the driver will give up after this time if it doesn't get any answer.</p></body></html></string> |
|
154 | <string><html><head/><body><p>Set the RMAP timeout, when waiting for a RMAP answer the driver will give up after this time if it doesn't get any answer.</p></body></html></string> | |
162 | </property> |
|
155 | </property> | |
163 | <property name="inputMethodHints"> |
|
156 | <property name="inputMethodHints"> | |
164 | <set>Qt::ImhDigitsOnly</set> |
|
157 | <set>Qt::ImhDigitsOnly</set> | |
165 | </property> |
|
158 | </property> | |
166 | <property name="inputMask"> |
|
159 | <property name="inputMask"> | |
167 | <string comment="DDdd;"/> |
|
160 | <string comment="DDdd;"/> | |
168 | </property> |
|
161 | </property> | |
169 | <property name="text"> |
|
162 | <property name="text"> | |
170 | <string>500</string> |
|
163 | <string>500</string> | |
171 | </property> |
|
164 | </property> | |
172 | <property name="maxLength"> |
|
165 | <property name="maxLength"> | |
173 | <number>5</number> |
|
166 | <number>5</number> | |
174 | </property> |
|
167 | </property> | |
175 | </widget> |
|
168 | </widget> | |
176 | </item> |
|
169 | </item> | |
177 | <item row="6" column="0"> |
|
170 | <item row="6" column="0"> | |
178 | <widget class="QLabel" name="RMAPTimeoutLbl"> |
|
171 | <widget class="QLabel" name="RMAPTimeoutLbl"> | |
179 | <property name="text"> |
|
172 | <property name="text"> | |
180 | <string>RMAP timeout(ms)</string> |
|
173 | <string>RMAP timeout(ms)</string> | |
181 | </property> |
|
174 | </property> | |
182 | </widget> |
|
175 | </widget> | |
183 | </item> |
|
176 | </item> | |
|
177 | <item row="9" column="1"> | |||
|
178 | <widget class="QPushButton" name="connectQpb"> | |||
|
179 | <property name="text"> | |||
|
180 | <string>Connect</string> | |||
|
181 | </property> | |||
|
182 | </widget> | |||
|
183 | </item> | |||
|
184 | <item row="7" column="1"> | |||
|
185 | <widget class="QRadioButton" name="setInterfaceModeQrb"> | |||
|
186 | <property name="text"> | |||
|
187 | <string>interface mode</string> | |||
|
188 | </property> | |||
|
189 | <property name="checked"> | |||
|
190 | <bool>true</bool> | |||
|
191 | </property> | |||
|
192 | </widget> | |||
|
193 | </item> | |||
|
194 | <item row="8" column="1"> | |||
|
195 | <widget class="QRadioButton" name="setRouterModeQrb"> | |||
|
196 | <property name="text"> | |||
|
197 | <string>router mode</string> | |||
|
198 | </property> | |||
|
199 | </widget> | |||
|
200 | </item> | |||
|
201 | <item row="10" column="0" colspan="2"> | |||
|
202 | <layout class="QGridLayout" name="gridLayout"> | |||
|
203 | <item row="1" column="0"> | |||
|
204 | <widget class="QLabel" name="label_4"> | |||
|
205 | <property name="text"> | |||
|
206 | <string>Packets</string> | |||
|
207 | </property> | |||
|
208 | </widget> | |||
|
209 | </item> | |||
|
210 | <item row="1" column="1"> | |||
|
211 | <widget class="QLabel" name="starDundeeReceivedPackets"> | |||
|
212 | <property name="text"> | |||
|
213 | <string>-</string> | |||
|
214 | </property> | |||
|
215 | </widget> | |||
|
216 | </item> | |||
|
217 | <item row="0" column="1"> | |||
|
218 | <widget class="QLabel" name="label_3"> | |||
|
219 | <property name="font"> | |||
|
220 | <font> | |||
|
221 | <weight>75</weight> | |||
|
222 | <bold>true</bold> | |||
|
223 | </font> | |||
|
224 | </property> | |||
|
225 | <property name="text"> | |||
|
226 | <string>Received</string> | |||
|
227 | </property> | |||
|
228 | </widget> | |||
|
229 | </item> | |||
|
230 | <item row="2" column="1"> | |||
|
231 | <widget class="QLabel" name="starDundeeReceivedBytes"> | |||
|
232 | <property name="text"> | |||
|
233 | <string>-</string> | |||
|
234 | </property> | |||
|
235 | </widget> | |||
|
236 | </item> | |||
|
237 | <item row="2" column="0"> | |||
|
238 | <widget class="QLabel" name="label_5"> | |||
|
239 | <property name="text"> | |||
|
240 | <string>Bytes</string> | |||
|
241 | </property> | |||
|
242 | </widget> | |||
|
243 | </item> | |||
|
244 | <item row="0" column="2"> | |||
|
245 | <widget class="QLabel" name="label_7"> | |||
|
246 | <property name="font"> | |||
|
247 | <font> | |||
|
248 | <weight>75</weight> | |||
|
249 | <bold>true</bold> | |||
|
250 | </font> | |||
|
251 | </property> | |||
|
252 | <property name="text"> | |||
|
253 | <string>Transmitted</string> | |||
|
254 | </property> | |||
|
255 | </widget> | |||
|
256 | </item> | |||
|
257 | <item row="1" column="2"> | |||
|
258 | <widget class="QLabel" name="starDundeeTransmittedPackets"> | |||
|
259 | <property name="text"> | |||
|
260 | <string>-</string> | |||
|
261 | </property> | |||
|
262 | </widget> | |||
|
263 | </item> | |||
|
264 | <item row="2" column="2"> | |||
|
265 | <widget class="QLabel" name="starDundeeTransmittedBytes"> | |||
|
266 | <property name="text"> | |||
|
267 | <string>-</string> | |||
|
268 | </property> | |||
|
269 | </widget> | |||
|
270 | </item> | |||
|
271 | <item row="0" column="0"> | |||
|
272 | <widget class="QPushButton" name="resetStatsQpb"> | |||
|
273 | <property name="text"> | |||
|
274 | <string>Reset stats</string> | |||
|
275 | </property> | |||
|
276 | </widget> | |||
|
277 | </item> | |||
|
278 | </layout> | |||
|
279 | </item> | |||
184 | </layout> |
|
280 | </layout> | |
185 | </widget> |
|
281 | </widget> | |
186 | <resources/> |
|
282 | <resources/> | |
187 | <connections/> |
|
283 | <connections/> | |
188 | </ui> |
|
284 | </ui> |
@@ -1,174 +1,254 | |||||
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 | #include "stardundeegui.h" |
|
22 | #include "stardundeegui.h" | |
23 |
|
23 | |||
24 | #include "ui_stardundeeGUI.h" |
|
24 | #include "ui_stardundeeGUI.h" | |
25 | #include <spw_usb_api.h> |
|
25 | #include <spw_usb_api.h> | |
26 | #include <spw_config_library.h> |
|
26 | #include <spw_config_library.h> | |
27 |
|
27 | |||
28 | StarDundeeGUI::StarDundeeGUI(QWidget *parent) : |
|
28 | StarDundeeGUI::StarDundeeGUI(QWidget *parent) : | |
29 | QWidget(parent),ui(new Ui::StarDundeeUI) |
|
29 | QWidget(parent),ui(new Ui::StarDundeeUI) | |
30 | { |
|
30 | { | |
|
31 | resetBytesPacketsStatistics(); | |||
|
32 | ||||
31 | this->ui->setupUi(this); |
|
33 | this->ui->setupUi(this); | |
32 | connect(this->ui->selectBrickCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(brickSelectionChanged(int))); |
|
34 | connect(this->ui->selectBrickCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(brickSelectionChanged(int))); | |
33 | connect(this->ui->selectLinkCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(linkNumberSelectionChanged(int))); |
|
35 | connect(this->ui->selectLinkCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(linkNumberSelectionChanged(int))); | |
34 | connect(this->ui->setLinkSpeedCmbx,SIGNAL(currentIndexChanged(QString)),this,SIGNAL(linkSpeedSelectionChanged(QString))); |
|
36 | connect(this->ui->setLinkSpeedCmbx,SIGNAL(currentIndexChanged(QString)),this,SIGNAL(linkSpeedSelectionChanged(QString))); | |
35 | connect(this->ui->destKeyLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(destinationKeyChanged(QString))); |
|
37 | connect(this->ui->destKeyLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(destinationKeyChanged(QString))); | |
36 | connect(this->ui->RMAPAddresslineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapAddressChanged(QString))); |
|
38 | connect(this->ui->RMAPAddresslineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapAddressChanged(QString))); | |
37 | connect(this->ui->RMAPKeylineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapKeyChanged(QString))); |
|
39 | connect(this->ui->RMAPKeylineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapKeyChanged(QString))); | |
38 | connect(this->ui->RMAPTimeoutLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapTimeoutChanged(QString))); |
|
40 | connect(this->ui->RMAPTimeoutLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapTimeoutChanged(QString))); | |
39 | connect(this->ui->connectQpb,SIGNAL(clicked()),this,SIGNAL(connectClicked())); |
|
41 | connect(this->ui->connectQpb,SIGNAL(clicked()),this,SIGNAL(connectClicked())); | |
40 |
|
42 | connect(this->ui->setInterfaceModeQrb, SIGNAL(toggled(bool)), this, SIGNAL(brickModeChanged(bool))); | ||
|
43 | connect(this->ui->resetStatsQpb, SIGNAL(clicked()), this, SLOT(resetStatistics())); | |||
41 | } |
|
44 | } | |
42 |
|
45 | |||
43 | int StarDundeeGUI::getBrickSelection() |
|
46 | int StarDundeeGUI::getBrickSelection() | |
44 | { |
|
47 | { | |
45 | return ui->selectBrickCmbx->currentIndex(); |
|
48 | return ui->selectBrickCmbx->currentIndex(); | |
46 | } |
|
49 | } | |
47 |
|
50 | |||
48 | int StarDundeeGUI::getLinkNumberSelection() |
|
51 | int StarDundeeGUI::getLinkNumberSelection() | |
49 | { |
|
52 | { | |
50 | return ui->selectLinkCmbx->currentIndex(); |
|
53 | return ui->selectLinkCmbx->currentIndex(); | |
51 | } |
|
54 | } | |
52 |
|
55 | |||
53 | QString StarDundeeGUI::getLinkSpeedSelection() |
|
56 | QString StarDundeeGUI::getLinkSpeedSelection() | |
54 | { |
|
57 | { | |
55 | return ui->setLinkSpeedCmbx->currentText(); |
|
58 | return ui->setLinkSpeedCmbx->currentText(); | |
56 | } |
|
59 | } | |
57 |
|
60 | |||
58 | QString StarDundeeGUI::getDestinationKey() |
|
61 | QString StarDundeeGUI::getDestinationKey() | |
59 | { |
|
62 | { | |
60 | return ui->destKeyLineEdit->text(); |
|
63 | return ui->destKeyLineEdit->text(); | |
61 | } |
|
64 | } | |
62 |
|
65 | |||
63 | QString StarDundeeGUI::getRmapAddress() |
|
66 | QString StarDundeeGUI::getRmapAddress() | |
64 | { |
|
67 | { | |
65 | return ui->RMAPAddresslineEdit->text(); |
|
68 | return ui->RMAPAddresslineEdit->text(); | |
66 | } |
|
69 | } | |
67 |
|
70 | |||
68 | QString StarDundeeGUI::getRmapKey() |
|
71 | QString StarDundeeGUI::getRmapKey() | |
69 | { |
|
72 | { | |
70 | return ui->RMAPKeylineEdit->text(); |
|
73 | return ui->RMAPKeylineEdit->text(); | |
71 | } |
|
74 | } | |
72 |
|
75 | |||
73 | QString StarDundeeGUI::getRmapTimeout() |
|
76 | QString StarDundeeGUI::getRmapTimeout() | |
74 | { |
|
77 | { | |
75 | return ui->RMAPTimeoutLineEdit->text(); |
|
78 | return ui->RMAPTimeoutLineEdit->text(); | |
76 | } |
|
79 | } | |
77 |
|
80 | |||
|
81 | bool StarDundeeGUI::isBrickSetAsAnInterface() | |||
|
82 | { | |||
|
83 | return ui->setInterfaceModeQrb->isChecked(); | |||
|
84 | } | |||
78 |
|
85 | |||
|
86 | void StarDundeeGUI::setBrickAsAnInterface( bool interfaceMode ) | |||
|
87 | { | |||
|
88 | if (interfaceMode == true) | |||
|
89 | { | |||
|
90 | this->ui->setInterfaceModeQrb->setChecked( true ); | |||
|
91 | } | |||
|
92 | else | |||
|
93 | { | |||
|
94 | this->ui->setRouterModeQrb->setChecked( true ); | |||
|
95 | } | |||
|
96 | } | |||
|
97 | ||||
|
98 | void StarDundeeGUI::setBrickAsARouter( bool interfaceMode ) | |||
|
99 | { | |||
|
100 | if (interfaceMode==true) | |||
|
101 | { | |||
|
102 | this->ui->setRouterModeQrb->setChecked( true ); | |||
|
103 | } | |||
|
104 | else | |||
|
105 | { | |||
|
106 | this->ui->setInterfaceModeQrb->setChecked( true ); | |||
|
107 | } | |||
|
108 | ||||
|
109 | } | |||
79 |
|
110 | |||
80 | void StarDundeeGUI::lock(bool lock) |
|
111 | void StarDundeeGUI::lock(bool lock) | |
81 | { |
|
112 | { | |
82 | this->ui->selectBrickCmbx->setDisabled(lock); |
|
113 | this->ui->selectBrickCmbx->setDisabled(lock); | |
83 | this->ui->selectLinkCmbx->setDisabled(lock); |
|
114 | this->ui->selectLinkCmbx->setDisabled(lock); | |
84 | this->ui->setLinkSpeedCmbx->setDisabled(lock); |
|
115 | this->ui->setLinkSpeedCmbx->setDisabled(lock); | |
85 | this->ui->destKeyLineEdit->setDisabled(lock); |
|
116 | this->ui->destKeyLineEdit->setDisabled(lock); | |
86 | this->ui->RMAPAddresslineEdit->setDisabled(lock); |
|
117 | this->ui->RMAPAddresslineEdit->setDisabled(lock); | |
87 | this->ui->RMAPKeylineEdit->setDisabled(lock); |
|
118 | this->ui->RMAPKeylineEdit->setDisabled(lock); | |
88 | this->ui->RMAPTimeoutLineEdit->setDisabled(lock); |
|
119 | this->ui->RMAPTimeoutLineEdit->setDisabled(lock); | |
|
120 | this->ui->setInterfaceModeQrb->setDisabled(lock); | |||
|
121 | this->ui->setRouterModeQrb->setDisabled(lock); | |||
89 | if(lock) |
|
122 | if(lock) | |
90 | this->ui->connectQpb->setText("Disconnect"); |
|
123 | this->ui->connectQpb->setText("Disconnect"); | |
91 | else |
|
124 | else | |
92 | this->ui->connectQpb->setText("Connect"); |
|
125 | this->ui->connectQpb->setText("Connect"); | |
93 | } |
|
126 | } | |
94 |
|
127 | |||
95 | void StarDundeeGUI::updateAvailableBrickCount(int count) |
|
128 | void StarDundeeGUI::updateAvailableBrickCount(int count) | |
96 | { |
|
129 | { | |
97 | this->ui->selectBrickCmbx->clear(); |
|
130 | this->ui->selectBrickCmbx->clear(); | |
98 | this->ui->selectBrickCmbx->addItem("none"); |
|
131 | this->ui->selectBrickCmbx->addItem("none"); | |
99 | for(int i =0;i<32;i++) |
|
132 | for(int i =0;i<32;i++) | |
100 | { |
|
133 | { | |
101 | if((count&1)==1) |
|
134 | if((count&1)==1) | |
102 | { |
|
135 | { | |
103 | star_device_handle hDevice; |
|
136 | star_device_handle hDevice; | |
104 | char serial[11]=""; |
|
137 | char serial[11]=""; | |
105 | if (USBSpaceWire_Open(&hDevice, 0)) |
|
138 | if (USBSpaceWire_Open(&hDevice, 0)) | |
106 | { |
|
139 | { | |
107 | USBSpaceWire_GetSerialNumber(hDevice,(U8*) serial); |
|
140 | USBSpaceWire_GetSerialNumber(hDevice,(U8*) serial); | |
108 | USBSpaceWire_Close(hDevice); |
|
141 | USBSpaceWire_Close(hDevice); | |
109 | } |
|
142 | } | |
110 | this->ui->selectBrickCmbx->addItem("STAR-Dundee USB brick "+QString::number(i)+" sn:" + serial); |
|
143 | this->ui->selectBrickCmbx->addItem("STAR-Dundee USB brick "+QString::number(i)+" sn:" + serial); | |
111 | } |
|
144 | } | |
112 | count>>=1; |
|
145 | count>>=1; | |
113 | } |
|
146 | } | |
114 | } |
|
147 | } | |
115 |
|
148 | |||
116 | void StarDundeeGUI::setRmapTimeout(const QString &timeout) |
|
149 | void StarDundeeGUI::setRmapTimeout(const QString &timeout) | |
117 | { |
|
150 | { | |
118 | this->ui->RMAPTimeoutLineEdit->setText(timeout); |
|
151 | this->ui->RMAPTimeoutLineEdit->setText(timeout); | |
119 | } |
|
152 | } | |
120 |
|
153 | |||
121 | void StarDundeeGUI::selectBrick(int brickIndex) |
|
154 | void StarDundeeGUI::selectBrick(int brickIndex) | |
122 | { |
|
155 | { | |
123 | if(brickIndex>=0&& brickIndex<this->ui->selectBrickCmbx->count()) |
|
156 | if(brickIndex>=0&& brickIndex<this->ui->selectBrickCmbx->count()) | |
124 | { |
|
157 | { | |
125 | this->ui->selectBrickCmbx->setCurrentIndex(brickIndex); |
|
158 | this->ui->selectBrickCmbx->setCurrentIndex(brickIndex); | |
126 | } |
|
159 | } | |
127 | } |
|
160 | } | |
128 |
|
161 | |||
129 | void StarDundeeGUI::selectLinkNumber(int linkNumber) |
|
162 | void StarDundeeGUI::selectLinkNumber(int linkNumber) | |
130 | { |
|
163 | { | |
131 | if(linkNumber==1 || linkNumber==2) |
|
164 | if(linkNumber==1 || linkNumber==2) | |
132 | { |
|
165 | { | |
133 | this->ui->selectLinkCmbx->setCurrentIndex(linkNumber-1); |
|
166 | this->ui->selectLinkCmbx->setCurrentIndex(linkNumber-1); | |
134 | } |
|
167 | } | |
135 | } |
|
168 | } | |
136 |
|
169 | |||
137 | void StarDundeeGUI::selectLinkSpeed(int linkSpeed) |
|
170 | void StarDundeeGUI::selectLinkSpeed(int linkSpeed) | |
138 | { |
|
171 | { | |
139 | #define MHz *(1000*1000) |
|
172 | #define MHz *(1000*1000) | |
140 | if(linkSpeed==10 MHz) |
|
173 | if(linkSpeed==10 MHz) | |
141 | { |
|
174 | { | |
142 | this->ui->selectLinkCmbx->setCurrentIndex(0); |
|
175 | this->ui->selectLinkCmbx->setCurrentIndex(0); | |
143 | } |
|
176 | } | |
144 | } |
|
177 | } | |
145 |
|
178 | |||
146 | void StarDundeeGUI::setDestinationKey(const QString &destKey) |
|
179 | void StarDundeeGUI::setDestinationKey(const QString &destKey) | |
147 | { |
|
180 | { | |
148 | bool ok; |
|
181 | bool ok; | |
149 | int Key=destKey.toInt(&ok,10); |
|
182 | int Key=destKey.toInt(&ok,10); | |
150 | if(ok) |
|
183 | if(ok) | |
151 | { |
|
184 | { | |
152 | this->ui->destKeyLineEdit->setText(destKey); |
|
185 | this->ui->destKeyLineEdit->setText(destKey); | |
153 | } |
|
186 | } | |
154 | } |
|
187 | } | |
155 |
|
188 | |||
156 | void StarDundeeGUI::setRmapAddress(const QString &address) |
|
189 | void StarDundeeGUI::setRmapAddress(const QString &address) | |
157 | { |
|
190 | { | |
158 | bool ok; |
|
191 | bool ok; | |
159 | int tmp=address.toInt(&ok,10); |
|
192 | int tmp=address.toInt(&ok,10); | |
160 | if(ok) |
|
193 | if(ok) | |
161 | { |
|
194 | { | |
162 | this->ui->RMAPAddresslineEdit->setText(address); |
|
195 | this->ui->RMAPAddresslineEdit->setText(address); | |
163 | } |
|
196 | } | |
164 | } |
|
197 | } | |
165 |
|
198 | |||
166 | void StarDundeeGUI::setRmapKey(const QString &key) |
|
199 | void StarDundeeGUI::setRmapKey(const QString &key) | |
167 | { |
|
200 | { | |
168 | bool ok; |
|
201 | bool ok; | |
169 | int tmp=key.toInt(&ok,10); |
|
202 | int tmp=key.toInt(&ok,10); | |
170 | if(ok) |
|
203 | if(ok) | |
171 | { |
|
204 | { | |
172 | this->ui->RMAPKeylineEdit->setText(key); |
|
205 | this->ui->RMAPKeylineEdit->setText(key); | |
173 | } |
|
206 | } | |
174 | } |
|
207 | } | |
|
208 | ||||
|
209 | int StarDundeeGUI::getAvailableBrickCount( void ) | |||
|
210 | { | |||
|
211 | int list = USBSpaceWire_ListDevices(); | |||
|
212 | emit updateAvailableBrickCount(list); | |||
|
213 | QCoreApplication::processEvents(); | |||
|
214 | return list; | |||
|
215 | } | |||
|
216 | ||||
|
217 | void StarDundeeGUI::resetBytesPacketsStatistics( void ) | |||
|
218 | { | |||
|
219 | nbBytesReceivedFromSpw = 0; | |||
|
220 | nbBytesTransmittedToSpw = 0; | |||
|
221 | nbPacketsReceivedFromSpw = 0; | |||
|
222 | nbPacketsTransmittedToSpw = 0; | |||
|
223 | } | |||
|
224 | ||||
|
225 | void StarDundeeGUI::resetStatistics( void ) | |||
|
226 | { | |||
|
227 | nbBytesReceivedFromSpw = 0; | |||
|
228 | nbBytesTransmittedToSpw = 0; | |||
|
229 | nbPacketsReceivedFromSpw = 0; | |||
|
230 | nbPacketsTransmittedToSpw = 0; | |||
|
231 | ||||
|
232 | this->ui->starDundeeReceivedBytes->setText( QString::number(nbBytesReceivedFromSpw) ); | |||
|
233 | this->ui->starDundeeReceivedPackets->setText( QString::number(nbPacketsReceivedFromSpw) ); | |||
|
234 | this->ui->starDundeeTransmittedBytes->setText( QString::number(nbBytesTransmittedToSpw) ); | |||
|
235 | this->ui->starDundeeTransmittedPackets->setText( QString::number(nbPacketsTransmittedToSpw) ); | |||
|
236 | } | |||
|
237 | ||||
|
238 | void StarDundeeGUI::updateNbReceivedBytesFromSpw( unsigned int nbBytes) | |||
|
239 | { | |||
|
240 | nbBytesReceivedFromSpw = nbBytesReceivedFromSpw + nbBytes; | |||
|
241 | nbPacketsReceivedFromSpw = nbPacketsReceivedFromSpw + 1; | |||
|
242 | ||||
|
243 | this->ui->starDundeeReceivedBytes->setText( QString::number(nbBytesReceivedFromSpw) ); | |||
|
244 | this->ui->starDundeeReceivedPackets->setText( QString::number(nbPacketsReceivedFromSpw) ); | |||
|
245 | } | |||
|
246 | ||||
|
247 | void StarDundeeGUI::updateNbTransmittedBytesToSpw( unsigned int nbBytes) | |||
|
248 | { | |||
|
249 | nbBytesTransmittedToSpw = nbBytesTransmittedToSpw + nbBytes; | |||
|
250 | nbPacketsTransmittedToSpw = nbPacketsTransmittedToSpw + 1; | |||
|
251 | ||||
|
252 | this->ui->starDundeeTransmittedBytes->setText( QString::number(nbBytesTransmittedToSpw) ); | |||
|
253 | this->ui->starDundeeTransmittedPackets->setText( QString::number(nbPacketsTransmittedToSpw) ); | |||
|
254 | } |
@@ -1,66 +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 STARDUNDEEGUI_H |
|
22 | #ifndef STARDUNDEEGUI_H | |
23 | #define STARDUNDEEGUI_H |
|
23 | #define STARDUNDEEGUI_H | |
24 |
|
24 | |||
25 | #include <QWidget> |
|
25 | #include <QWidget> | |
26 |
|
26 | |||
27 | namespace Ui { |
|
27 | namespace Ui { | |
28 | class StarDundeeUI; |
|
28 | class StarDundeeUI; | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 | class StarDundeeGUI : public QWidget |
|
31 | class StarDundeeGUI : public QWidget | |
32 | { |
|
32 | { | |
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 | public: |
|
34 | public: | |
35 | explicit StarDundeeGUI(QWidget *parent = 0); |
|
35 | explicit StarDundeeGUI(QWidget *parent = 0); | |
36 | int getBrickSelection(); |
|
36 | int getBrickSelection(); | |
37 | int getLinkNumberSelection(); |
|
37 | int getLinkNumberSelection(); | |
38 | QString getLinkSpeedSelection(); |
|
38 | QString getLinkSpeedSelection(); | |
39 | QString getDestinationKey(); |
|
39 | QString getDestinationKey(); | |
40 | QString getRmapAddress(); |
|
40 | QString getRmapAddress(); | |
41 | QString getRmapKey(); |
|
41 | QString getRmapKey(); | |
42 | QString getRmapTimeout(); |
|
42 | QString getRmapTimeout(); | |
|
43 | bool isBrickSetAsAnInterface(); | |||
43 | signals: |
|
44 | signals: | |
44 | void brickSelectionChanged(int brickIndex); |
|
45 | void brickSelectionChanged(int brickIndex); | |
45 | void linkNumberSelectionChanged(int linkIndex); |
|
46 | void linkNumberSelectionChanged(int linkIndex); | |
46 | void linkSpeedSelectionChanged(const QString & linkSpeed); |
|
47 | void linkSpeedSelectionChanged(const QString & linkSpeed); | |
47 | void destinationKeyChanged(const QString & destKey); |
|
48 | void destinationKeyChanged(const QString & destKey); | |
48 | void rmapAddressChanged(const QString & address); |
|
49 | void rmapAddressChanged(const QString & address); | |
49 | void rmapKeyChanged(const QString & key); |
|
50 | void rmapKeyChanged(const QString & key); | |
50 | void rmapTimeoutChanged(const QString & timeout); |
|
51 | void rmapTimeoutChanged(const QString & timeout); | |
51 | void connectClicked(); |
|
52 | void connectClicked(); | |
|
53 | void brickModeChanged(bool); | |||
52 | public slots: |
|
54 | public slots: | |
53 | void lock(bool lock); |
|
55 | void lock(bool lock); | |
54 | void updateAvailableBrickCount(int count); |
|
56 | void updateAvailableBrickCount(int count); | |
55 | void selectBrick(int brickIndex); |
|
57 | void selectBrick(int brickIndex); | |
56 | void selectLinkNumber(int linkIndex); |
|
58 | void selectLinkNumber(int linkIndex); | |
57 | void selectLinkSpeed(int linkSpeed); |
|
59 | void selectLinkSpeed(int linkSpeed); | |
58 | void setDestinationKey(const QString & destKey); |
|
60 | void setDestinationKey(const QString & destKey); | |
59 | void setRmapAddress(const QString & address); |
|
61 | void setRmapAddress(const QString & address); | |
60 | void setRmapKey(const QString & key); |
|
62 | void setRmapKey(const QString & key); | |
61 | void setRmapTimeout(const QString & timeout); |
|
63 | void setRmapTimeout(const QString & timeout); | |
|
64 | int getAvailableBrickCount( void ); | |||
|
65 | void setBrickAsAnInterface(bool interfaceMode); | |||
|
66 | void setBrickAsARouter( bool interfaceMode ); | |||
|
67 | void resetBytesPacketsStatistics( void ); | |||
|
68 | void resetStatistics( void ); | |||
|
69 | void updateNbReceivedBytesFromSpw( unsigned int nbBytes); | |||
|
70 | void updateNbTransmittedBytesToSpw( unsigned int nbBytes); | |||
62 | private: |
|
71 | private: | |
63 | Ui::StarDundeeUI *ui; |
|
72 | Ui::StarDundeeUI *ui; | |
|
73 | unsigned int nbBytesReceivedFromSpw; | |||
|
74 | unsigned int nbBytesTransmittedToSpw; | |||
|
75 | unsigned int nbPacketsReceivedFromSpw; | |||
|
76 | unsigned int nbPacketsTransmittedToSpw; | |||
64 | }; |
|
77 | }; | |
65 |
|
78 | |||
66 | #endif // STARDUNDEEGUI_H |
|
79 | #endif // STARDUNDEEGUI_H |
@@ -1,647 +1,1020 | |||||
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 "stardundeespw_usb.h" |
|
23 | #include "stardundeespw_usb.h" | |
24 | #include <socexplorerengine.h> |
|
24 | #include <socexplorerengine.h> | |
25 | #include <qhexedit.h> |
|
25 | #include <qhexedit.h> | |
26 |
|
26 | |||
|
27 | QString dwLinkStatusQString[6] = { | |||
|
28 | "CFG_SPACEWIRE_ERROR_RESET", | |||
|
29 | "CFG_SPACEWIRE_ERROR_WAIT", | |||
|
30 | "CFG_SPACEWIRE_READY", | |||
|
31 | "CFG_SPACEWIRE_STARTED", | |||
|
32 | "CFG_SPACEWIRE_CONNECTING", | |||
|
33 | "CFG_SPACEWIRE_RUN" | |||
|
34 | }; | |||
|
35 | ||||
27 | stardundeeSPW_USB::stardundeeSPW_USB(socexplorerplugin *parent) : |
|
36 | stardundeeSPW_USB::stardundeeSPW_USB(socexplorerplugin *parent) : | |
28 | abstractSpwBridge(parent) |
|
37 | abstractSpwBridge(parent) | |
29 | { |
|
38 | { | |
30 | Q_UNUSED(parent) |
|
39 | Q_UNUSED(parent) | |
31 | this->manager = new stardundeeSPW_USB_Manager(parent,this); |
|
40 | this->manager = new stardundeeSPW_USB_Manager(parent,this); | |
32 | makeGUI(parent); |
|
41 | makeGUI(parent); | |
33 | this->manager->start(); |
|
42 | this->manager->start(); | |
34 | connect(this->manager,SIGNAL(emitPacket(char*,int)),this,SIGNAL(pushPacketOverTCP(char*,int))); |
|
43 | connect(this->manager,SIGNAL(emitPacket(char*,int)),this,SIGNAL(pushPacketOverTCP(char*,int))); | |
|
44 | connect(this->manager, SIGNAL(bytesReceivedFromSpw(uint)), this, SIGNAL(BytesReceivedFromSpw(uint))); | |||
|
45 | connect(this->manager, SIGNAL(bytesTransmittedToSpw(uint)), this, SIGNAL(BytesTransmittedToSpw(uint))); | |||
35 | } |
|
46 | } | |
36 |
|
47 | |||
37 | stardundeeSPW_USB::~stardundeeSPW_USB() |
|
48 | stardundeeSPW_USB::~stardundeeSPW_USB() | |
38 | { |
|
49 | { | |
39 | this->manager->requestInterruption(); |
|
50 | this->manager->requestInterruption(); | |
40 | while(this->manager->isRunning()); |
|
51 | while(this->manager->isRunning()); | |
41 | } |
|
52 | } | |
42 |
|
53 | |||
43 | void stardundeeSPW_USB::toggleBridgeConnection() |
|
54 | void stardundeeSPW_USB::toggleBridgeConnection() | |
44 | { |
|
55 | { | |
45 | if(this->plugin->isConnected()) |
|
56 | if(this->plugin->isConnected()) | |
46 | { |
|
57 | { | |
47 | this->disconnectBridge(); |
|
58 | this->disconnectBridge(); | |
48 | } |
|
59 | } | |
49 | else |
|
60 | else | |
50 | { |
|
61 | { | |
51 | this->connectBridge(); |
|
62 | this->connectBridge(); | |
52 | } |
|
63 | } | |
53 | } |
|
64 | } | |
54 |
|
65 | |||
55 | bool stardundeeSPW_USB::connectBridge() |
|
66 | bool stardundeeSPW_USB::connectBridge() | |
56 | { |
|
67 | { | |
57 | if(this->manager->connectBridge()) |
|
68 | if(this->manager->connectBridge()) | |
58 | { |
|
69 | { | |
59 | ((StarDundeeGUI*)this->p_GUI)->lock(true); |
|
70 | ((StarDundeeGUI*)this->p_GUI)->lock(true); | |
60 | emit setConnected(true); |
|
71 | emit setConnected(true); | |
61 | return true; |
|
72 | return true; | |
62 | } |
|
73 | } | |
63 | return false; |
|
74 | return false; | |
64 | } |
|
75 | } | |
65 |
|
76 | |||
66 | bool stardundeeSPW_USB::disconnectBridge() |
|
77 | bool stardundeeSPW_USB::disconnectBridge() | |
67 | { |
|
78 | { | |
68 | if(this->manager->disconnectBridge()) |
|
79 | if(this->manager->disconnectBridge()) | |
69 | { |
|
80 | { | |
70 | ((StarDundeeGUI*)this->p_GUI)->lock(false); |
|
81 | ((StarDundeeGUI*)this->p_GUI)->lock(false); | |
71 | emit setConnected(false); |
|
82 | emit setConnected(false); | |
72 | return true; |
|
83 | return true; | |
73 | } |
|
84 | } | |
74 | return false; |
|
85 | return false; | |
75 | } |
|
86 | } | |
76 |
|
87 | |||
77 |
|
88 | |||
78 | int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size) |
|
89 | int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size) | |
79 | { |
|
90 | { | |
80 | return this->manager->sendPacket(packet,size); |
|
91 | return this->manager->sendPacket(packet,size); | |
81 | } |
|
92 | } | |
82 |
|
93 | |||
83 | unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address) |
|
94 | unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address) | |
84 | { |
|
95 | { | |
85 | char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1]; |
|
96 | char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1]; | |
86 | char *RMAPAckBuff; |
|
97 | char *RMAPAckBuff; | |
87 | writeBuffer[0]=this->manager->linkNumber;//Link number |
|
98 | writeBuffer[0]=this->manager->linkNumber;//Link number | |
88 | int transactionID = 0; |
|
99 | int transactionID = 0; | |
89 | int written=0; |
|
100 | int written=0; | |
90 | SocExplorerEngine::message(this->plugin,"Enter Write function",2); |
|
101 | SocExplorerEngine::message(this->plugin,"Enter Write function",2); | |
91 | QProgressBar* progress=NULL; |
|
102 | QProgressBar* progress=NULL; | |
92 | SocExplorerAutoProgressBar autopb; |
|
103 | SocExplorerAutoProgressBar autopb; | |
93 | if(count>RMAP_MAX_XFER_SIZE) |
|
104 | if(count>RMAP_MAX_XFER_SIZE) | |
94 | { |
|
105 | { | |
95 | progress= SocExplorerEngine::getProgressBar("Writing on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); |
|
106 | progress= SocExplorerEngine::getProgressBar("Writing on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); | |
96 | autopb.setProgressBar(progress); |
|
107 | autopb.setProgressBar(progress); | |
97 | } |
|
108 | } | |
98 | //Quite stupide loop, I guess that I always get the number of byte I asked for! |
|
109 | //Quite stupide loop, I guess that I always get the number of byte I asked for! | |
99 | while(count>=RMAP_MAX_XFER_SIZE) |
|
110 | while(count>=RMAP_MAX_XFER_SIZE) | |
100 | { |
|
111 | { | |
101 | for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++) |
|
112 | for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++) | |
102 | { |
|
113 | { | |
103 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); |
|
114 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); | |
104 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); |
|
115 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); | |
105 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); |
|
116 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); | |
106 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); |
|
117 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); | |
107 | } |
|
118 | } | |
108 | transactionID=manager->getRMAPtransactionID(); |
|
119 | transactionID=manager->getRMAPtransactionID(); | |
109 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); |
|
120 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); | |
110 | RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),RMAP_MAX_XFER_SIZE*4,writeBuffer+1); |
|
121 | RMAP_build_tx_request_header( | |
|
122 | this->manager->destinationLogicalAddress, | |||
|
123 | this->manager->destinationKey, | |||
|
124 | this->manager->sourceLogicalAddress, | |||
|
125 | transactionID, | |||
|
126 | address+(written*4), | |||
|
127 | RMAP_MAX_XFER_SIZE*4, | |||
|
128 | writeBuffer+1); | |||
111 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1); |
|
129 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1); | |
112 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); |
|
130 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); | |
113 | free(RMAPAckBuff); |
|
131 | free(RMAPAckBuff); | |
114 | written+=RMAP_MAX_XFER_SIZE; |
|
132 | written+=RMAP_MAX_XFER_SIZE; | |
115 | count-=RMAP_MAX_XFER_SIZE; |
|
133 | count-=RMAP_MAX_XFER_SIZE; | |
116 | progress->setValue(written); |
|
134 | progress->setValue(written); | |
117 | qApp->processEvents(); |
|
135 | qApp->processEvents(); | |
118 | } |
|
136 | } | |
119 | if(count>0) |
|
137 | if(count>0) | |
120 | { |
|
138 | { | |
121 | for(int i=0;i<((int)count);i++) |
|
139 | for(int i=0;i<((int)count);i++) | |
122 | { |
|
140 | { | |
123 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); |
|
141 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char)(((unsigned int)Value[i+written]>>24)&0xFF); | |
124 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); |
|
142 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char)(((unsigned int)Value[i+written]>>16)&0xFF); | |
125 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); |
|
143 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF); | |
126 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); |
|
144 | writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF); | |
127 | } |
|
145 | } | |
128 | transactionID=manager->getRMAPtransactionID(); |
|
146 | transactionID=manager->getRMAPtransactionID(); | |
129 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); |
|
147 | SocExplorerEngine::message(this->plugin,QString("Sending Write request with ID=%1").arg(transactionID),2); | |
130 | RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),count*4,writeBuffer+1); |
|
148 | RMAP_build_tx_request_header( | |
|
149 | this->manager->destinationLogicalAddress, | |||
|
150 | this->manager->destinationKey, | |||
|
151 | this->manager->sourceLogicalAddress, | |||
|
152 | transactionID, | |||
|
153 | address+(written*4), | |||
|
154 | count*4, | |||
|
155 | writeBuffer+1); | |||
131 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1); |
|
156 | manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1); | |
132 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); |
|
157 | manager->getRMAPanswer(transactionID,&RMAPAckBuff); | |
133 | free(RMAPAckBuff); |
|
158 | free(RMAPAckBuff); | |
134 | written+=count; |
|
159 | written+=count; | |
135 | if(progress!=NULL) |
|
160 | if(progress!=NULL) | |
136 | { |
|
161 | { | |
137 | progress->setValue(written); |
|
162 | progress->setValue(written); | |
138 | qApp->processEvents(); |
|
163 | qApp->processEvents(); | |
139 | } |
|
164 | } | |
140 | } |
|
165 | } | |
141 | return written; |
|
166 | return written; | |
142 | } |
|
167 | } | |
143 |
|
168 | |||
144 | unsigned int stardundeeSPW_USB::Read(unsigned int *Value, unsigned int count, unsigned int address) |
|
169 | unsigned int stardundeeSPW_USB::Read(unsigned int *Value, unsigned int count, unsigned int address) | |
145 | { |
|
170 | { | |
146 | char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1]; |
|
171 | char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1]; | |
147 | char* RMAP_AnswerBuffer; |
|
172 | char* RMAP_AnswerBuffer; | |
148 | requestBuffer[0]=this->manager->linkNumber;//Link number |
|
173 | requestBuffer[0]=this->manager->linkNumber;//Link number | |
149 | int transactionID = 0; |
|
174 | int transactionID = 0; | |
150 | int read=0; |
|
175 | int read=0; | |
151 | QProgressBar* progress=NULL; |
|
176 | QProgressBar* progress=NULL; | |
152 | SocExplorerAutoProgressBar autopb; |
|
177 | SocExplorerAutoProgressBar autopb; | |
153 | if(count>RMAP_MAX_XFER_SIZE) |
|
178 | if(count>RMAP_MAX_XFER_SIZE) | |
154 | { |
|
179 | { | |
155 | progress= SocExplorerEngine::getProgressBar("Reading on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); |
|
180 | progress= SocExplorerEngine::getProgressBar("Reading on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); | |
156 | autopb.setProgressBar(progress); |
|
181 | autopb.setProgressBar(progress); | |
157 | } |
|
182 | } | |
158 | SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE),2); |
|
183 | SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE),2); | |
159 |
|
184 | |||
160 | //Quite stupide loop, I guess that I always get the number of byte I asked for! |
|
185 | //Quite stupide loop, I guess that I always get the number of byte I asked for! | |
161 | while((int)count>=(int)RMAP_MAX_XFER_SIZE) |
|
186 | while((int)count>=(int)RMAP_MAX_XFER_SIZE) | |
162 | { |
|
187 | { | |
163 | transactionID = manager->getRMAPtransactionID(); |
|
188 | transactionID = manager->getRMAPtransactionID(); | |
164 | SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2); |
|
189 | SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2); | |
165 | RMAP_build_rx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(read*4),RMAP_MAX_XFER_SIZE*4,requestBuffer+1); |
|
190 | RMAP_build_rx_request_header( | |
|
191 | this->manager->destinationLogicalAddress, | |||
|
192 | this->manager->destinationKey, | |||
|
193 | this->manager->sourceLogicalAddress, | |||
|
194 | transactionID, | |||
|
195 | address+(read*4), | |||
|
196 | RMAP_MAX_XFER_SIZE*4, | |||
|
197 | requestBuffer+1); | |||
166 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); |
|
198 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); | |
167 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); |
|
199 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); | |
168 | if(len==-1) |
|
200 | if(len==-1) | |
169 | { |
|
201 | { | |
170 | this->toggleBridgeConnection(); |
|
202 | this->toggleBridgeConnection(); | |
171 | return 0; |
|
203 | return 0; | |
172 | } |
|
204 | } | |
173 | for(int i=0;i<((len-13)/4);i++) |
|
205 | for(int i=0;i<((len-13)/4);i++) | |
174 | { |
|
206 | { | |
175 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); |
|
207 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); | |
176 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); |
|
208 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); | |
177 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); |
|
209 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); | |
178 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); |
|
210 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); | |
179 | } |
|
211 | } | |
180 | free(RMAP_AnswerBuffer); |
|
212 | free(RMAP_AnswerBuffer); | |
181 | read+=RMAP_MAX_XFER_SIZE; |
|
213 | read+=RMAP_MAX_XFER_SIZE; | |
182 | count-=RMAP_MAX_XFER_SIZE; |
|
214 | count-=RMAP_MAX_XFER_SIZE; | |
183 | progress->setValue(read); |
|
215 | progress->setValue(read); | |
184 | qApp->processEvents(); |
|
216 | qApp->processEvents(); | |
185 | } |
|
217 | } | |
186 | if((int)count>0) |
|
218 | if((int)count>0) | |
187 | { |
|
219 | { | |
188 | transactionID = manager->getRMAPtransactionID(); |
|
220 | transactionID = manager->getRMAPtransactionID(); | |
189 | SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2); |
|
221 | SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2); | |
190 | SocExplorerEngine::message(this->plugin,QString("Building request with:"),2); |
|
222 | SocExplorerEngine::message(this->plugin,QString("Building request with:"),2); | |
191 | SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2); |
|
223 | SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2); | |
192 | SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2); |
|
224 | SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2); | |
193 | SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2); |
|
225 | SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2); | |
194 | RMAP_build_rx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(read*4),count*4,requestBuffer+1); |
|
226 | RMAP_build_rx_request_header( | |
|
227 | this->manager->destinationLogicalAddress, | |||
|
228 | this->manager->destinationKey, | |||
|
229 | this->manager->sourceLogicalAddress, | |||
|
230 | transactionID, | |||
|
231 | address+(read*4), | |||
|
232 | count*4, | |||
|
233 | requestBuffer+1); | |||
195 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); |
|
234 | manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); | |
196 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); |
|
235 | int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); | |
197 | if(len==-1) |
|
236 | if(len==-1) | |
198 | { |
|
237 | { | |
199 | this->toggleBridgeConnection(); |
|
238 | this->toggleBridgeConnection(); | |
200 | return 0; |
|
239 | return 0; | |
201 | } |
|
240 | } | |
202 | for(int i=0;i<((len-13)/4);i++) |
|
241 | for(int i=0;i<((len-13)/4);i++) | |
203 | { |
|
242 | { | |
204 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); |
|
243 | Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]); | |
205 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); |
|
244 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+13])); | |
206 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); |
|
245 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+14])); | |
207 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); |
|
246 | Value[read+i] = (Value[read+i]<<8) + (0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+15])); | |
208 | } |
|
247 | } | |
209 | free(RMAP_AnswerBuffer); |
|
248 | free(RMAP_AnswerBuffer); | |
210 | read+=count; |
|
249 | read+=count; | |
211 | if(progress!=NULL) |
|
250 | if(progress!=NULL) | |
212 | { |
|
251 | { | |
213 | progress->setValue(read); |
|
252 | progress->setValue(read); | |
214 | qApp->processEvents(); |
|
253 | qApp->processEvents(); | |
215 | } |
|
254 | } | |
216 | } |
|
255 | } | |
217 | return read; |
|
256 | return read; | |
218 | } |
|
257 | } | |
219 |
|
258 | |||
220 | void stardundeeSPW_USB::brickSelectionChanged(int brickIndex) |
|
259 | void stardundeeSPW_USB::brickSelectionChanged(int brickIndex) | |
221 | { |
|
260 | { | |
222 | this->manager->selectedBrick = brickIndex-1; |
|
261 | this->manager->selectedBrick = brickIndex-1; | |
223 | SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick),1); |
|
262 | SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick),1); | |
224 | } |
|
263 | } | |
225 |
|
264 | |||
226 | void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex) |
|
265 | void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex) | |
227 | { |
|
266 | { | |
228 | this->manager->linkNumber = linkIndex + 1; |
|
267 | this->manager->linkNumber = linkIndex + 1; | |
229 | SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber),1); |
|
268 | SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber),1); | |
230 | } |
|
269 | } | |
231 |
|
270 | |||
232 | void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed) |
|
271 | void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed) | |
233 | { |
|
272 | { | |
234 | this->manager->linkSpeed = linkSpeed.toInt(); |
|
273 | this->manager->linkSpeed = linkSpeed.toInt(); | |
235 |
|
274 | |||
236 | SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed),1); |
|
275 | SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed),1); | |
237 | } |
|
276 | } | |
238 |
|
277 | |||
239 |
void stardundeeSPW_USB:: |
|
278 | void stardundeeSPW_USB::sourceLogicalAddressChanged(const QString &sourceAddress) | |
240 | { |
|
279 | { | |
241 |
this->manager-> |
|
280 | this->manager->sourceLogicalAddress = sourceAddress.toInt(); | |
242 |
SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager-> |
|
281 | SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->sourceLogicalAddress),1); | |
243 | } |
|
282 | } | |
244 |
|
283 | |||
245 | void stardundeeSPW_USB::rmapAddressChanged(const QString &rmapaddress) |
|
284 | void stardundeeSPW_USB::rmapAddressChanged(const QString &rmapaddress) | |
246 | { |
|
285 | { | |
247 |
this->manager-> |
|
286 | this->manager->destinationLogicalAddress = rmapaddress.toInt(); | |
248 |
SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager-> |
|
287 | SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->destinationLogicalAddress),1); | |
249 | } |
|
288 | } | |
250 |
|
289 | |||
251 |
void stardundeeSPW_USB:: |
|
290 | void stardundeeSPW_USB::destinationKeyChanged(const QString &key) | |
252 | { |
|
291 | { | |
253 |
this->manager-> |
|
292 | this->manager->destinationKey = key.toInt(); | |
254 |
SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager-> |
|
293 | SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->destinationKey),1); | |
|
294 | } | |||
|
295 | ||||
|
296 | void stardundeeSPW_USB::brickModeChanged( bool interfaceMode ) | |||
|
297 | { | |||
|
298 | this->manager->interfaceMode = interfaceMode; | |||
255 | } |
|
299 | } | |
256 |
|
300 | |||
257 | void stardundeeSPW_USB::rmapTimeoutChanged(const QString &timeout) |
|
301 | void stardundeeSPW_USB::rmapTimeoutChanged(const QString &timeout) | |
258 | { |
|
302 | { | |
259 | int tim=timeout.toInt(); |
|
303 | int tim=timeout.toInt(); | |
260 | if(tim<50) |
|
304 | if(tim<50) | |
261 | { |
|
305 | { | |
262 | tim = 50; |
|
306 | tim = 50; | |
263 | ((StarDundeeGUI*)this->p_GUI)->setRmapTimeout(QString("%1").arg(tim)); |
|
307 | ((StarDundeeGUI*)this->p_GUI)->setRmapTimeout(QString("%1").arg(tim)); | |
264 | } |
|
308 | } | |
265 | this->manager->RMAPtimeout = tim; |
|
309 | this->manager->RMAPtimeout = tim; | |
266 | SocExplorerEngine::message(plugin,QString("Changing RMAP Timeout: %1").arg(manager->RMAPtimeout),1); |
|
310 | SocExplorerEngine::message(plugin,QString("Changing RMAP Timeout: %1").arg(manager->RMAPtimeout),1); | |
267 | } |
|
311 | } | |
268 |
|
312 | |||
269 |
|
||||
270 | void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent) |
|
313 | void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent) | |
271 | { |
|
314 | { | |
272 | this->p_GUI = new StarDundeeGUI(); |
|
315 | this->p_GUI = new StarDundeeGUI(); | |
273 | // this->mainLayout = new QGridLayout(this->p_GUI); |
|
316 | // this->mainLayout = new QGridLayout(this->p_GUI); | |
274 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection())); |
|
317 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection())); | |
275 | connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int))); |
|
318 | connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int))); | |
276 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int))); |
|
319 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int))); | |
277 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int))); |
|
320 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int))); | |
278 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString))); |
|
321 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString))); | |
279 |
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL( |
|
322 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(sourceLogicalAddressChanged(QString)),this,SLOT(sourceLogicalAddressChanged(QString))); | |
280 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(rmapAddressChanged(QString))); |
|
323 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(rmapAddressChanged(QString))); | |
281 |
connect(((StarDundeeGUI*)this->p_GUI),SIGNAL( |
|
324 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(destinationKeyChanged(QString)),this,SLOT(destinationKeyChanged(QString))); | |
282 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapTimeoutChanged(QString)),this,SLOT(rmapTimeoutChanged(QString))); |
|
325 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapTimeoutChanged(QString)),this,SLOT(rmapTimeoutChanged(QString))); | |
|
326 | connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickModeChanged(bool)), this, SLOT(brickModeChanged(bool))); | |||
283 |
|
327 | |||
284 | this->brickSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getBrickSelection()); |
|
328 | this->brickSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getBrickSelection()); | |
285 | this->linkNumberSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection()); |
|
329 | this->linkNumberSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection()); | |
286 | this->linkSpeedSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection()); |
|
330 | this->linkSpeedSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection()); | |
287 |
this-> |
|
331 | this->sourceLogicalAddressChanged(((StarDundeeGUI*)this->p_GUI)->getDestinationKey()); | |
288 | this->rmapAddressChanged(((StarDundeeGUI*)this->p_GUI)->getRmapAddress()); |
|
332 | this->rmapAddressChanged(((StarDundeeGUI*)this->p_GUI)->getRmapAddress()); | |
289 |
this-> |
|
333 | this->destinationKeyChanged(((StarDundeeGUI*)this->p_GUI)->getRmapKey()); | |
290 | this->rmapTimeoutChanged(((StarDundeeGUI*)this->p_GUI)->getRmapTimeout()); |
|
334 | this->rmapTimeoutChanged(((StarDundeeGUI*)this->p_GUI)->getRmapTimeout()); | |
|
335 | this->brickModeChanged(((StarDundeeGUI*)this->p_GUI)->isBrickSetAsAnInterface()); | |||
|
336 | ||||
|
337 | connect(this,SIGNAL(SelectBrick(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int))); | |||
|
338 | connect(this,SIGNAL(SelectLinkNumber(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int))); | |||
|
339 | connect(this,SIGNAL(SelectLinkSpeed(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkSpeed(int))); | |||
|
340 | connect(this,SIGNAL(SetDestinationKey(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationKey(QString))); | |||
|
341 | connect(this,SIGNAL(SetRmapAddress(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setRmapAddress(QString))); | |||
|
342 | connect(this,SIGNAL(SetRmapKey(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setRmapKey(QString))); | |||
|
343 | connect(this,SIGNAL(SetRmapTimeout(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setRmapTimeout(QString))); | |||
|
344 | connect(this,SIGNAL(GetAvailableBrickCount()), ((StarDundeeGUI*)this->p_GUI),SLOT(getAvailableBrickCount())); | |||
|
345 | connect(this,SIGNAL(SetBrickAsAnInterface(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsAnInterface(bool))); | |||
|
346 | connect(this,SIGNAL(SetBrickAsARouter(bool)), ((StarDundeeGUI*)this->p_GUI),SLOT(setBrickAsARouter(bool))); | |||
|
347 | connect(this,SIGNAL(BytesReceivedFromSpw(uint)), ((StarDundeeGUI*)this->p_GUI),SLOT(updateNbReceivedBytesFromSpw(uint))); | |||
|
348 | connect(this,SIGNAL(BytesTransmittedToSpw(uint)),((StarDundeeGUI*)this->p_GUI),SLOT(updateNbTransmittedBytesToSpw(uint))); | |||
|
349 | } | |||
291 |
|
350 | |||
292 | connect(this,SIGNAL(SelectBrick(int)),((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int))); |
|
351 | void stardundeeSPW_USB::sendPacketComingFromTCPServer(char *packet, int size) | |
293 | connect(this,SIGNAL(SelectLinkNumber(int)),((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int))); |
|
352 | { | |
294 | connect(this,SIGNAL(SelectLinkSpeed(int)),((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkSpeed(int))); |
|
353 | char* data; | |
295 | connect(this,SIGNAL(SetDestinationKey(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setDestinationKey(QString))); |
|
354 | int i; | |
296 | connect(this,SIGNAL(SetRmapAddress(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setRmapAddress(QString))); |
|
355 | ||
297 | connect(this,SIGNAL(SetRmapKey(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setRmapKey(QString))); |
|
356 | data = (char *) malloc( size + 5 ); | |
298 | connect(this,SIGNAL(SetRmapTimeout(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setRmapTimeout(QString))); |
|
|||
299 |
|
357 | |||
|
358 | data[0] = this->manager->linkNumber; | |||
|
359 | data[1] = this->manager->destinationLogicalAddress; // target logical address | |||
|
360 | data[2] = SPW_PROTO_ID_CCSDS; // protocol identifier | |||
|
361 | data[3] = 0x00; // reserved | |||
|
362 | data[4] = 0x00; // user application | |||
|
363 | ||||
|
364 | for ( i=0; i<size; i++ ) | |||
|
365 | { | |||
|
366 | data[i+5] = packet[i]; | |||
|
367 | } | |||
|
368 | ||||
|
369 | this->manager->sendPacket( data, size + 5); | |||
|
370 | ||||
|
371 | free(data); | |||
|
372 | free(packet); | |||
300 | } |
|
373 | } | |
301 |
|
374 | |||
302 | stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent) |
|
375 | stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent) | |
303 | :QThread((QObject*)parent) |
|
376 | :QThread((QObject*)parent) | |
304 | { |
|
377 | { | |
305 | this->RMAPtimeout = 2000; |
|
378 | this->RMAPtimeout = 2000; | |
306 | this->handleMutex = new QMutex(QMutex::NonRecursive); |
|
379 | this->handleMutex = new QMutex(QMutex::NonRecursive); | |
307 | this->RMAP_AnswersSem = new QSemaphore(0); |
|
380 | this->RMAP_AnswersSem = new QSemaphore(0); | |
308 | this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); |
|
381 | this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); | |
309 | this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); |
|
382 | this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); | |
310 | this->plugin = plugin; |
|
383 | this->plugin = plugin; | |
311 | connected = false; |
|
384 | connected = false; | |
312 | this->moveToThread(this); |
|
385 | this->moveToThread(this); | |
313 | } |
|
386 | } | |
314 |
|
387 | |||
315 | stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() |
|
388 | stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() | |
316 | { |
|
389 | { | |
317 | this->terminate(); |
|
390 | this->terminate(); | |
318 | while (!this->isFinished()) { |
|
391 | while (!this->isFinished()) { | |
319 | this->usleep(1000); |
|
392 | this->usleep(1000); | |
320 | } |
|
393 | } | |
321 | } |
|
394 | } | |
322 |
|
395 | |||
323 |
|
||||
324 | void stardundeeSPW_USB_Manager::run() |
|
396 | void stardundeeSPW_USB_Manager::run() | |
325 | { |
|
397 | { | |
326 | USB_SPACEWIRE_PACKET_PROPERTIES properties; |
|
398 | USB_SPACEWIRE_PACKET_PROPERTIES properties; | |
327 | USB_SPACEWIRE_ID pIdentifier=NULL; |
|
399 | USB_SPACEWIRE_ID pIdentifier=NULL; | |
328 | USB_SPACEWIRE_STATUS stat; |
|
400 | USB_SPACEWIRE_STATUS stat; | |
329 | SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1); |
|
401 | SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1); | |
330 | char buffer[(RMAP_MAX_XFER_SIZE*4)+50]; |
|
402 | char buffer[(RMAP_MAX_XFER_SIZE*4)+50]; | |
331 | while (!this->isInterruptionRequested()) |
|
403 | while (!this->isInterruptionRequested()) | |
332 | { |
|
404 | { | |
333 | if(this->connected) |
|
405 | if(this->connected) | |
334 | { |
|
406 | { | |
335 | handleMutex->lock(); |
|
407 | handleMutex->lock(); | |
336 | SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4); |
|
408 | SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4); | |
337 | if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01)) |
|
409 | if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01)) | |
338 | { |
|
410 | { | |
339 | SocExplorerEngine::message(this->plugin,"Got packet",2); |
|
411 | SocExplorerEngine::message(this->plugin,"Got packet",2); | |
340 | stat = USBSpaceWire_ReadPackets(hDevice, buffer, (RMAP_MAX_XFER_SIZE*4)+50,1, 1, &properties, &pIdentifier); |
|
412 | stat = USBSpaceWire_ReadPackets(hDevice, buffer, (RMAP_MAX_XFER_SIZE*4)+50,1, 1, &properties, &pIdentifier); | |
341 | if (stat == TRANSFER_SUCCESS) |
|
413 | if (stat == TRANSFER_SUCCESS) | |
342 | { |
|
414 | { | |
343 | if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET) |
|
415 | if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET) | |
344 | { |
|
416 | { | |
345 | SocExplorerEngine::message(this->plugin,"It's a SPW packet",2); |
|
417 | SocExplorerEngine::message(this->plugin,"It's a SPW packet",2); | |
346 | if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP) |
|
418 | if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP) | |
347 | { |
|
419 | { | |
348 | SocExplorerEngine::message(this->plugin,"Got end of packet",2); |
|
420 | SocExplorerEngine::message(this->plugin,"Got end of packet",2); | |
|
421 | emit bytesReceivedFromSpw( properties.len ); | |||
349 | if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet |
|
422 | if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet | |
350 | { |
|
423 | { | |
351 | RMAP_Answer* packet; |
|
424 | RMAP_Answer* packet; | |
352 | SocExplorerEngine::message(this->plugin,"Got RMAP packet",2); |
|
425 | SocExplorerEngine::message(this->plugin,"Got RMAP packet",2); | |
353 | SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2); |
|
426 | SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2); | |
354 | char* packetbuffer = (char*)malloc(properties.len); |
|
427 | char* packetbuffer = (char*)malloc(properties.len); | |
355 | memcpy(packetbuffer,buffer,properties.len); |
|
428 | memcpy(packetbuffer,buffer,properties.len); | |
356 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
429 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
357 | pIdentifier = NULL; |
|
430 | pIdentifier = NULL; | |
358 | handleMutex->unlock(); |
|
431 | handleMutex->unlock(); | |
359 | if(properties.len==8) |
|
432 | if(properties.len==8) | |
360 | { |
|
433 | { | |
361 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len); |
|
434 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer),packetbuffer,properties.len); | |
362 | } |
|
435 | } | |
363 | else |
|
436 | else | |
364 | { |
|
437 | { | |
365 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); |
|
438 | packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); | |
366 | } |
|
439 | } | |
367 | RMAP_AnswersMtx->lock(); |
|
440 | RMAP_AnswersMtx->lock(); | |
368 | RMAP_Answers.append(packet); |
|
441 | RMAP_Answers.append(packet); | |
369 | RMAP_AnswersMtx->unlock(); |
|
442 | RMAP_AnswersMtx->unlock(); | |
370 | RMAP_AnswersSem->release(); |
|
443 | RMAP_AnswersSem->release(); | |
371 | } |
|
444 | } | |
372 | else //any non-rmap packet will be pushed to the network |
|
445 | else //any non-rmap packet will be pushed to the network | |
373 | { |
|
446 | { | |
374 | char* packetbuffer = (char*)malloc(properties.len); |
|
447 | char* packetbuffer = (char*)malloc(properties.len); | |
375 | memcpy(packetbuffer,buffer,properties.len); |
|
448 | memcpy(packetbuffer,buffer,properties.len); | |
376 | emit emitPacket(packetbuffer,properties.len); |
|
449 | emit emitPacket(packetbuffer,properties.len); | |
377 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
450 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
378 | handleMutex->unlock(); |
|
451 | handleMutex->unlock(); | |
379 | SocExplorerEngine::message(this->plugin,"Got SPW packet",2); |
|
452 | SocExplorerEngine::message(this->plugin,"Got SPW packet",2); | |
380 | } |
|
453 | } | |
381 | } |
|
454 | } | |
382 | else |
|
455 | else | |
383 | { |
|
456 | { | |
384 | SocExplorerEngine::message(this->plugin,"No EOP received",2); |
|
457 | SocExplorerEngine::message(this->plugin,"No EOP received",2); | |
385 | } |
|
458 | } | |
386 | } |
|
459 | } | |
387 |
|
460 | |||
388 | } |
|
461 | } | |
389 | else |
|
462 | else | |
390 | { |
|
463 | { | |
391 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
464 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
392 | handleMutex->unlock(); |
|
465 | handleMutex->unlock(); | |
393 | } |
|
466 | } | |
394 | } |
|
467 | } | |
395 | else |
|
468 | else | |
396 | { |
|
469 | { | |
397 | USBSpaceWire_FreeRead(hDevice, pIdentifier); |
|
470 | USBSpaceWire_FreeRead(hDevice, pIdentifier); | |
398 | handleMutex->unlock(); |
|
471 | handleMutex->unlock(); | |
399 | } |
|
472 | } | |
400 | } |
|
473 | } | |
401 | else |
|
474 | else | |
402 | { |
|
475 | { | |
403 | //do some sanity checks! |
|
476 | //do some sanity checks! | |
404 | int list = USBSpaceWire_ListDevices(); |
|
477 | int list = USBSpaceWire_ListDevices(); | |
405 | if(this->brickList!=list) |
|
478 | if(this->brickList!=list) | |
406 | { |
|
479 | { | |
407 | this->brickList = list; |
|
480 | this->brickList = list; | |
408 | emit updateAvailableBrickCount(this->brickList); |
|
481 | emit updateAvailableBrickCount(this->brickList); | |
409 | } |
|
482 | } | |
410 | usleep(RMAPtimeout/2); |
|
483 | usleep(RMAPtimeout/2); | |
411 | } |
|
484 | } | |
412 | usleep(1000); |
|
485 | usleep(1000); | |
413 | } |
|
486 | } | |
414 | SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1); |
|
487 | SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1); | |
415 | } |
|
488 | } | |
416 |
|
489 | |||
417 | bool stardundeeSPW_USB_Manager::connectBridge() |
|
490 | bool stardundeeSPW_USB_Manager::connectBridge() | |
418 | { |
|
491 | { | |
|
492 | bool ret; | |||
|
493 | ||||
|
494 | if (this->interfaceMode == BRICK_IS_SET_AS_AN_INTERFACE) | |||
|
495 | { | |||
|
496 | ret = connectBridgeAsInterface(); | |||
|
497 | } | |||
|
498 | else if (this->interfaceMode == BRICK_IS_SET_AS_A_ROUTER) | |||
|
499 | { | |||
|
500 | ret = connectBridgeAsRouter(); | |||
|
501 | } | |||
|
502 | else | |||
|
503 | { | |||
|
504 | ret = false; | |||
|
505 | } | |||
|
506 | ||||
|
507 | return ret; | |||
|
508 | } | |||
|
509 | ||||
|
510 | bool stardundeeSPW_USB_Manager::connectBridgeAsInterface() | |||
|
511 | { | |||
419 | QMutexLocker mlock(this->handleMutex); |
|
512 | QMutexLocker mlock(this->handleMutex); | |
420 | int status; |
|
513 | int status; | |
421 | U32 statusControl; |
|
514 | U32 statusControl; | |
422 | this->connected = false; |
|
515 | this->connected = false; | |
423 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device |
|
516 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device | |
424 | { |
|
517 | { | |
425 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0); |
|
518 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0); | |
426 | return false; |
|
519 | return false; | |
427 | } |
|
520 | } | |
428 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0); |
|
521 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0); | |
429 |
|
522 | |||
430 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode |
|
523 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode | |
431 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration |
|
524 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration | |
432 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices |
|
525 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices | |
433 |
|
526 | |||
434 | // Set the path and return path to the device |
|
527 | // Set the path and return path to the device | |
435 | CFGSpaceWire_StackClear(); |
|
528 | CFGSpaceWire_StackClear(); | |
436 | CFGSpaceWire_AddrStackPush(0); |
|
529 | CFGSpaceWire_AddrStackPush(0); | |
437 | CFGSpaceWire_AddrStackPush(254); |
|
530 | CFGSpaceWire_AddrStackPush(254); | |
438 | CFGSpaceWire_RetAddrStackPush(254); |
|
531 | CFGSpaceWire_RetAddrStackPush(254); | |
439 | // set the base transmit rate to 100 MHz |
|
532 | // set the base transmit rate to 100 MHz | |
440 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); |
|
533 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); | |
441 | if (status != CFG_TRANSFER_SUCCESS) |
|
534 | if (status != CFG_TRANSFER_SUCCESS) | |
442 | { |
|
535 | { | |
443 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1); |
|
536 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1); | |
444 | return false; |
|
537 | return false; | |
445 | } |
|
538 | } | |
446 | else |
|
539 | else | |
447 | { |
|
540 | { | |
448 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz",1); |
|
541 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz",1); | |
449 | } |
|
542 | } | |
450 |
|
543 | |||
451 | // read the link status |
|
544 | // read the link status | |
452 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) |
|
545 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |
453 | { |
|
546 | { | |
454 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1); |
|
547 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1); | |
455 | return false; |
|
548 | return false; | |
456 | } |
|
549 | } | |
457 | else |
|
550 | else | |
458 | { |
|
551 | { | |
459 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(this->linkNumber),1); |
|
552 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(this->linkNumber),1); | |
460 |
|
553 | |||
461 | // Set the link status control register properties |
|
554 | // Set the link status control register properties | |
462 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); |
|
555 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |
463 | CFGSpaceWire_LSEnableStart(&statusControl, 1); |
|
556 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |
464 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); |
|
557 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |
465 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); |
|
558 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |
466 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz |
|
559 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |
467 |
|
560 | |||
468 | // Set the link status control register |
|
561 | // Set the link status control register | |
469 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) |
|
562 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |
470 | { |
|
563 | { | |
471 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1); |
|
564 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1); | |
472 | return false; |
|
565 | return false; | |
473 | } |
|
566 | } | |
474 | else |
|
567 | else | |
475 | { |
|
568 | { | |
476 | SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(this->linkNumber),1); |
|
569 | SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(this->linkNumber),1); | |
477 | } |
|
570 | } | |
478 | } |
|
571 | } | |
479 |
|
572 | |||
480 | if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) |
|
573 | if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) | |
481 | { |
|
574 | { | |
482 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1); |
|
575 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1); | |
483 | return false; |
|
576 | return false; | |
484 | } |
|
577 | } | |
485 | else |
|
578 | else | |
486 | { |
|
579 | { | |
487 | SocExplorerEngine::message(this->plugin,"Device set to be an interface",1); |
|
580 | SocExplorerEngine::message(this->plugin,"Device set to be an interface",1); | |
488 | } |
|
581 | } | |
489 |
|
582 | |||
490 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports |
|
583 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports | |
491 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints |
|
584 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints | |
492 | USBSpaceWire_SetTimeout(hDevice,1.0); |
|
585 | USBSpaceWire_SetTimeout(hDevice,1.0); | |
493 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1); |
|
586 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1); | |
494 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1); |
|
587 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1); | |
495 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1); |
|
588 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1); | |
496 | this->connected = true; |
|
589 | this->connected = true; | |
497 | return true; |
|
590 | return true; | |
498 | } |
|
591 | } | |
499 |
|
592 | |||
|
593 | bool stardundeeSPW_USB_Manager::connectBridgeAsRouter() | |||
|
594 | { | |||
|
595 | QMutexLocker mlock(this->handleMutex); | |||
|
596 | int status; | |||
|
597 | U32 statusControl; | |||
|
598 | unsigned int linkStatus1; | |||
|
599 | unsigned int linkStatus2; | |||
|
600 | unsigned char linkNumber; | |||
|
601 | unsigned char deviceIsAnInterface; | |||
|
602 | ||||
|
603 | if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device | |||
|
604 | { | |||
|
605 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))"); | |||
|
606 | return false; | |||
|
607 | } | |||
|
608 | SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful, device number: " | |||
|
609 | + QString::number(this->selectedBrick)); | |||
|
610 | ||||
|
611 | USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode | |||
|
612 | CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration | |||
|
613 | CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices | |||
|
614 | ||||
|
615 | // Set the path and return path to the device | |||
|
616 | // This affects just the operations performed by the Configuration Library and does not affect the packets | |||
|
617 | // sent and received using the driver API. | |||
|
618 | CFGSpaceWire_StackClear(); | |||
|
619 | CFGSpaceWire_AddrStackPush(0); | |||
|
620 | CFGSpaceWire_AddrStackPush(254); | |||
|
621 | CFGSpaceWire_RetAddrStackPush(254); | |||
|
622 | ||||
|
623 | // set the base transmit rate to 100 MHz | |||
|
624 | status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); | |||
|
625 | if (status != CFG_TRANSFER_SUCCESS) | |||
|
626 | { | |||
|
627 | SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate"); | |||
|
628 | } | |||
|
629 | else SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz"); | |||
|
630 | ||||
|
631 | //********************* | |||
|
632 | // LINK 1 CONFIGURATION | |||
|
633 | linkNumber = 1; | |||
|
634 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |||
|
635 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); | |||
|
636 | else | |||
|
637 | { | |||
|
638 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); | |||
|
639 | ||||
|
640 | // Set the link status control register properties | |||
|
641 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |||
|
642 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |||
|
643 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |||
|
644 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |||
|
645 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |||
|
646 | ||||
|
647 | // Set the link status control register | |||
|
648 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |||
|
649 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); | |||
|
650 | else | |||
|
651 | SocExplorerEngine::message(this->plugin,"link status control for link " + QString::number(0x01) + " is set"); | |||
|
652 | } | |||
|
653 | ||||
|
654 | //********************* | |||
|
655 | // LINK 2 CONFIGURATION | |||
|
656 | linkNumber = 2; | |||
|
657 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) | |||
|
658 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); | |||
|
659 | else | |||
|
660 | { | |||
|
661 | SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); | |||
|
662 | ||||
|
663 | // Set the link status control register properties | |||
|
664 | CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); | |||
|
665 | CFGSpaceWire_LSEnableStart(&statusControl, 1); | |||
|
666 | CFGSpaceWire_LSEnableDisabled(&statusControl, 0); | |||
|
667 | CFGSpaceWire_LSEnableTristate(&statusControl, 0); | |||
|
668 | CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz | |||
|
669 | ||||
|
670 | // Set the link status control register | |||
|
671 | if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) | |||
|
672 | SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); | |||
|
673 | else | |||
|
674 | SocExplorerEngine::message(this->plugin,"link status control for link " + QString::number(linkNumber) + " is set"); | |||
|
675 | } | |||
|
676 | ||||
|
677 | //*************************** | |||
|
678 | // SET THE DEVICE AS A ROUTER | |||
|
679 | deviceIsAnInterface = 0; // 0 = router, 1 = interface | |||
|
680 | if (CFGSpaceWire_SetAsInterface(hDevice, deviceIsAnInterface, 0) != CFG_TRANSFER_SUCCESS) | |||
|
681 | SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface"); | |||
|
682 | else | |||
|
683 | SocExplorerEngine::message(this->plugin,"Device is an interface: " + QString::number(deviceIsAnInterface) + " (1 => true, 0 => false)"); | |||
|
684 | ||||
|
685 | setRoutingTableEntry(0xfe, 0x02, 0); // [0010] => route 0xfe on port 1 | |||
|
686 | setRoutingTableEntry(32 , 0x08, 0); // [1000] => route 32 on port 3 | |||
|
687 | ||||
|
688 | USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on port 1 only | |||
|
689 | USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints | |||
|
690 | ||||
|
691 | SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes"); | |||
|
692 | SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes"); | |||
|
693 | SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice))); | |||
|
694 | ||||
|
695 | //************ | |||
|
696 | // test Link 1 and Link 2 | |||
|
697 | linkStatus1 = getLinkStatus(0x01); | |||
|
698 | linkStatus2 = getLinkStatus(0x02); | |||
|
699 | ||||
|
700 | if ((linkStatus1==1) || (linkStatus2==1)) | |||
|
701 | { | |||
|
702 | initializeTimecodeGeneration(); | |||
|
703 | this->connected=true; | |||
|
704 | return true; | |||
|
705 | } | |||
|
706 | else | |||
|
707 | { | |||
|
708 | statusLink1->setText("Link 1 status code: " + QString::number(linkStatus1)); | |||
|
709 | statusLink2->setText("Link 2 status code: " + QString::number(linkStatus2)); | |||
|
710 | starDundeeStatusQueryDialog->exec(); | |||
|
711 | this->connected = false; | |||
|
712 | return false; | |||
|
713 | } | |||
|
714 | } | |||
|
715 | ||||
|
716 | void stardundeeSPW_USB_Manager::initDialog( void ) | |||
|
717 | { | |||
|
718 | // STAR DUNDEE STATUS QUERY DIALOG | |||
|
719 | starDundeeStatusQueryDialog = new QDialog; | |||
|
720 | starDundeeStatusQueryDialogLayout = new QGridLayout; | |||
|
721 | starDundeeStatusQueryDialogLabel = new QLabel(tr("SpaceWire links state")); | |||
|
722 | starDundeeStatusQueryContinueButton = new QPushButton(tr("Continue")); | |||
|
723 | starDundeeStatusQueryRetryButton = new QPushButton(tr("Retry")); | |||
|
724 | starDundeeStatusQueryAbortButton = new QPushButton(tr("Abort")); | |||
|
725 | statusLink1 = new QLabel(tr("Link 1 status code: -")); | |||
|
726 | statusLink2 = new QLabel(tr("Link 2 status code: -")); | |||
|
727 | ||||
|
728 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryDialogLabel, 0, 0, 1, 2); | |||
|
729 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryContinueButton, 1, 0, 0); | |||
|
730 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryRetryButton, 1, 1, 0); | |||
|
731 | starDundeeStatusQueryDialogLayout->addWidget(starDundeeStatusQueryAbortButton, 1, 2, 0); | |||
|
732 | starDundeeStatusQueryDialogLayout->addWidget(statusLink1, 2, 0, 0); | |||
|
733 | starDundeeStatusQueryDialogLayout->addWidget(statusLink2, 3, 0, 0); | |||
|
734 | starDundeeStatusQueryDialog->setLayout(starDundeeStatusQueryDialogLayout); | |||
|
735 | } | |||
|
736 | ||||
|
737 | unsigned char stardundeeSPW_USB_Manager::setRoutingTableEntry(int tableEntry, U32 dwOutputPorts, char bDelHead) | |||
|
738 | { | |||
|
739 | U32 routingTableEntry; | |||
|
740 | // SET THE ROUTING TABLE ENTRY FOR LOGICAL ADDRESSING, TARGET entryNumber | |||
|
741 | if (CFGSpaceWire_ClearRoutingTableEntry(hDevice, tableEntry) != CFG_TRANSFER_SUCCESS) | |||
|
742 | { | |||
|
743 | SocExplorerEngine::message(this->plugin,"Could not clear routing table entry " + QString::number(tableEntry)); | |||
|
744 | } | |||
|
745 | // Build the routing table entry | |||
|
746 | CFGSpaceWire_RTBuildRoutingTableEntry(&routingTableEntry, | |||
|
747 | dwOutputPorts, // route out of port dwOutputPorts | |||
|
748 | bDelHead, // header deletion is enabled [1] or disabled [0] | |||
|
749 | 0); // priority normal | |||
|
750 | // Set the routing table entry for logical address tableEntry | |||
|
751 | if (CFGSpaceWire_SetRoutingTableEntry(hDevice, tableEntry, routingTableEntry) != CFG_TRANSFER_SUCCESS) | |||
|
752 | { | |||
|
753 | SocExplorerEngine::message(this->plugin,"Could not set routing table entry [" + QString::number(tableEntry) + "]"); | |||
|
754 | } | |||
|
755 | else SocExplorerEngine::message(this->plugin,"Routing table entry [" + QString::number(tableEntry) + "] set" ); | |||
|
756 | return 1; | |||
|
757 | } | |||
|
758 | ||||
|
759 | unsigned int stardundeeSPW_USB_Manager::getRoutingTableEntry(int tableEntry) | |||
|
760 | { | |||
|
761 | U32 routingTableEntry, outputPorts; | |||
|
762 | char enabled, delHead, priority; | |||
|
763 | int portNum; | |||
|
764 | ||||
|
765 | SocExplorerEngine::message(this->plugin,"GetRoutingTableEntry [" + QString::number(tableEntry) + "]"); | |||
|
766 | // Read the routing table entry | |||
|
767 | if (CFGSpaceWire_GetRoutingTableEntry(hDevice, tableEntry, &routingTableEntry) != CFG_TRANSFER_SUCCESS) | |||
|
768 | { | |||
|
769 | SocExplorerEngine::message(this->plugin,"Could not read routing table entry [" + QString::number(tableEntry) + "]"); | |||
|
770 | } | |||
|
771 | else | |||
|
772 | { | |||
|
773 | // Display the routing table entry properties | |||
|
774 | CFGSpaceWire_RTIsEnabled(routingTableEntry, &enabled); | |||
|
775 | CFGSpaceWire_RTIsDelHead(routingTableEntry, &delHead); | |||
|
776 | CFGSpaceWire_RTIsPriority(routingTableEntry, &priority); | |||
|
777 | CFGSpaceWire_RTGetOutputPorts(routingTableEntry, &outputPorts); | |||
|
778 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsEnabled : " + QString::number(enabled)); | |||
|
779 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsDelHead : " + QString::number(delHead)); | |||
|
780 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTIsPriority : " + QString::number(priority)); | |||
|
781 | SocExplorerEngine::message(this->plugin,"CFGSpaceWire_RTGetOutputPorts : "); | |||
|
782 | for (portNum = 0; portNum < 32; portNum++) | |||
|
783 | { | |||
|
784 | if (outputPorts & (1 << portNum)) | |||
|
785 | { | |||
|
786 | SocExplorerEngine::message(this->plugin,QString::number(portNum)); | |||
|
787 | } | |||
|
788 | } | |||
|
789 | } | |||
|
790 | ||||
|
791 | return 1; | |||
|
792 | } | |||
|
793 | ||||
|
794 | void stardundeeSPW_USB_Manager::initializeTimecodeGeneration() | |||
|
795 | { | |||
|
796 | U32 dwTickEnableStatus; | |||
|
797 | U32 rtr_clk_freq; | |||
|
798 | ||||
|
799 | // (1) RESET | |||
|
800 | if (!USBSpaceWire_TC_Reset(hDevice)) | |||
|
801 | SocExplorerEngine::message(this->plugin,"ERR *** in Open *** Could not reset timecodes\n"); | |||
|
802 | ||||
|
803 | // (2) Clear the tick enable register | |||
|
804 | if (CFGSpaceWire_SetTickEnableStatus(hDevice, 6) != CFG_TRANSFER_SUCCESS) | |||
|
805 | SocExplorerEngine::message(this->plugin,"Could not clear the tick enable register"); | |||
|
806 | else | |||
|
807 | SocExplorerEngine::message(this->plugin,"Cleared the tick enable register"); | |||
|
808 | ||||
|
809 | // (3) get the tick status | |||
|
810 | CFGSpaceWire_GetTickEnableStatus(hDevice, &dwTickEnableStatus); | |||
|
811 | SocExplorerEngine::message(this->plugin,"OK *** in Open *** CFGSpaceWire_GetTickEnableStatus, code is " + QString::number(dwTickEnableStatus, 2)); | |||
|
812 | ||||
|
813 | // (4) enable external timecode selection | |||
|
814 | if(!USBSpaceWire_TC_EnableExternalTimecodeSelection(hDevice,0)) | |||
|
815 | SocExplorerEngine::message(this->plugin,"ERR *** disable external timecode selection"); | |||
|
816 | ||||
|
817 | rtr_clk_freq = USBSpaceWire_TC_GetClockFrequency(hDevice); | |||
|
818 | ||||
|
819 | SocExplorerEngine::message(this->plugin,"clock frequency = " + QString::number(rtr_clk_freq) ); | |||
|
820 | ||||
|
821 | //************************************************** | |||
|
822 | // auto _ tick _ freq = rtr _ clk _ freq / freqCount | |||
|
823 | if (!USBSpaceWire_TC_SetAutoTickInFrequency(hDevice, rtr_clk_freq) ) | |||
|
824 | SocExplorerEngine::message(this->plugin,"Could not set the tick-in frequency"); | |||
|
825 | } | |||
|
826 | ||||
|
827 | unsigned int stardundeeSPW_USB_Manager::getLinkStatus(unsigned char link) | |||
|
828 | { | |||
|
829 | U32 statusControl, errorStatus, portType; | |||
|
830 | U32 linkStatus, operatingSpeed, outputPortConnection; | |||
|
831 | char isLinkRunning, isAutoStart, isStart, isDisabled, isTristate; | |||
|
832 | ||||
|
833 | // Read the link status control register | |||
|
834 | if (CFGSpaceWire_GetLinkStatusControl(hDevice, link, &statusControl) != CFG_TRANSFER_SUCCESS) | |||
|
835 | { | |||
|
836 | SocExplorerEngine::message(this->plugin,"Could not read link status control for link" + QString::number(link)); | |||
|
837 | } | |||
|
838 | else | |||
|
839 | { | |||
|
840 | // Display the link status control register properties | |||
|
841 | CFGSpaceWire_LSPortType(statusControl, &portType); | |||
|
842 | if (portType == CFG_CONFIGURATION_PORT) | |||
|
843 | { | |||
|
844 | CFGSpaceWire_LSConfigErrorStatus(statusControl, &errorStatus); | |||
|
845 | } | |||
|
846 | else if (portType == CFG_SPACEWIRE_EXTERNAL_PORT) | |||
|
847 | { | |||
|
848 | CFGSpaceWire_LSExternalErrorStatus(statusControl, &errorStatus); | |||
|
849 | } | |||
|
850 | else | |||
|
851 | { | |||
|
852 | CFGSpaceWire_LSErrorStatus(statusControl, &errorStatus); | |||
|
853 | } | |||
|
854 | CFGSpaceWire_LSLinkState(statusControl, &linkStatus); | |||
|
855 | CFGSpaceWire_LSIsLinkRunning(statusControl, &isLinkRunning); | |||
|
856 | CFGSpaceWire_LSIsAutoStart(statusControl, &isAutoStart); | |||
|
857 | CFGSpaceWire_LSIsStart(statusControl, &isStart); | |||
|
858 | CFGSpaceWire_LSIsDisabled(statusControl, &isDisabled); | |||
|
859 | CFGSpaceWire_LSIsTristate(statusControl, &isTristate); | |||
|
860 | CFGSpaceWire_LSOperatingSpeed(statusControl, &operatingSpeed); | |||
|
861 | CFGSpaceWire_LSOutputPortConnection(statusControl, &outputPortConnection); | |||
|
862 | } | |||
|
863 | SocExplorerEngine::message(this->plugin,"status of link " + QString::number(link) | |||
|
864 | +" is " + dwLinkStatusQString[linkStatus]); | |||
|
865 | if (linkStatus == 5) | |||
|
866 | { | |||
|
867 | return 1; | |||
|
868 | } | |||
|
869 | else return 0; | |||
|
870 | } | |||
|
871 | ||||
500 | bool stardundeeSPW_USB_Manager::disconnectBridge() |
|
872 | bool stardundeeSPW_USB_Manager::disconnectBridge() | |
501 | { |
|
873 | { | |
502 | this->handleMutex->lock(); |
|
874 | this->handleMutex->lock(); | |
503 | USBSpaceWire_Close(hDevice); // Close the device |
|
875 | USBSpaceWire_Close(hDevice); // Close the device | |
504 | SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0); |
|
876 | SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0); | |
505 | USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports |
|
877 | USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports | |
506 | this->handleMutex->unlock(); |
|
878 | this->handleMutex->unlock(); | |
507 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
879 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
508 | this->RMAP_pending_transaction_IDs.clear(); |
|
880 | this->RMAP_pending_transaction_IDs.clear(); | |
509 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
881 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
510 | this->RMAP_AnswersMtx->lock(); |
|
882 | this->RMAP_AnswersMtx->lock(); | |
511 | this->RMAP_Answers.clear(); |
|
883 | this->RMAP_Answers.clear(); | |
512 | this->RMAP_AnswersMtx->unlock(); |
|
884 | this->RMAP_AnswersMtx->unlock(); | |
513 | this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available()); |
|
885 | this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available()); | |
514 | return true; |
|
886 | return true; | |
515 | } |
|
887 | } | |
516 |
|
888 | |||
517 | int stardundeeSPW_USB_Manager::getRMAPtransactionID() |
|
889 | int stardundeeSPW_USB_Manager::getRMAPtransactionID() | |
518 | { |
|
890 | { | |
519 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
891 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
520 | int ID=0; |
|
892 | int ID=0; | |
521 | bool found=true; |
|
893 | bool found=true; | |
522 | while(ID<511) |
|
894 | while(ID<511) | |
523 | { |
|
895 | { | |
524 | for(int i=0;i<RMAP_pending_transaction_IDs.count();i++) |
|
896 | for(int i=0;i<RMAP_pending_transaction_IDs.count();i++) | |
525 | { |
|
897 | { | |
526 | if(RMAP_pending_transaction_IDs[i]==ID)found=false; |
|
898 | if(RMAP_pending_transaction_IDs[i]==ID)found=false; | |
527 | } |
|
899 | } | |
528 | if(found==true)break; |
|
900 | if(found==true)break; | |
529 | ID++; |
|
901 | ID++; | |
530 | found = true; |
|
902 | found = true; | |
531 | } |
|
903 | } | |
532 | if(found) |
|
904 | if(found) | |
533 | { |
|
905 | { | |
534 | RMAP_pending_transaction_IDs.append(ID); |
|
906 | RMAP_pending_transaction_IDs.append(ID); | |
535 | } |
|
907 | } | |
536 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
908 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
537 | return ID; |
|
909 | return ID; | |
538 | } |
|
910 | } | |
539 |
|
911 | |||
540 | int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer) |
|
912 | int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer) | |
541 | { |
|
913 | { | |
542 | QTime timeout; |
|
914 | QTime timeout; | |
543 | *buffer=NULL; |
|
915 | *buffer=NULL; | |
544 | int count=0; |
|
916 | int count=0; | |
545 | SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2); |
|
917 | SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2); | |
546 | timeout.start(); |
|
918 | timeout.start(); | |
547 | while (*buffer==NULL) |
|
919 | while (*buffer==NULL) | |
548 | { |
|
920 | { | |
549 | this->RMAP_AnswersMtx->lock(); |
|
921 | this->RMAP_AnswersMtx->lock(); | |
550 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2); |
|
922 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2); | |
551 | SocExplorerEngine::message(this->plugin,QString("%1 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2); |
|
923 | SocExplorerEngine::message(this->plugin,QString("%1 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2); | |
552 | for(int i=0;i<RMAP_Answers.count();i++) |
|
924 | for(int i=0;i<RMAP_Answers.count();i++) | |
553 | { |
|
925 | { | |
554 | SocExplorerEngine::message(this->plugin,QString("Packet %1 ID=%2").arg(i).arg(RMAP_Answers[i]->transactionID),2); |
|
926 | SocExplorerEngine::message(this->plugin,QString("Packet %1 ID=%2").arg(i).arg(RMAP_Answers[i]->transactionID),2); | |
555 | if(RMAP_Answers[i]->transactionID==transactionID) |
|
927 | if(RMAP_Answers[i]->transactionID==transactionID) | |
556 | { |
|
928 | { | |
557 | this->RMAP_pending_transaction_IDsMtx->lock(); |
|
929 | this->RMAP_pending_transaction_IDsMtx->lock(); | |
558 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2); |
|
930 | SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2); | |
559 | for(int j=0;j<RMAP_pending_transaction_IDs.count();j++) |
|
931 | for(int j=0;j<RMAP_pending_transaction_IDs.count();j++) | |
560 | { |
|
932 | { | |
561 | if(RMAP_pending_transaction_IDs[j]==transactionID) |
|
933 | if(RMAP_pending_transaction_IDs[j]==transactionID) | |
562 | { |
|
934 | { | |
563 | RMAP_pending_transaction_IDs.removeAt(j); |
|
935 | RMAP_pending_transaction_IDs.removeAt(j); | |
564 | } |
|
936 | } | |
565 | } |
|
937 | } | |
566 | this->RMAP_pending_transaction_IDsMtx->unlock(); |
|
938 | this->RMAP_pending_transaction_IDsMtx->unlock(); | |
567 | *buffer = RMAP_Answers[i]->data; |
|
939 | *buffer = RMAP_Answers[i]->data; | |
568 | count = RMAP_Answers[i]->len; |
|
940 | count = RMAP_Answers[i]->len; | |
569 | RMAP_Answer* tmp=RMAP_Answers[i]; |
|
941 | RMAP_Answer* tmp=RMAP_Answers[i]; | |
570 | RMAP_Answers.removeAt(i); |
|
942 | RMAP_Answers.removeAt(i); | |
571 | delete tmp; |
|
943 | delete tmp; | |
572 | } |
|
944 | } | |
573 | } |
|
945 | } | |
574 | this->RMAP_AnswersMtx->unlock(); |
|
946 | this->RMAP_AnswersMtx->unlock(); | |
575 | //if no answer found in the stack wait until a new packet is pushed |
|
947 | //if no answer found in the stack wait until a new packet is pushed | |
576 | SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2); |
|
948 | SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2); | |
577 | if(*buffer==NULL) |
|
949 | if(*buffer==NULL) | |
578 | { |
|
950 | { | |
579 | while (0==this->RMAP_AnswersSem->available()) |
|
951 | while (0==this->RMAP_AnswersSem->available()) | |
580 | { |
|
952 | { | |
581 | SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2); |
|
953 | SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2); | |
582 | if(timeout.elapsed()>=RMAPtimeout) |
|
954 | if(timeout.elapsed()>=RMAPtimeout) | |
583 | { |
|
955 | { | |
584 | SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2); |
|
956 | SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2); | |
585 | return -1; |
|
957 | return -1; | |
586 | } |
|
958 | } | |
587 | usleep(1000); |
|
959 | usleep(1000); | |
588 | } |
|
960 | } | |
589 | this->RMAP_AnswersSem->acquire(); |
|
961 | this->RMAP_AnswersSem->acquire(); | |
590 | } |
|
962 | } | |
591 | } |
|
963 | } | |
592 | return count; |
|
964 | return count; | |
593 | } |
|
965 | } | |
594 |
|
966 | |||
595 | bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size) |
|
967 | bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size) | |
596 | { |
|
968 | { | |
597 | USB_SPACEWIRE_STATUS result; |
|
969 | USB_SPACEWIRE_STATUS result; | |
598 | USB_SPACEWIRE_ID pIdentifier; |
|
970 | USB_SPACEWIRE_ID pIdentifier; | |
599 | SocExplorerEngine::message(this->plugin,"Sending SPW packet",2); |
|
971 | SocExplorerEngine::message(this->plugin,"Sending SPW packet",2); | |
600 | this->handleMutex->lock(); |
|
972 | this->handleMutex->lock(); | |
601 | result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier); |
|
973 | result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier); | |
602 | if (result != TRANSFER_SUCCESS) |
|
974 | if (result != TRANSFER_SUCCESS) | |
603 | { |
|
975 | { | |
604 | SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2); |
|
976 | SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2); | |
605 | this->handleMutex->unlock(); |
|
977 | this->handleMutex->unlock(); | |
606 | return false; |
|
978 | return false; | |
607 | } |
|
979 | } | |
608 | else |
|
980 | else | |
609 | { |
|
981 | { | |
|
982 | emit bytesTransmittedToSpw( size-1 ); // -1 is for removing the first bytes added to the packet to route to the right link | |||
610 | SocExplorerEngine::message(this->plugin,"Packet sent",2); |
|
983 | SocExplorerEngine::message(this->plugin,"Packet sent",2); | |
611 | USBSpaceWire_FreeSend(hDevice, pIdentifier); |
|
984 | USBSpaceWire_FreeSend(hDevice, pIdentifier); | |
612 | } |
|
985 | } | |
613 | this->handleMutex->unlock(); |
|
986 | this->handleMutex->unlock(); | |
614 | return true; |
|
987 | return true; | |
615 | } |
|
988 | } | |
616 |
|
989 | |||
617 | void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len) |
|
990 | void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len) | |
618 | { |
|
991 | { | |
619 | char* packetbuffer = (char*)malloc(len); |
|
992 | char* packetbuffer = (char*)malloc(len); | |
620 | memcpy(packetbuffer,packet,len); |
|
993 | memcpy(packetbuffer,packet,len); | |
621 | RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len); |
|
994 | RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len); | |
622 | RMAP_AnswersMtx->lock(); |
|
995 | RMAP_AnswersMtx->lock(); | |
623 | RMAP_Answers.append(RMPAPpacket); |
|
996 | RMAP_Answers.append(RMPAPpacket); | |
624 | RMAP_AnswersMtx->unlock(); |
|
997 | RMAP_AnswersMtx->unlock(); | |
625 | } |
|
998 | } | |
626 |
|
999 | |||
627 |
|
1000 | |||
628 |
|
1001 | |||
629 |
|
1002 | |||
630 |
|
1003 | |||
631 |
|
1004 | |||
632 |
|
1005 | |||
633 |
|
1006 | |||
634 |
|
1007 | |||
635 |
|
1008 | |||
636 |
|
1009 | |||
637 |
|
1010 | |||
638 |
|
1011 | |||
639 |
|
1012 | |||
640 |
|
1013 | |||
641 |
|
1014 | |||
642 |
|
1015 | |||
643 |
|
1016 | |||
644 |
|
1017 | |||
645 |
|
1018 | |||
646 |
|
1019 | |||
647 |
|
1020 |
@@ -1,116 +1,144 | |||||
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 |
|
39 | #define BRICK_IS_SET_AS_AN_INTERFACE true | ||
|
40 | #define BRICK_IS_SET_AS_A_ROUTER false | |||
40 |
|
41 | |||
41 | class stardundeeSPW_USB_Manager: public QThread |
|
42 | class stardundeeSPW_USB_Manager: public QThread | |
42 | { |
|
43 | { | |
43 | Q_OBJECT |
|
44 | Q_OBJECT | |
44 | public: |
|
45 | public: | |
45 | explicit stardundeeSPW_USB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0); |
|
46 | explicit stardundeeSPW_USB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0); | |
46 | ~stardundeeSPW_USB_Manager(); |
|
47 | ~stardundeeSPW_USB_Manager(); | |
47 | void run(); |
|
48 | void run(); | |
48 | bool connectBridge(); |
|
49 | bool connectBridge(); | |
|
50 | bool connectBridgeAsInterface(); | |||
|
51 | bool connectBridgeAsRouter(); | |||
|
52 | void initDialog( void ); | |||
|
53 | unsigned char setRoutingTableEntry(int tableEntry, U32 dwOutputPorts, char bDelHead); | |||
|
54 | unsigned int getRoutingTableEntry(int tableEntry); | |||
|
55 | void initializeTimecodeGeneration(); | |||
|
56 | unsigned int getLinkStatus(unsigned char link); | |||
49 | bool disconnectBridge(); |
|
57 | bool disconnectBridge(); | |
50 | int getRMAPtransactionID(); |
|
58 | int getRMAPtransactionID(); | |
51 | int getRMAPanswer(int transactionID,char** buffer); |
|
59 | int getRMAPanswer(int transactionID,char** buffer); | |
52 | bool sendPacket(char* packet,int size); |
|
60 | bool sendPacket(char* packet,int size); | |
53 |
|
61 | |||
54 | signals: |
|
62 | signals: | |
55 | void updateAvailableBrickCount(int count); |
|
63 | void updateAvailableBrickCount(int count); | |
56 | void emitPacket(char* packet,int size); |
|
64 | void emitPacket(char* packet,int size); | |
|
65 | void bytesReceivedFromSpw( unsigned int ); | |||
|
66 | void bytesTransmittedToSpw( unsigned int); | |||
|
67 | ||||
57 | private: |
|
68 | private: | |
58 | QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx; |
|
69 | QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx; | |
59 | QSemaphore* RMAP_AnswersSem; |
|
70 | QSemaphore* RMAP_AnswersSem; | |
60 | void pushRmapPacket(char* packet,int len); |
|
71 | void pushRmapPacket(char* packet,int len); | |
61 | star_device_handle hDevice; |
|
72 | star_device_handle hDevice; | |
62 | socexplorerplugin* plugin; |
|
73 | socexplorerplugin* plugin; | |
63 | bool connected; |
|
74 | bool connected; | |
64 | char* SPWPacketBuff; |
|
75 | char* SPWPacketBuff; | |
65 | QList<RMAP_Answer*> RMAP_Answers; |
|
76 | QList<RMAP_Answer*> RMAP_Answers; | |
66 | QList<int> RMAP_pending_transaction_IDs; |
|
77 | QList<int> RMAP_pending_transaction_IDs; | |
67 |
|
78 | |||
|
79 | QLabel *starDundeeStatusQueryDialogLabel; | |||
|
80 | QPushButton *starDundeeStatusQueryRetryButton; | |||
|
81 | QPushButton *starDundeeStatusQueryAbortButton; | |||
|
82 | QLabel *statusLink1; | |||
|
83 | QLabel *statusLink2; | |||
|
84 | QPushButton *starDundeeStatusQueryContinueButton; | |||
|
85 | QDialog *starDundeeStatusQueryDialog; | |||
|
86 | QGridLayout *starDundeeStatusQueryDialogLayout; | |||
|
87 | ||||
68 | public: |
|
88 | public: | |
69 | int selectedBrick; |
|
89 | int selectedBrick; | |
70 | int linkNumber; |
|
90 | int linkNumber; | |
71 | int brickList; |
|
91 | int brickList; | |
72 | int linkSpeed; |
|
92 | int linkSpeed; | |
|
93 | int sourceLogicalAddress; | |||
|
94 | int destinationLogicalAddress; | |||
73 | int destinationKey; |
|
95 | int destinationKey; | |
74 | int rmapAddress; |
|
|||
75 | int rmapKey; |
|
|||
76 | int RMAPtimeout; |
|
96 | int RMAPtimeout; | |
|
97 | bool interfaceMode; // 1 => interface mode, 0 => router mode | |||
77 | }; |
|
98 | }; | |
78 |
|
99 | |||
79 | class stardundeeSPW_USB : public abstractSpwBridge |
|
100 | class stardundeeSPW_USB : public abstractSpwBridge | |
80 | { |
|
101 | { | |
81 | Q_OBJECT |
|
102 | Q_OBJECT | |
82 | public: |
|
103 | public: | |
83 | explicit stardundeeSPW_USB(socexplorerplugin *parent = 0); |
|
104 | explicit stardundeeSPW_USB(socexplorerplugin *parent = 0); | |
84 | ~stardundeeSPW_USB(); |
|
105 | ~stardundeeSPW_USB(); | |
85 |
|
106 | |||
86 | signals: |
|
107 | signals: | |
87 |
|
108 | |||
88 | void setRmapTimeout(const QString & timeout); |
|
109 | void setRmapTimeout(const QString & timeout); | |
89 | void SelectBrick(int brickIndex); |
|
110 | void SelectBrick(int brickIndex); | |
90 | void SelectLinkNumber(int linkIndex); |
|
111 | void SelectLinkNumber(int linkIndex); | |
91 | void SelectLinkSpeed(int linkSpeed); |
|
112 | void SelectLinkSpeed(int linkSpeed); | |
92 | void SetDestinationKey(const QString & destKey); |
|
113 | void SetDestinationKey(const QString & destKey); | |
93 | void SetRmapAddress(const QString & address); |
|
114 | void SetRmapAddress(const QString & address); | |
94 | void SetRmapKey(const QString & key); |
|
115 | void SetRmapKey(const QString & key); | |
95 | void SetRmapTimeout(const QString & timeout); |
|
116 | void SetRmapTimeout(const QString & timeout); | |
|
117 | void SetBrickAsAnInterface( bool ); | |||
|
118 | void SetBrickAsARouter( bool ); | |||
|
119 | int GetAvailableBrickCount( void ); | |||
|
120 | void BytesReceivedFromSpw( unsigned int ); | |||
|
121 | void BytesTransmittedToSpw( unsigned int ); | |||
96 |
|
122 | |||
97 | public slots: |
|
123 | public slots: | |
98 | void toggleBridgeConnection(); |
|
124 | void toggleBridgeConnection(); | |
99 | bool connectBridge(); |
|
125 | bool connectBridge(); | |
100 | bool disconnectBridge(); |
|
126 | bool disconnectBridge(); | |
101 | int pushRMAPPacket(char* packet,int size); |
|
127 | int pushRMAPPacket(char* packet,int size); | |
102 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
128 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); | |
103 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
129 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); | |
104 | void brickSelectionChanged(int brickIndex); |
|
130 | void brickSelectionChanged(int brickIndex); | |
105 | void linkNumberSelectionChanged(int linkIndex); |
|
131 | void linkNumberSelectionChanged(int linkIndex); | |
106 | void linkSpeedSelectionChanged(const QString & linkSpeed); |
|
132 | void linkSpeedSelectionChanged(const QString & linkSpeed); | |
107 |
void |
|
133 | void sourceLogicalAddressChanged(const QString & destKey); | |
108 | void rmapAddressChanged(const QString & rmapaddress); |
|
134 | void rmapAddressChanged(const QString & rmapaddress); | |
109 | void rmapKeyChanged(const QString & key); |
|
135 | void brickModeChanged( bool interfaceMode ); | |
|
136 | void destinationKeyChanged(const QString & key); | |||
110 | void rmapTimeoutChanged(const QString & timeout); |
|
137 | void rmapTimeoutChanged(const QString & timeout); | |
|
138 | void sendPacketComingFromTCPServer(char *packet, int size); | |||
111 | private: |
|
139 | private: | |
112 | void makeGUI(socexplorerplugin *parent); |
|
140 | void makeGUI(socexplorerplugin *parent); | |
113 | stardundeeSPW_USB_Manager* manager; |
|
141 | stardundeeSPW_USB_Manager* manager; | |
114 | }; |
|
142 | }; | |
115 |
|
143 | |||
116 | #endif // STARDUNDEESPW_USB_H |
|
144 | #endif // STARDUNDEESPW_USB_H |
@@ -1,166 +1,170 | |||||
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 | |||
30 | spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false) |
|
30 | spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false) | |
31 | { |
|
31 | { | |
32 | Q_UNUSED(parent) |
|
32 | Q_UNUSED(parent) | |
33 | this->bridge = NULL; |
|
33 | this->bridge = NULL; | |
34 | this->scanDone = false; |
|
34 | this->scanDone = false; | |
35 | this->pyObject = new spwPyWrapper(this); |
|
35 | this->pyObject = new spwPyWrapper(this); | |
36 | this->tcpServer = new SpwTcpPacketServer(this); |
|
36 | this->tcpServer = new SpwTcpPacketServer(this); | |
37 | this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this); |
|
37 | this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this); | |
38 | this->bridgeSelector = new QComboBox(this); |
|
38 | this->bridgeSelector = new QComboBox(this); | |
39 | this->mainTabWidgt = new QTabWidget(this); |
|
39 | this->mainTabWidgt = new QTabWidget(this); | |
40 | this->mainTabWidgt->addTab(this->mainGroupBox,"Bridge Configuration"); |
|
40 | this->mainTabWidgt->addTab(this->mainGroupBox,"Bridge Configuration"); | |
41 | this->mainTabWidgt->addTab(this->tcpServer,"TCP Server"); |
|
41 | this->mainTabWidgt->addTab(this->tcpServer,"TCP Server"); | |
42 | this->mainLayout = new QGridLayout(this->mainGroupBox); |
|
42 | this->mainLayout = new QGridLayout(this->mainGroupBox); | |
43 | 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); | |
44 | this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1); |
|
44 | this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1); | |
45 | this->setWidget(this->mainTabWidgt); |
|
45 | this->setWidget(this->mainTabWidgt); | |
46 | this->bridgeSelector->addItem("none"); |
|
46 | this->bridgeSelector->addItem("none"); | |
47 | this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick"); |
|
47 | this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick"); | |
48 | this->bridgeSelector->addItem("GR-ESB"); |
|
48 | this->bridgeSelector->addItem("GR-ESB"); | |
49 | connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString))); |
|
49 | connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString))); | |
50 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString))); |
|
50 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString))); | |
51 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerConnect()),this->tcpServer,SLOT(connectServer())); |
|
51 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerConnect()),this->tcpServer,SLOT(connectServer())); | |
52 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerDisconnect()),this->tcpServer,SLOT(disconnectServer())); |
|
52 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerDisconnect()),this->tcpServer,SLOT(disconnectServer())); | |
53 | 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))); | |
54 | 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))); | |
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 |
|
57 | |||
58 | spwplugin::~spwplugin() |
|
58 | spwplugin::~spwplugin() | |
59 | { |
|
59 | { | |
60 |
|
60 | |||
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 |
|
63 | |||
64 |
|
64 | |||
65 | 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) | |
66 | { |
|
66 | { | |
67 | if(Connected) |
|
67 | if(Connected) | |
68 | { |
|
68 | { | |
69 | return bridge->Read(Value,count,address); |
|
69 | return bridge->Read(Value,count,address); | |
70 | } |
|
70 | } | |
71 | return 0; |
|
71 | return 0; | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | void spwplugin::bridgeSelectionChanged(const QString &text) |
|
74 | void spwplugin::bridgeSelectionChanged(const QString &text) | |
75 | { |
|
75 | { | |
76 | printf("test"); |
|
76 | printf("test"); | |
77 | if(text=="none") |
|
77 | if(text=="none") | |
78 | { |
|
78 | { | |
79 | if(this->bridge!=NULL) |
|
79 | if(this->bridge!=NULL) | |
80 | { |
|
80 | { | |
81 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
81 | this->mainLayout->removeWidget(this->bridge->getGUI()); | |
82 | this->disconnect(this,SLOT(setConnected(bool))); |
|
82 | this->disconnect(this,SLOT(setConnected(bool))); | |
83 | delete this->bridge; |
|
83 | delete this->bridge; | |
84 | this->bridge= NULL; |
|
84 | this->bridge= NULL; | |
85 | } |
|
85 | } | |
86 | } |
|
86 | } | |
87 | if(text=="STAR-Dundee Spw USB Brick") |
|
87 | if(text=="STAR-Dundee Spw USB Brick") | |
88 | { |
|
88 | { | |
89 | if(this->bridge!=NULL) |
|
89 | if(this->bridge!=NULL) | |
90 | { |
|
90 | { | |
91 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
91 | this->mainLayout->removeWidget(this->bridge->getGUI()); | |
92 | this->disconnect(this,SLOT(setConnected(bool))); |
|
92 | this->disconnect(this,SLOT(setConnected(bool))); | |
93 | delete this->bridge; |
|
93 | delete this->bridge; | |
94 | } |
|
94 | } | |
95 | this->bridge = new stardundeeSPW_USB(this); |
|
95 | this->bridge = new stardundeeSPW_USB(this); | |
96 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); |
|
96 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); | |
97 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); |
|
97 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); | |
98 | 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))); | |
99 | 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))); | |
100 | 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))); | |
101 | 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))); | |
102 | 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))); | |
103 | 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))); | |
104 | 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))); | |
105 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge())); |
|
105 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge())); | |
106 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge())); |
|
106 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge())); | |
|
107 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeGetAvailableBrickCount()),((stardundeeSPW_USB*)bridge),SIGNAL(GetAvailableBrickCount())); | |||
|
108 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetBrickAsAninterface(bool)), | |||
|
109 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetBrickAsAnInterface(bool))); | |||
|
110 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetBrickAsARouter(bool)), | |||
|
111 | ((stardundeeSPW_USB*)bridge),SIGNAL(SetBrickAsARouter(bool))); | |||
107 | connect(this->bridge,SIGNAL(pushPacketOverTCP(char*,int)),this->tcpServer,SLOT(pushPacket(char*,int))); |
|
112 | connect(this->bridge,SIGNAL(pushPacketOverTCP(char*,int)),this->tcpServer,SLOT(pushPacket(char*,int))); | |
|
113 | connect(this->tcpServer, SIGNAL(sendSPWPacket(char*,int)), ((stardundeeSPW_USB*)bridge), SLOT(sendPacketComingFromTCPServer(char*,int))); | |||
108 | } |
|
114 | } | |
109 | if(text=="GR-ESB") |
|
115 | if(text=="GR-ESB") | |
110 | { |
|
116 | { | |
111 | if(this->bridge!=NULL) |
|
117 | if(this->bridge!=NULL) | |
112 | { |
|
118 | { | |
113 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
119 | this->mainLayout->removeWidget(this->bridge->getGUI()); | |
114 | this->disconnect(this,SLOT(setConnected(bool))); |
|
120 | this->disconnect(this,SLOT(setConnected(bool))); | |
115 | delete this->bridge; |
|
121 | delete this->bridge; | |
116 | } |
|
122 | } | |
117 | this->bridge = new GR_ESB_bridge(this); |
|
123 | this->bridge = new GR_ESB_bridge(this); | |
118 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); |
|
124 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); | |
119 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); |
|
125 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); | |
120 | } |
|
126 | } | |
121 | } |
|
127 | } | |
122 |
|
128 | |||
123 |
|
129 | |||
124 | void spwplugin::selectBridge(const QString &text) |
|
130 | void spwplugin::selectBridge(const QString &text) | |
125 | { |
|
131 | { | |
126 |
|
132 | |||
127 | if(text=="none") |
|
133 | if(text=="none") | |
128 | { |
|
134 | { | |
129 | this->bridgeSelector->setCurrentIndex(0); |
|
135 | this->bridgeSelector->setCurrentIndex(0); | |
130 | } |
|
136 | } | |
131 | if(text=="STAR-Dundee Spw USB Brick") |
|
137 | if(text=="STAR-Dundee Spw USB Brick") | |
132 | { |
|
138 | { | |
133 | this->bridgeSelector->setCurrentIndex(1); |
|
139 | this->bridgeSelector->setCurrentIndex(1); | |
134 | } |
|
140 | } | |
135 | } |
|
141 | } | |
136 |
|
142 | |||
137 | void spwplugin::setConnected(bool connected) |
|
143 | void spwplugin::setConnected(bool connected) | |
138 | { |
|
144 | { | |
139 | this->bridgeSelector->setDisabled(connected); |
|
145 | this->bridgeSelector->setDisabled(connected); | |
140 | this->Connected = connected; |
|
146 | this->Connected = connected; | |
141 | emit activateSig(connected); |
|
147 | emit activateSig(connected); | |
142 | if(!this->scanDone) |
|
148 | if(!this->scanDone) | |
143 | { |
|
149 | { | |
144 | socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); |
|
150 | socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); | |
145 | this->scanDone=true; |
|
151 | this->scanDone=true; | |
146 | } |
|
152 | } | |
147 | } |
|
153 | } | |
148 |
|
154 | |||
149 |
|
||||
150 |
|
||||
151 | unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) |
|
155 | unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) | |
152 | { |
|
156 | { | |
153 | if(Connected) |
|
157 | if(Connected) | |
154 | { |
|
158 | { | |
155 | return bridge->Write(Value,count,address); |
|
159 | return bridge->Write(Value,count,address); | |
156 | } |
|
160 | } | |
157 | return 0; |
|
161 | return 0; | |
158 | } |
|
162 | } | |
159 |
|
163 | |||
160 |
|
164 | |||
161 |
|
165 | |||
162 |
|
166 | |||
163 |
|
167 | |||
164 |
|
168 | |||
165 |
|
169 | |||
166 |
|
170 |
@@ -1,30 +1,33 | |||||
1 | #ifndef SPWPYWRAPPER_H |
|
1 | #ifndef SPWPYWRAPPER_H | |
2 | #define SPWPYWRAPPER_H |
|
2 | #define SPWPYWRAPPER_H | |
3 | #include <genericPySysdriver.h> |
|
3 | #include <genericPySysdriver.h> | |
4 |
|
4 | |||
5 | class spwPyWrapper : public genericPySysdriver |
|
5 | class spwPyWrapper : public genericPySysdriver | |
6 | { |
|
6 | { | |
7 | Q_OBJECT |
|
7 | Q_OBJECT | |
8 | public: |
|
8 | public: | |
9 | explicit spwPyWrapper(socexplorerplugin *parent = 0); |
|
9 | explicit spwPyWrapper(socexplorerplugin *parent = 0); | |
10 | signals: |
|
10 | signals: | |
11 | void selectBridge(const QString &bridgeName); |
|
11 | void selectBridge(const QString &bridgeName); | |
12 | bool connectBridge(); |
|
12 | bool connectBridge(); | |
13 | bool disconnectBridge(); |
|
13 | bool disconnectBridge(); | |
14 | void StarDundeeSelectBrick(int brickIndex); |
|
14 | void StarDundeeSelectBrick(int brickIndex); | |
15 | void StarDundeeSelectLinkNumber(int linkIndex); |
|
15 | void StarDundeeSelectLinkNumber(int linkIndex); | |
16 | void StarDundeeSelectLinkSpeed(int linkSpeed); |
|
16 | void StarDundeeSelectLinkSpeed(int linkSpeed); | |
17 | void StarDundeeSetDestinationKey(const QString & destKey); |
|
17 | void StarDundeeSetDestinationKey(const QString & destKey); | |
18 | void StarDundeeSetRmapAddress(const QString & address); |
|
18 | void StarDundeeSetRmapAddress(const QString & address); | |
19 | void StarDundeeSetRmapKey(const QString & key); |
|
19 | void StarDundeeSetRmapKey(const QString & key); | |
20 | void StarDundeeSetRmapTimeout(const QString & timeout); |
|
20 | void StarDundeeSetRmapTimeout(const QString & timeout); | |
|
21 | int StarDundeeGetAvailableBrickCount(); | |||
|
22 | void StarDundeeSetBrickAsAninterface( bool ); | |||
|
23 | void StarDundeeSetBrickAsARouter( bool ); | |||
21 |
|
24 | |||
22 | void TCPServerConnect(); |
|
25 | void TCPServerConnect(); | |
23 | void TCPServerDisconnect(); |
|
26 | void TCPServerDisconnect(); | |
24 | void TCPServerSetPort(qint32 port); |
|
27 | void TCPServerSetPort(qint32 port); | |
25 | void TCPServerSetIP(QString ip); |
|
28 | void TCPServerSetIP(QString ip); | |
26 | public slots: |
|
29 | public slots: | |
27 |
|
30 | |||
28 | }; |
|
31 | }; | |
29 |
|
32 | |||
30 | #endif // SPWPYWRAPPER_H |
|
33 | #endif // SPWPYWRAPPER_H |
General Comments 0
You need to be logged in to leave comments.
Login now