@@ -35,6 +35,7 SpwTcpPacketServer::SpwTcpPacketServer(Q | |||||
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() | |
@@ -73,6 +74,7 void SpwTcpPacketServer::pushPacket(char | |||||
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); | |
@@ -94,6 +96,7 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() | |
@@ -137,11 +140,12 void SpwTcpPacketServer::readReady() | |||||
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); | |
@@ -150,6 +154,15 void SpwTcpPacketServer::readReady() | |||||
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(); | |
@@ -161,3 +174,17 void SpwTcpPacketServer::updateHostIP() | |||||
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 | } |
@@ -52,12 +52,17 public slots: | |||||
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 |
@@ -86,12 +86,12 | |||||
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> | |
@@ -103,7 +103,7 | |||||
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> |
@@ -7,7 +7,7 | |||||
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"> | |
@@ -82,7 +82,7 | |||||
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> | |
@@ -105,7 +105,7 | |||||
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> | |
@@ -128,7 +128,7 | |||||
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> | |
@@ -148,13 +148,6 | |||||
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"> | |
@@ -181,6 +174,109 | |||||
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/> |
@@ -28,6 +28,8 | |||||
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))); | |
@@ -37,7 +39,8 StarDundeeGUI::StarDundeeGUI(QWidget *pa | |||||
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() | |
@@ -75,7 +78,35 QString StarDundeeGUI::getRmapTimeout() | |||||
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 | { | |
@@ -86,6 +117,8 void StarDundeeGUI::lock(bool 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 | |
@@ -172,3 +205,50 void StarDundeeGUI::setRmapKey(const QSt | |||||
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 | } |
@@ -40,6 +40,7 public: | |||||
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); | |
@@ -49,6 +50,7 signals: | |||||
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); | |
@@ -59,8 +61,19 public slots: | |||||
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 |
@@ -24,6 +24,15 | |||||
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 | { | |
@@ -32,6 +41,8 stardundeeSPW_USB::stardundeeSPW_USB(soc | |||||
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() | |
@@ -107,7 +118,14 unsigned int stardundeeSPW_USB::Write(un | |||||
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); | |
@@ -127,7 +145,14 unsigned int stardundeeSPW_USB::Write(un | |||||
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); | |
@@ -162,7 +187,14 unsigned int stardundeeSPW_USB::Read(uns | |||||
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) | |
@@ -191,7 +223,14 unsigned int stardundeeSPW_USB::Read(uns | |||||
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) | |
@@ -236,22 +275,27 void stardundeeSPW_USB::linkSpeedSelecti | |||||
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) | |
@@ -266,7 +310,6 void stardundeeSPW_USB::rmapTimeoutChang | |||||
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(); | |
@@ -276,18 +319,20 void stardundeeSPW_USB::makeGUI(socexplo | |||||
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()); | |||
291 |
|
336 | |||
292 | connect(this,SIGNAL(SelectBrick(int)),((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int))); |
|
337 | connect(this,SIGNAL(SelectBrick(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectBrick(int))); | |
293 | connect(this,SIGNAL(SelectLinkNumber(int)),((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int))); |
|
338 | connect(this,SIGNAL(SelectLinkNumber(int)), ((StarDundeeGUI*)this->p_GUI),SLOT(selectLinkNumber(int))); | |
@@ -296,7 +341,35 void stardundeeSPW_USB::makeGUI(socexplo | |||||
296 | connect(this,SIGNAL(SetRmapAddress(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setRmapAddress(QString))); |
|
341 | connect(this,SIGNAL(SetRmapAddress(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setRmapAddress(QString))); | |
297 | connect(this,SIGNAL(SetRmapKey(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setRmapKey(QString))); |
|
342 | connect(this,SIGNAL(SetRmapKey(QString)), ((StarDundeeGUI*)this->p_GUI),SLOT(setRmapKey(QString))); | |
298 | connect(this,SIGNAL(SetRmapTimeout(QString)),((StarDundeeGUI*)this->p_GUI),SLOT(setRmapTimeout(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 | } | |||
299 |
|
350 | |||
|
351 | void stardundeeSPW_USB::sendPacketComingFromTCPServer(char *packet, int size) | |||
|
352 | { | |||
|
353 | char* data; | |||
|
354 | int i; | |||
|
355 | ||||
|
356 | data = (char *) malloc( size + 5 ); | |||
|
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) | |
@@ -320,7 +393,6 stardundeeSPW_USB_Manager::~stardundeeSP | |||||
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; | |
@@ -346,6 +418,7 void stardundeeSPW_USB_Manager::run() | |||||
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; | |
@@ -416,6 +489,26 void stardundeeSPW_USB_Manager::run() | |||||
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; | |
@@ -497,6 +590,285 bool stardundeeSPW_USB_Manager::connectB | |||||
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(); | |
@@ -607,6 +979,7 bool stardundeeSPW_USB_Manager::sendPack | |||||
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 | } |
@@ -36,7 +36,8 | |||||
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 | { | |
@@ -46,6 +47,13 public: | |||||
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); | |
@@ -54,6 +62,9 public: | |||||
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; | |
@@ -65,15 +76,25 private: | |||||
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 | |
@@ -93,6 +114,11 signals: | |||||
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(); | |
@@ -104,10 +130,12 public slots: | |||||
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; |
@@ -104,7 +104,13 void spwplugin::bridgeSelectionChanged(c | |||||
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 | { | |
@@ -146,8 +152,6 void spwplugin::setConnected(bool connec | |||||
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) |
@@ -18,6 +18,9 signals: | |||||
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(); |
General Comments 0
You need to be logged in to leave comments.
Login now