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