The requested changes are too big and content was truncated. Show full diff
@@ -1,1194 +1,1209 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on September , 2012 |
|
3 | 3 | @author: |
|
4 | 4 | ''' |
|
5 | 5 | from xml.etree.ElementTree import Element, SubElement |
|
6 | 6 | from xml.etree import ElementTree as ET |
|
7 | 7 | from xml.dom import minidom |
|
8 | 8 | |
|
9 | 9 | #import datetime |
|
10 | 10 | from model import * |
|
11 | 11 | |
|
12 | 12 | try: |
|
13 | 13 | from gevent import sleep |
|
14 | 14 | except: |
|
15 | 15 | from time import sleep |
|
16 | 16 | |
|
17 | 17 | import ast |
|
18 | 18 | |
|
19 | 19 | def prettify(elem): |
|
20 | 20 | """Return a pretty-printed XML string for the Element. |
|
21 | 21 | """ |
|
22 | 22 | rough_string = ET.tostring(elem, 'utf-8') |
|
23 | 23 | reparsed = minidom.parseString(rough_string) |
|
24 | 24 | return reparsed.toprettyxml(indent=" ") |
|
25 | 25 | |
|
26 | 26 | class ParameterConf(): |
|
27 | 27 | |
|
28 | 28 | id = None |
|
29 | 29 | name = None |
|
30 | 30 | value = None |
|
31 | 31 | format = None |
|
32 | 32 | |
|
33 | 33 | __formated_value = None |
|
34 | 34 | |
|
35 | 35 | ELEMENTNAME = 'Parameter' |
|
36 | 36 | |
|
37 | 37 | def __init__(self): |
|
38 | 38 | |
|
39 | 39 | self.format = 'str' |
|
40 | 40 | |
|
41 | 41 | def getElementName(self): |
|
42 | 42 | |
|
43 | 43 | return self.ELEMENTNAME |
|
44 | 44 | |
|
45 | 45 | def getValue(self): |
|
46 | 46 | |
|
47 | 47 | value = self.value |
|
48 | 48 | format = self.format |
|
49 | 49 | |
|
50 | 50 | if self.__formated_value != None: |
|
51 | 51 | |
|
52 | 52 | return self.__formated_value |
|
53 | 53 | |
|
54 | 54 | if format == 'str': |
|
55 | 55 | self.__formated_value = str(value) |
|
56 | 56 | return self.__formated_value |
|
57 | 57 | |
|
58 | 58 | if value == '': |
|
59 | 59 | raise ValueError, "%s: This parameter value is empty" %self.name |
|
60 | 60 | |
|
61 | 61 | if format == 'bool': |
|
62 | 62 | value = int(value) |
|
63 | 63 | |
|
64 | 64 | if format == 'list': |
|
65 | 65 | strList = value.split(',') |
|
66 | 66 | |
|
67 | 67 | self.__formated_value = strList |
|
68 | 68 | |
|
69 | 69 | return self.__formated_value |
|
70 | 70 | |
|
71 | 71 | if format == 'intlist': |
|
72 | 72 | """ |
|
73 | 73 | Example: |
|
74 | 74 | value = (0,1,2) |
|
75 | 75 | """ |
|
76 | 76 | value = value.replace('(', '') |
|
77 | 77 | value = value.replace(')', '') |
|
78 | 78 | |
|
79 | 79 | value = value.replace('[', '') |
|
80 | 80 | value = value.replace(']', '') |
|
81 | 81 | |
|
82 | 82 | strList = value.split(',') |
|
83 | 83 | intList = [int(x) for x in strList] |
|
84 | 84 | |
|
85 | 85 | self.__formated_value = intList |
|
86 | 86 | |
|
87 | 87 | return self.__formated_value |
|
88 | 88 | |
|
89 | 89 | if format == 'floatlist': |
|
90 | 90 | """ |
|
91 | 91 | Example: |
|
92 | 92 | value = (0.5, 1.4, 2.7) |
|
93 | 93 | """ |
|
94 | 94 | |
|
95 | 95 | value = value.replace('(', '') |
|
96 | 96 | value = value.replace(')', '') |
|
97 | 97 | |
|
98 | 98 | value = value.replace('[', '') |
|
99 | 99 | value = value.replace(']', '') |
|
100 | 100 | |
|
101 | 101 | strList = value.split(',') |
|
102 | 102 | floatList = [float(x) for x in strList] |
|
103 | 103 | |
|
104 | 104 | self.__formated_value = floatList |
|
105 | 105 | |
|
106 | 106 | return self.__formated_value |
|
107 | 107 | |
|
108 | 108 | if format == 'date': |
|
109 | 109 | strList = value.split('/') |
|
110 | 110 | intList = [int(x) for x in strList] |
|
111 | 111 | date = datetime.date(intList[0], intList[1], intList[2]) |
|
112 | 112 | |
|
113 | 113 | self.__formated_value = date |
|
114 | 114 | |
|
115 | 115 | return self.__formated_value |
|
116 | 116 | |
|
117 | 117 | if format == 'time': |
|
118 | 118 | strList = value.split(':') |
|
119 | 119 | intList = [int(x) for x in strList] |
|
120 | 120 | time = datetime.time(intList[0], intList[1], intList[2]) |
|
121 | 121 | |
|
122 | 122 | self.__formated_value = time |
|
123 | 123 | |
|
124 | 124 | return self.__formated_value |
|
125 | 125 | |
|
126 | 126 | if format == 'pairslist': |
|
127 | 127 | """ |
|
128 | 128 | Example: |
|
129 | 129 | value = (0,1),(1,2) |
|
130 | 130 | """ |
|
131 | 131 | |
|
132 | 132 | value = value.replace('(', '') |
|
133 | 133 | value = value.replace(')', '') |
|
134 | 134 | |
|
135 | 135 | value = value.replace('[', '') |
|
136 | 136 | value = value.replace(']', '') |
|
137 | 137 | |
|
138 | 138 | strList = value.split(',') |
|
139 | 139 | intList = [int(item) for item in strList] |
|
140 | 140 | pairList = [] |
|
141 | 141 | for i in range(len(intList)/2): |
|
142 | 142 | pairList.append((intList[i*2], intList[i*2 + 1])) |
|
143 | 143 | |
|
144 | 144 | self.__formated_value = pairList |
|
145 | 145 | |
|
146 | 146 | return self.__formated_value |
|
147 | 147 | |
|
148 | 148 | if format == 'multilist': |
|
149 | 149 | """ |
|
150 | 150 | Example: |
|
151 | 151 | value = (0,1,2),(3,4,5) |
|
152 | 152 | """ |
|
153 | 153 | multiList = ast.literal_eval(value) |
|
154 | 154 | |
|
155 | 155 | if type(multiList[0]) == int: |
|
156 | 156 | multiList = ast.literal_eval("(" + value + ")") |
|
157 | 157 | |
|
158 | 158 | self.__formated_value = multiList |
|
159 | 159 | |
|
160 | 160 | return self.__formated_value |
|
161 | 161 | |
|
162 | 162 | format_func = eval(format) |
|
163 | 163 | |
|
164 | 164 | self.__formated_value = format_func(value) |
|
165 | 165 | |
|
166 | 166 | return self.__formated_value |
|
167 | 167 | |
|
168 | 168 | def updateId(self, new_id): |
|
169 | 169 | |
|
170 | 170 | self.id = str(new_id) |
|
171 | 171 | |
|
172 | 172 | def setup(self, id, name, value, format='str'): |
|
173 | 173 | |
|
174 | 174 | self.id = str(id) |
|
175 | 175 | self.name = name |
|
176 | 176 | self.value = str(value) |
|
177 | 177 | self.format = str.lower(format) |
|
178 | 178 | |
|
179 | 179 | def update(self, name, value, format='str'): |
|
180 | 180 | |
|
181 | 181 | self.name = name |
|
182 | 182 | self.value = str(value) |
|
183 | 183 | self.format = format |
|
184 | 184 | |
|
185 | 185 | def makeXml(self, opElement): |
|
186 | 186 | |
|
187 | 187 | parmElement = SubElement(opElement, self.ELEMENTNAME) |
|
188 | 188 | parmElement.set('id', str(self.id)) |
|
189 | 189 | parmElement.set('name', self.name) |
|
190 | 190 | parmElement.set('value', self.value) |
|
191 | 191 | parmElement.set('format', self.format) |
|
192 | 192 | |
|
193 | 193 | def readXml(self, parmElement): |
|
194 | 194 | |
|
195 | 195 | self.id = parmElement.get('id') |
|
196 | 196 | self.name = parmElement.get('name') |
|
197 | 197 | self.value = parmElement.get('value') |
|
198 | 198 | self.format = str.lower(parmElement.get('format')) |
|
199 | 199 | |
|
200 | 200 | #Compatible with old signal chain version |
|
201 | 201 | if self.format == 'int' and self.name == 'idfigure': |
|
202 | 202 | self.name = 'id' |
|
203 | 203 | |
|
204 | 204 | def printattr(self): |
|
205 | 205 | |
|
206 | 206 | print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format) |
|
207 | 207 | |
|
208 | 208 | class OperationConf(): |
|
209 | 209 | |
|
210 | 210 | id = None |
|
211 | 211 | name = None |
|
212 | 212 | priority = None |
|
213 | 213 | type = None |
|
214 | 214 | |
|
215 | 215 | parmConfObjList = [] |
|
216 | 216 | |
|
217 | 217 | ELEMENTNAME = 'Operation' |
|
218 | 218 | |
|
219 | 219 | def __init__(self): |
|
220 | 220 | |
|
221 | 221 | self.id = '0' |
|
222 | 222 | self.name = None |
|
223 | 223 | self.priority = None |
|
224 | 224 | self.type = 'self' |
|
225 | 225 | |
|
226 | 226 | |
|
227 | 227 | def __getNewId(self): |
|
228 | 228 | |
|
229 | 229 | return int(self.id)*10 + len(self.parmConfObjList) + 1 |
|
230 | 230 | |
|
231 | 231 | def updateId(self, new_id): |
|
232 | 232 | |
|
233 | 233 | self.id = str(new_id) |
|
234 | 234 | |
|
235 | 235 | n = 1 |
|
236 | 236 | for parmObj in self.parmConfObjList: |
|
237 | 237 | |
|
238 | 238 | idParm = str(int(new_id)*10 + n) |
|
239 | 239 | parmObj.updateId(idParm) |
|
240 | 240 | |
|
241 | 241 | n += 1 |
|
242 | 242 | |
|
243 | 243 | def getElementName(self): |
|
244 | 244 | |
|
245 | 245 | return self.ELEMENTNAME |
|
246 | 246 | |
|
247 | 247 | def getParameterObjList(self): |
|
248 | 248 | |
|
249 | 249 | return self.parmConfObjList |
|
250 | 250 | |
|
251 | 251 | def getParameterObj(self, parameterName): |
|
252 | 252 | |
|
253 | 253 | for parmConfObj in self.parmConfObjList: |
|
254 | 254 | |
|
255 | 255 | if parmConfObj.name != parameterName: |
|
256 | 256 | continue |
|
257 | 257 | |
|
258 | 258 | return parmConfObj |
|
259 | 259 | |
|
260 | 260 | return None |
|
261 | 261 | |
|
262 | def getParameterObjfromValue(self,parameterValue): | |
|
262 | def getParameterObjfromValue(self, parameterValue): | |
|
263 | ||
|
263 | 264 | for parmConfObj in self.parmConfObjList: |
|
264 | 265 | |
|
265 | 266 | if parmConfObj.getValue() != parameterValue: |
|
266 | 267 | continue |
|
267 | 268 | |
|
268 | 269 | return parmConfObj.getValue() |
|
269 | 270 | |
|
270 | 271 | return None |
|
271 | 272 | |
|
272 | 273 | def getParameterValue(self, parameterName): |
|
273 | 274 | |
|
274 | 275 | parameterObj = self.getParameterObj(parameterName) |
|
276 | ||
|
277 | if not parameterObj: | |
|
278 | return None | |
|
279 | ||
|
275 | 280 | value = parameterObj.getValue() |
|
276 | 281 | |
|
277 | 282 | return value |
|
278 | 283 | |
|
279 | 284 | def setup(self, id, name, priority, type): |
|
280 | 285 | |
|
281 | 286 | self.id = str(id) |
|
282 | 287 | self.name = name |
|
283 | 288 | self.type = type |
|
284 | 289 | self.priority = priority |
|
285 | 290 | |
|
286 | 291 | self.parmConfObjList = [] |
|
287 | 292 | |
|
288 | 293 | def removeParameters(self): |
|
289 | 294 | |
|
290 | 295 | for obj in self.parmConfObjList: |
|
291 | 296 | del obj |
|
292 | 297 | |
|
293 | 298 | self.parmConfObjList = [] |
|
294 | 299 | |
|
295 | 300 | def addParameter(self, name, value, format='str'): |
|
296 | 301 | |
|
297 | 302 | id = self.__getNewId() |
|
298 | 303 | |
|
299 | 304 | parmConfObj = ParameterConf() |
|
300 | 305 | parmConfObj.setup(id, name, value, format) |
|
301 | 306 | |
|
302 | 307 | self.parmConfObjList.append(parmConfObj) |
|
303 | 308 | |
|
304 | 309 | return parmConfObj |
|
305 | 310 | |
|
306 | 311 | def changeParameter(self, name, value, format='str'): |
|
307 | 312 | |
|
308 | 313 | parmConfObj = self.getParameterObj(name) |
|
309 | 314 | parmConfObj.update(name, value, format) |
|
310 | 315 | |
|
311 | 316 | return parmConfObj |
|
312 | 317 | |
|
313 | 318 | def makeXml(self, upElement): |
|
314 | 319 | |
|
315 | 320 | opElement = SubElement(upElement, self.ELEMENTNAME) |
|
316 | 321 | opElement.set('id', str(self.id)) |
|
317 | 322 | opElement.set('name', self.name) |
|
318 | 323 | opElement.set('type', self.type) |
|
319 | 324 | opElement.set('priority', str(self.priority)) |
|
320 | 325 | |
|
321 | 326 | for parmConfObj in self.parmConfObjList: |
|
322 | 327 | parmConfObj.makeXml(opElement) |
|
323 | 328 | |
|
324 | 329 | def readXml(self, opElement): |
|
325 | 330 | |
|
326 | 331 | self.id = opElement.get('id') |
|
327 | 332 | self.name = opElement.get('name') |
|
328 | 333 | self.type = opElement.get('type') |
|
329 | 334 | self.priority = opElement.get('priority') |
|
330 | 335 | |
|
331 | 336 | #Compatible with old signal chain version |
|
332 | 337 | #Use of 'run' method instead 'init' |
|
333 | 338 | if self.type == 'self' and self.name == 'init': |
|
334 | 339 | self.name = 'run' |
|
335 | 340 | |
|
336 | 341 | self.parmConfObjList = [] |
|
337 | 342 | |
|
338 | 343 | parmElementList = opElement.getiterator(ParameterConf().getElementName()) |
|
339 | 344 | |
|
340 | 345 | for parmElement in parmElementList: |
|
341 | 346 | parmConfObj = ParameterConf() |
|
342 | 347 | parmConfObj.readXml(parmElement) |
|
343 | 348 | |
|
344 | 349 | #Compatible with old signal chain version |
|
345 | 350 | #If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER |
|
346 | 351 | if self.type != 'self' and self.name == 'Plot': |
|
347 | 352 | if parmConfObj.format == 'str' and parmConfObj.name == 'type': |
|
348 | 353 | self.name = parmConfObj.value |
|
349 | 354 | continue |
|
350 | 355 | |
|
351 | 356 | self.parmConfObjList.append(parmConfObj) |
|
352 | 357 | |
|
353 | 358 | def printattr(self): |
|
354 | 359 | |
|
355 | 360 | print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME, |
|
356 | 361 | self.id, |
|
357 | 362 | self.name, |
|
358 | 363 | self.type, |
|
359 | 364 | self.priority) |
|
360 | 365 | |
|
361 | 366 | for parmConfObj in self.parmConfObjList: |
|
362 | 367 | parmConfObj.printattr() |
|
363 | 368 | |
|
364 | 369 | def createObject(self): |
|
365 | 370 | |
|
366 | 371 | if self.type == 'self': |
|
367 | 372 | raise ValueError, "This operation type cannot be created" |
|
368 | 373 | |
|
369 | 374 | if self.type == 'external' or self.type == 'other': |
|
370 | 375 | className = eval(self.name) |
|
371 | 376 | opObj = className() |
|
372 | 377 | |
|
373 | 378 | return opObj |
|
374 | 379 | |
|
375 | 380 | class ProcUnitConf(): |
|
376 | 381 | |
|
377 | 382 | id = None |
|
378 | 383 | name = None |
|
379 | 384 | datatype = None |
|
380 | 385 | inputId = None |
|
381 | 386 | parentId = None |
|
382 | 387 | |
|
383 | 388 | opConfObjList = [] |
|
384 | 389 | |
|
385 | 390 | procUnitObj = None |
|
386 | 391 | opObjList = [] |
|
387 | 392 | |
|
388 | 393 | ELEMENTNAME = 'ProcUnit' |
|
389 | 394 | |
|
390 | 395 | def __init__(self): |
|
391 | 396 | |
|
392 | 397 | self.id = None |
|
393 | 398 | self.datatype = None |
|
394 | 399 | self.name = None |
|
395 | 400 | self.inputId = None |
|
396 | 401 | |
|
397 | 402 | self.opConfObjList = [] |
|
398 | 403 | |
|
399 | 404 | self.procUnitObj = None |
|
400 | 405 | self.opObjDict = {} |
|
401 | 406 | |
|
402 | 407 | def __getPriority(self): |
|
403 | 408 | |
|
404 | 409 | return len(self.opConfObjList)+1 |
|
405 | 410 | |
|
406 | 411 | def __getNewId(self): |
|
407 | 412 | |
|
408 | 413 | return int(self.id)*10 + len(self.opConfObjList) + 1 |
|
409 | 414 | |
|
410 | 415 | def getElementName(self): |
|
411 | 416 | |
|
412 | 417 | return self.ELEMENTNAME |
|
413 | 418 | |
|
414 | 419 | def getId(self): |
|
415 | 420 | |
|
416 | 421 | return self.id |
|
417 | 422 | |
|
418 | 423 | def updateId(self, new_id, parentId=parentId): |
|
419 | 424 | |
|
420 | 425 | |
|
421 | 426 | new_id = int(parentId)*10 + (int(self.id) % 10) |
|
422 | 427 | new_inputId = int(parentId)*10 + (int(self.inputId) % 10) |
|
423 | 428 | |
|
424 | 429 | #If this proc unit has not inputs |
|
425 | 430 | if self.inputId == '0': |
|
426 | 431 | new_inputId = 0 |
|
427 | 432 | |
|
428 | 433 | n = 1 |
|
429 | 434 | for opConfObj in self.opConfObjList: |
|
430 | 435 | |
|
431 | 436 | idOp = str(int(new_id)*10 + n) |
|
432 | 437 | opConfObj.updateId(idOp) |
|
433 | 438 | |
|
434 | 439 | n += 1 |
|
435 | 440 | |
|
436 | 441 | self.parentId = str(parentId) |
|
437 | 442 | self.id = str(new_id) |
|
438 | 443 | self.inputId = str(new_inputId) |
|
439 | 444 | |
|
440 | 445 | |
|
441 | 446 | def getInputId(self): |
|
442 | 447 | |
|
443 | 448 | return self.inputId |
|
444 | 449 | |
|
445 | 450 | def getOperationObjList(self): |
|
446 | 451 | |
|
447 | 452 | return self.opConfObjList |
|
448 | 453 | |
|
449 | 454 | def getOperationObj(self, name=None): |
|
450 | 455 | |
|
451 | 456 | for opConfObj in self.opConfObjList: |
|
452 | 457 | |
|
453 | 458 | if opConfObj.name != name: |
|
454 | 459 | continue |
|
455 | 460 | |
|
456 | 461 | return opConfObj |
|
457 | 462 | |
|
458 | 463 | return None |
|
459 | 464 | |
|
460 | def getOpObjfromParamValue(self,value=None): | |
|
465 | def getOpObjfromParamValue(self, value=None): | |
|
461 | 466 | |
|
462 | 467 | for opConfObj in self.opConfObjList: |
|
463 | 468 | if opConfObj.getParameterObjfromValue(parameterValue=value) != value: |
|
464 | 469 | continue |
|
465 | 470 | return opConfObj |
|
466 | 471 | return None |
|
467 | 472 | |
|
468 | 473 | def getProcUnitObj(self): |
|
469 | 474 | |
|
470 | 475 | return self.procUnitObj |
|
471 | 476 | |
|
472 | 477 | def setup(self, id, name, datatype, inputId, parentId=None): |
|
473 | 478 | |
|
474 | 479 | #Compatible with old signal chain version |
|
475 | 480 | if datatype==None and name==None: |
|
476 | 481 | raise ValueError, "datatype or name should be defined" |
|
477 | 482 | |
|
478 | 483 | if name==None: |
|
479 | 484 | if 'Proc' in datatype: |
|
480 | 485 | name = datatype |
|
481 | 486 | else: |
|
482 | 487 | name = '%sProc' %(datatype) |
|
483 | 488 | |
|
484 | 489 | if datatype==None: |
|
485 | 490 | datatype = name.replace('Proc','') |
|
486 | 491 | |
|
487 | 492 | self.id = str(id) |
|
488 | 493 | self.name = name |
|
489 | 494 | self.datatype = datatype |
|
490 | 495 | self.inputId = inputId |
|
491 | 496 | self.parentId = parentId |
|
492 | 497 | |
|
493 | 498 | self.opConfObjList = [] |
|
494 | 499 | |
|
495 | 500 | self.addOperation(name='run', optype='self') |
|
496 | 501 | |
|
497 | 502 | def removeOperations(self): |
|
498 | 503 | |
|
499 | 504 | for obj in self.opConfObjList: |
|
500 | 505 | del obj |
|
501 | 506 | |
|
502 | 507 | self.opConfObjList = [] |
|
503 | 508 | self.addOperation(name='run') |
|
504 | 509 | |
|
505 | 510 | def addParameter(self, **kwargs): |
|
506 | 511 | ''' |
|
507 | 512 | Add parameters to "run" operation |
|
508 | 513 | ''' |
|
509 | 514 | opObj = self.opConfObjList[0] |
|
510 | 515 | |
|
511 | 516 | opObj.addParameter(**kwargs) |
|
512 | 517 | |
|
513 | 518 | return opObj |
|
514 | 519 | |
|
515 | 520 | def addOperation(self, name, optype='self'): |
|
516 | 521 | |
|
517 | 522 | id = self.__getNewId() |
|
518 | 523 | priority = self.__getPriority() |
|
519 | 524 | |
|
520 | 525 | opConfObj = OperationConf() |
|
521 | 526 | opConfObj.setup(id, name=name, priority=priority, type=optype) |
|
522 | 527 | |
|
523 | 528 | self.opConfObjList.append(opConfObj) |
|
524 | 529 | |
|
525 | 530 | return opConfObj |
|
526 | 531 | |
|
527 | 532 | def makeXml(self, procUnitElement): |
|
528 | 533 | |
|
529 | 534 | upElement = SubElement(procUnitElement, self.ELEMENTNAME) |
|
530 | 535 | upElement.set('id', str(self.id)) |
|
531 | 536 | upElement.set('name', self.name) |
|
532 | 537 | upElement.set('datatype', self.datatype) |
|
533 | 538 | upElement.set('inputId', str(self.inputId)) |
|
534 | 539 | |
|
535 | 540 | for opConfObj in self.opConfObjList: |
|
536 | 541 | opConfObj.makeXml(upElement) |
|
537 | 542 | |
|
538 | 543 | def readXml(self, upElement): |
|
539 | 544 | |
|
540 | 545 | self.id = upElement.get('id') |
|
541 | 546 | self.name = upElement.get('name') |
|
542 | 547 | self.datatype = upElement.get('datatype') |
|
543 | 548 | self.inputId = upElement.get('inputId') |
|
544 | 549 | |
|
545 | 550 | if self.ELEMENTNAME == "ReadUnit": |
|
546 | 551 | self.datatype = self.datatype.replace("Reader", "") |
|
547 | 552 | |
|
548 | 553 | if self.ELEMENTNAME == "ProcUnit": |
|
549 | 554 | self.datatype = self.datatype.replace("Proc", "") |
|
550 | 555 | |
|
551 | 556 | if self.inputId == 'None': |
|
552 | 557 | self.inputId = '0' |
|
553 | 558 | |
|
554 | 559 | self.opConfObjList = [] |
|
555 | 560 | |
|
556 | 561 | opElementList = upElement.getiterator(OperationConf().getElementName()) |
|
557 | 562 | |
|
558 | 563 | for opElement in opElementList: |
|
559 | 564 | opConfObj = OperationConf() |
|
560 | 565 | opConfObj.readXml(opElement) |
|
561 | 566 | self.opConfObjList.append(opConfObj) |
|
562 | 567 | |
|
563 | 568 | def printattr(self): |
|
564 | 569 | |
|
565 | 570 | print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME, |
|
566 | 571 | self.id, |
|
567 | 572 | self.name, |
|
568 | 573 | self.datatype, |
|
569 | 574 | self.inputId) |
|
570 | 575 | |
|
571 | 576 | for opConfObj in self.opConfObjList: |
|
572 | 577 | opConfObj.printattr() |
|
573 | 578 | |
|
574 | 579 | def createObjects(self): |
|
575 | 580 | |
|
576 | 581 | className = eval(self.name) |
|
577 | 582 | procUnitObj = className() |
|
578 | 583 | |
|
579 | 584 | for opConfObj in self.opConfObjList: |
|
580 | 585 | |
|
581 | 586 | if opConfObj.type == 'self': |
|
582 | 587 | continue |
|
583 | 588 | |
|
584 | 589 | opObj = opConfObj.createObject() |
|
585 | 590 | |
|
586 | 591 | self.opObjDict[opConfObj.id] = opObj |
|
587 | 592 | procUnitObj.addOperation(opObj, opConfObj.id) |
|
588 | 593 | |
|
589 | 594 | self.procUnitObj = procUnitObj |
|
590 | 595 | |
|
591 | 596 | return procUnitObj |
|
592 | 597 | |
|
593 | 598 | def run(self): |
|
594 | 599 | |
|
595 | 600 | finalSts = False |
|
596 | 601 | |
|
597 | 602 | for opConfObj in self.opConfObjList: |
|
598 | 603 | |
|
599 | 604 | kwargs = {} |
|
600 | 605 | for parmConfObj in opConfObj.getParameterObjList(): |
|
601 | 606 | if opConfObj.name == 'run' and parmConfObj.name == 'datatype': |
|
602 | 607 | continue |
|
603 | 608 | |
|
604 | 609 | kwargs[parmConfObj.name] = parmConfObj.getValue() |
|
605 | 610 | |
|
606 | 611 | #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id) |
|
607 | 612 | sts = self.procUnitObj.call(opType = opConfObj.type, |
|
608 | 613 | opName = opConfObj.name, |
|
609 | 614 | opId = opConfObj.id, |
|
610 | 615 | **kwargs) |
|
611 | 616 | finalSts = finalSts or sts |
|
612 | 617 | |
|
613 | 618 | return finalSts |
|
614 | 619 | |
|
615 | 620 | def close(self): |
|
616 | 621 | |
|
617 | 622 | for opConfObj in self.opConfObjList: |
|
618 | 623 | if opConfObj.type == 'self': |
|
619 | 624 | continue |
|
620 | 625 | |
|
621 | 626 | opObj = self.procUnitObj.getOperationObj(opConfObj.id) |
|
622 | 627 | opObj.close() |
|
623 | 628 | |
|
624 | 629 | self.procUnitObj.close() |
|
625 | 630 | |
|
626 | 631 | return |
|
627 | 632 | |
|
628 | 633 | class ReadUnitConf(ProcUnitConf): |
|
629 | 634 | |
|
630 | 635 | path = None |
|
631 | 636 | startDate = None |
|
632 | 637 | endDate = None |
|
633 | 638 | startTime = None |
|
634 | 639 | endTime = None |
|
635 | 640 | |
|
636 | 641 | ELEMENTNAME = 'ReadUnit' |
|
637 | 642 | |
|
638 | 643 | def __init__(self): |
|
639 | 644 | |
|
640 | 645 | self.id = None |
|
641 | 646 | self.datatype = None |
|
642 | 647 | self.name = None |
|
643 | 648 | self.inputId = None |
|
644 | 649 | |
|
645 | 650 | self.parentId = None |
|
646 | 651 | |
|
647 | 652 | self.opConfObjList = [] |
|
648 | 653 | self.opObjList = [] |
|
649 | 654 | |
|
650 | 655 | def getElementName(self): |
|
651 | 656 | |
|
652 | 657 | return self.ELEMENTNAME |
|
653 | 658 | |
|
654 | 659 | def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", endTime="", parentId=None, **kwargs): |
|
655 | 660 | |
|
656 | 661 | #Compatible with old signal chain version |
|
657 | 662 | if datatype==None and name==None: |
|
658 | 663 | raise ValueError, "datatype or name should be defined" |
|
659 | 664 | |
|
660 | 665 | if name==None: |
|
661 | 666 | if 'Reader' in datatype: |
|
662 | 667 | name = datatype |
|
663 | 668 | else: |
|
664 | 669 | name = '%sReader' %(datatype) |
|
665 | 670 | |
|
666 | 671 | if datatype==None: |
|
667 | 672 | datatype = name.replace('Reader','') |
|
668 | 673 | |
|
669 | 674 | self.id = id |
|
670 | 675 | self.name = name |
|
671 | 676 | self.datatype = datatype |
|
672 | 677 | |
|
673 | 678 | self.path = path |
|
674 | 679 | self.startDate = startDate |
|
675 | 680 | self.endDate = endDate |
|
676 | 681 | self.startTime = startTime |
|
677 | 682 | self.endTime = endTime |
|
678 | 683 | |
|
679 | 684 | self.inputId = '0' |
|
680 | 685 | self.parentId = parentId |
|
681 | 686 | |
|
682 | 687 | self.addRunOperation(**kwargs) |
|
683 | 688 | |
|
684 | 689 | def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, name=None, **kwargs): |
|
685 | 690 | |
|
686 | 691 | #Compatible with old signal chain version |
|
687 | 692 | if datatype==None and name==None: |
|
688 | 693 | raise ValueError, "datatype or name should be defined" |
|
689 | 694 | |
|
690 | 695 | if name==None: |
|
691 | 696 | if 'Reader' in datatype: |
|
692 | 697 | name = datatype |
|
693 | 698 | else: |
|
694 | 699 | name = '%sReader' %(datatype) |
|
695 | 700 | |
|
696 | 701 | if datatype==None: |
|
697 | 702 | datatype = name.replace('Reader','') |
|
698 | 703 | |
|
699 | 704 | self.datatype = datatype |
|
700 | 705 | self.name = name |
|
701 | 706 | self.path = path |
|
702 | 707 | self.startDate = startDate |
|
703 | 708 | self.endDate = endDate |
|
704 | 709 | self.startTime = startTime |
|
705 | 710 | self.endTime = endTime |
|
706 | 711 | |
|
707 | 712 | self.inputId = '0' |
|
708 | 713 | self.parentId = parentId |
|
709 | 714 | |
|
710 | 715 | self.updateRunOperation(**kwargs) |
|
711 | 716 | |
|
712 | 717 | def addRunOperation(self, **kwargs): |
|
713 | 718 | |
|
714 | 719 | opObj = self.addOperation(name = 'run', optype = 'self') |
|
715 | 720 | |
|
716 | 721 | opObj.addParameter(name='datatype' , value=self.datatype, format='str') |
|
717 | 722 | opObj.addParameter(name='path' , value=self.path, format='str') |
|
718 | 723 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') |
|
719 | 724 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') |
|
720 | 725 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') |
|
721 | 726 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') |
|
722 | 727 | |
|
723 | 728 | for key, value in kwargs.items(): |
|
724 | 729 | opObj.addParameter(name=key, value=value, format=type(value).__name__) |
|
725 | 730 | |
|
726 | 731 | return opObj |
|
727 | 732 | |
|
728 | 733 | def updateRunOperation(self, **kwargs): |
|
729 | 734 | |
|
730 | 735 | opObj = self.getOperationObj(name = 'run') |
|
731 | 736 | opObj.removeParameters() |
|
732 | 737 | |
|
733 | 738 | opObj.addParameter(name='datatype' , value=self.datatype, format='str') |
|
734 | 739 | opObj.addParameter(name='path' , value=self.path, format='str') |
|
735 | 740 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') |
|
736 | 741 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') |
|
737 | 742 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') |
|
738 | 743 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') |
|
739 | 744 | |
|
740 | 745 | for key, value in kwargs.items(): |
|
741 | 746 | opObj.addParameter(name=key, value=value, format=type(value).__name__) |
|
742 | 747 | |
|
743 | 748 | return opObj |
|
744 | 749 | |
|
745 | 750 | class Project(): |
|
746 | 751 | |
|
747 | 752 | id = None |
|
748 | 753 | name = None |
|
749 | 754 | description = None |
|
750 | 755 | # readUnitConfObjList = None |
|
751 | 756 | procUnitConfObjDict = None |
|
752 | 757 | |
|
753 | 758 | ELEMENTNAME = 'Project' |
|
754 | 759 | |
|
755 | 760 | def __init__(self, control=None, dataq=None): |
|
756 | 761 | |
|
757 | 762 | self.id = None |
|
758 | 763 | self.name = None |
|
759 | 764 | self.description = None |
|
760 | 765 | |
|
761 | 766 | self.procUnitConfObjDict = {} |
|
762 | 767 | |
|
763 | 768 | #global data_q |
|
764 | 769 | #data_q = dataq |
|
765 | 770 | |
|
766 | 771 | if control==None: |
|
767 | 772 | control = {'stop':False,'pause':False} |
|
768 | 773 | |
|
769 | 774 | self.control = control |
|
770 | 775 | |
|
771 | 776 | def __getNewId(self): |
|
772 | 777 | |
|
773 | 778 | id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1 |
|
774 | 779 | |
|
775 | 780 | return str(id) |
|
776 | 781 | |
|
777 | 782 | def getElementName(self): |
|
778 | 783 | |
|
779 | 784 | return self.ELEMENTNAME |
|
780 | 785 | |
|
781 | 786 | def getId(self): |
|
782 | 787 | |
|
783 | 788 | return self.id |
|
784 | 789 | |
|
785 | 790 | def updateId(self, new_id): |
|
786 | 791 | |
|
787 | 792 | self.id = str(new_id) |
|
788 | 793 | |
|
789 | 794 | keyList = self.procUnitConfObjDict.keys() |
|
790 | 795 | keyList.sort() |
|
791 | 796 | |
|
792 | 797 | n = 1 |
|
793 | 798 | newProcUnitConfObjDict = {} |
|
794 | 799 | |
|
795 | 800 | for procKey in keyList: |
|
796 | 801 | |
|
797 | 802 | procUnitConfObj = self.procUnitConfObjDict[procKey] |
|
798 | 803 | idProcUnit = str(int(self.id)*10 + n) |
|
799 | 804 | procUnitConfObj.updateId(idProcUnit, parentId = self.id) |
|
800 | 805 | |
|
801 | 806 | newProcUnitConfObjDict[idProcUnit] = procUnitConfObj |
|
802 | 807 | n += 1 |
|
803 | 808 | |
|
804 | 809 | self.procUnitConfObjDict = newProcUnitConfObjDict |
|
805 | 810 | |
|
806 | 811 | def setup(self, id, name, description): |
|
807 | 812 | |
|
808 | 813 | self.id = str(id) |
|
809 | 814 | self.name = name |
|
810 | 815 | self.description = description |
|
811 | 816 | |
|
812 | 817 | def update(self, name, description): |
|
813 | 818 | |
|
814 | 819 | self.name = name |
|
815 | 820 | self.description = description |
|
816 | 821 | |
|
817 | 822 | def addReadUnit(self, datatype=None, name=None, **kwargs): |
|
818 | 823 | |
|
819 | 824 | idReadUnit = self.__getNewId() |
|
820 | 825 | |
|
821 | 826 | readUnitConfObj = ReadUnitConf() |
|
822 | 827 | readUnitConfObj.setup(idReadUnit, name, datatype, parentId=self.id, **kwargs) |
|
823 | 828 | |
|
824 | 829 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj |
|
825 | 830 | |
|
826 | 831 | return readUnitConfObj |
|
827 | 832 | |
|
828 | 833 | def addProcUnit(self, inputId='0', datatype=None, name=None): |
|
829 | 834 | |
|
830 | 835 | idProcUnit = self.__getNewId() |
|
831 | 836 | |
|
832 | 837 | procUnitConfObj = ProcUnitConf() |
|
833 | 838 | procUnitConfObj.setup(idProcUnit, name, datatype, inputId, parentId=self.id) |
|
834 | 839 | |
|
835 | 840 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj |
|
836 | 841 | |
|
837 | 842 | return procUnitConfObj |
|
838 | 843 | |
|
839 | 844 | def removeProcUnit(self, id): |
|
840 | 845 | |
|
841 | 846 | if id in self.procUnitConfObjDict.keys(): |
|
842 | 847 | self.procUnitConfObjDict.pop(id) |
|
843 | 848 | |
|
844 | 849 | def getReadUnitId(self): |
|
845 | 850 | |
|
846 | 851 | readUnitConfObj = self.getReadUnitObj() |
|
847 | 852 | |
|
848 | 853 | return readUnitConfObj.id |
|
849 | 854 | |
|
850 | 855 | def getReadUnitObj(self): |
|
851 | 856 | |
|
852 | 857 | for obj in self.procUnitConfObjDict.values(): |
|
853 | 858 | if obj.getElementName() == "ReadUnit": |
|
854 | 859 | return obj |
|
855 | 860 | |
|
856 | 861 | return None |
|
857 | 862 | |
|
858 | def getProcUnitObj(self, id): | |
|
863 | def getProcUnitObj(self, id=None, name=None): | |
|
864 | ||
|
865 | if id != None: | |
|
866 | return self.procUnitConfObjDict[id] | |
|
867 | ||
|
868 | if name != None: | |
|
869 | return self.getProcUnitObjByName(name) | |
|
870 | ||
|
871 | return None | |
|
859 | 872 | |
|
860 | return self.procUnitConfObjDict[id] | |
|
861 | ||
|
862 | 873 | def getProcUnitObjByName(self, name): |
|
863 | 874 | |
|
864 | 875 | for obj in self.procUnitConfObjDict.values(): |
|
865 | 876 | if obj.name == name: |
|
866 | 877 | return obj |
|
867 | 878 | |
|
868 | 879 | return None |
|
869 |
|
|
|
880 | ||
|
881 | def procUnitItems(self): | |
|
882 | ||
|
883 | return self.procUnitConfObjDict.items() | |
|
884 | ||
|
870 | 885 | def makeXml(self): |
|
871 | 886 | |
|
872 | 887 | projectElement = Element('Project') |
|
873 | 888 | projectElement.set('id', str(self.id)) |
|
874 | 889 | projectElement.set('name', self.name) |
|
875 | 890 | projectElement.set('description', self.description) |
|
876 | 891 | |
|
877 | 892 | # for readUnitConfObj in self.readUnitConfObjList: |
|
878 | 893 | # readUnitConfObj.makeXml(projectElement) |
|
879 | 894 | |
|
880 | 895 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
881 | 896 | procUnitConfObj.makeXml(projectElement) |
|
882 | 897 | |
|
883 | 898 | self.projectElement = projectElement |
|
884 | 899 | |
|
885 | 900 | def writeXml(self, filename): |
|
886 | 901 | |
|
887 | 902 | self.makeXml() |
|
888 | 903 | |
|
889 | 904 | #print prettify(self.projectElement) |
|
890 | 905 | |
|
891 | 906 | ElementTree(self.projectElement).write(filename, method='xml') |
|
892 | 907 | |
|
893 | 908 | def readXml(self, filename): |
|
894 | 909 | |
|
895 | 910 | #tree = ET.parse(filename) |
|
896 | 911 | self.projectElement = None |
|
897 | 912 | # self.readUnitConfObjList = [] |
|
898 | 913 | self.procUnitConfObjDict = {} |
|
899 | 914 | |
|
900 | 915 | self.projectElement = ElementTree().parse(filename) |
|
901 | 916 | |
|
902 | 917 | self.project = self.projectElement.tag |
|
903 | 918 | |
|
904 | 919 | self.id = self.projectElement.get('id') |
|
905 | 920 | self.name = self.projectElement.get('name') |
|
906 | 921 | self.description = self.projectElement.get('description') |
|
907 | 922 | |
|
908 | 923 | readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName()) |
|
909 | 924 | |
|
910 | 925 | for readUnitElement in readUnitElementList: |
|
911 | 926 | readUnitConfObj = ReadUnitConf() |
|
912 | 927 | readUnitConfObj.readXml(readUnitElement) |
|
913 | 928 | |
|
914 | 929 | if readUnitConfObj.parentId == None: |
|
915 | 930 | readUnitConfObj.parentId = self.id |
|
916 | 931 | |
|
917 | 932 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj |
|
918 | 933 | |
|
919 | 934 | procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName()) |
|
920 | 935 | |
|
921 | 936 | for procUnitElement in procUnitElementList: |
|
922 | 937 | procUnitConfObj = ProcUnitConf() |
|
923 | 938 | procUnitConfObj.readXml(procUnitElement) |
|
924 | 939 | |
|
925 | 940 | if procUnitConfObj.parentId == None: |
|
926 | 941 | procUnitConfObj.parentId = self.id |
|
927 | 942 | |
|
928 | 943 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj |
|
929 | 944 | |
|
930 | 945 | def printattr(self): |
|
931 | 946 | |
|
932 | 947 | print "Project[%s]: name = %s, description = %s" %(self.id, |
|
933 | 948 | self.name, |
|
934 | 949 | self.description) |
|
935 | 950 | |
|
936 | 951 | # for readUnitConfObj in self.readUnitConfObjList: |
|
937 | 952 | # readUnitConfObj.printattr() |
|
938 | 953 | |
|
939 | 954 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
940 | 955 | procUnitConfObj.printattr() |
|
941 | 956 | |
|
942 | 957 | def createObjects(self): |
|
943 | 958 | |
|
944 | 959 | # for readUnitConfObj in self.readUnitConfObjList: |
|
945 | 960 | # readUnitConfObj.createObjects() |
|
946 | 961 | |
|
947 | 962 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
948 | 963 | procUnitConfObj.createObjects() |
|
949 | 964 | |
|
950 | 965 | def __connect(self, objIN, thisObj): |
|
951 | 966 | |
|
952 | 967 | thisObj.setInput(objIN.getOutputObj()) |
|
953 | 968 | |
|
954 | 969 | def connectObjects(self): |
|
955 | 970 | |
|
956 | 971 | for thisPUConfObj in self.procUnitConfObjDict.values(): |
|
957 | 972 | |
|
958 | 973 | inputId = thisPUConfObj.getInputId() |
|
959 | 974 | |
|
960 | 975 | if int(inputId) == 0: |
|
961 | 976 | continue |
|
962 | 977 | |
|
963 | 978 | #Get input object |
|
964 | 979 | puConfINObj = self.procUnitConfObjDict[inputId] |
|
965 | 980 | puObjIN = puConfINObj.getProcUnitObj() |
|
966 | 981 | |
|
967 | 982 | #Get current object |
|
968 | 983 | thisPUObj = thisPUConfObj.getProcUnitObj() |
|
969 | 984 | |
|
970 | 985 | self.__connect(puObjIN, thisPUObj) |
|
971 | 986 | |
|
972 | 987 | def run(self): |
|
973 | 988 | |
|
974 | 989 | # for readUnitConfObj in self.readUnitConfObjList: |
|
975 | 990 | # readUnitConfObj.run() |
|
976 | 991 | |
|
977 | 992 | print "*"*40 |
|
978 | 993 | print " Starting SIGNAL CHAIN PROCESSING " |
|
979 | 994 | print "*"*40 |
|
980 | 995 | |
|
981 | 996 | |
|
982 | 997 | keyList = self.procUnitConfObjDict.keys() |
|
983 | 998 | keyList.sort() |
|
984 | 999 | |
|
985 | 1000 | while(True): |
|
986 | 1001 | |
|
987 | 1002 | finalSts = False |
|
988 | 1003 | |
|
989 | 1004 | for procKey in keyList: |
|
990 | 1005 | # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id) |
|
991 | 1006 | |
|
992 | 1007 | procUnitConfObj = self.procUnitConfObjDict[procKey] |
|
993 | 1008 | sts = procUnitConfObj.run() |
|
994 | 1009 | finalSts = finalSts or sts |
|
995 | 1010 | |
|
996 | 1011 | #If every process unit finished so end process |
|
997 | 1012 | if not(finalSts): |
|
998 | 1013 | print "Every process unit have finished" |
|
999 | 1014 | break |
|
1000 | 1015 | |
|
1001 | 1016 | if self.control['pause']: |
|
1002 | 1017 | print "Process suspended" |
|
1003 | 1018 | |
|
1004 | 1019 | while True: |
|
1005 | 1020 | sleep(0.1) |
|
1006 | 1021 | |
|
1007 | 1022 | if not self.control['pause']: |
|
1008 | 1023 | break |
|
1009 | 1024 | |
|
1010 | 1025 | if self.control['stop']: |
|
1011 | 1026 | break |
|
1012 | 1027 | print "Process reinitialized" |
|
1013 | 1028 | |
|
1014 | 1029 | if self.control['stop']: |
|
1015 | 1030 | print "Process stopped" |
|
1016 | 1031 | break |
|
1017 | 1032 | |
|
1018 | 1033 | #Closing every process |
|
1019 | 1034 | for procKey in keyList: |
|
1020 | 1035 | procUnitConfObj = self.procUnitConfObjDict[procKey] |
|
1021 | 1036 | procUnitConfObj.close() |
|
1022 | 1037 | |
|
1023 | 1038 | print "Process finished" |
|
1024 | 1039 | |
|
1025 | 1040 | def start(self, filename): |
|
1026 | 1041 | |
|
1027 | 1042 | self.writeXml(filename) |
|
1028 | 1043 | self.readXml(filename) |
|
1029 | 1044 | |
|
1030 | 1045 | self.createObjects() |
|
1031 | 1046 | self.connectObjects() |
|
1032 | 1047 | self.run() |
|
1033 | 1048 | |
|
1034 | 1049 | class ControllerThread(threading.Thread, Project): |
|
1035 | 1050 | |
|
1036 | 1051 | def __init__(self, filename): |
|
1037 | 1052 | |
|
1038 | 1053 | threading.Thread.__init__(self) |
|
1039 | 1054 | Project.__init__(self) |
|
1040 | 1055 | |
|
1041 | 1056 | self.setDaemon(True) |
|
1042 | 1057 | |
|
1043 | 1058 | self.filename = filename |
|
1044 | 1059 | self.control = {'stop':False, 'pause':False} |
|
1045 | 1060 | |
|
1046 | 1061 | def stop(self): |
|
1047 | 1062 | self.control['stop'] = True |
|
1048 | 1063 | |
|
1049 | 1064 | def pause(self): |
|
1050 | 1065 | self.control['pause'] = not(self.control['pause']) |
|
1051 | 1066 | |
|
1052 | 1067 | def run(self): |
|
1053 | 1068 | self.control['stop'] = False |
|
1054 | 1069 | self.control['pause'] = False |
|
1055 | 1070 | |
|
1056 | 1071 | self.readXml(self.filename) |
|
1057 | 1072 | self.createObjects() |
|
1058 | 1073 | self.connectObjects() |
|
1059 | 1074 | Project.run(self) |
|
1060 | 1075 | |
|
1061 | 1076 | if __name__ == '__main__': |
|
1062 | 1077 | |
|
1063 | 1078 | desc = "Segundo Test" |
|
1064 | 1079 | filename = "schain.xml" |
|
1065 | 1080 | |
|
1066 | 1081 | controllerObj = Project() |
|
1067 | 1082 | |
|
1068 | 1083 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
1069 | 1084 | |
|
1070 | 1085 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', |
|
1071 | 1086 | path='data/rawdata/', |
|
1072 | 1087 | startDate='2011/01/01', |
|
1073 | 1088 | endDate='2012/12/31', |
|
1074 | 1089 | startTime='00:00:00', |
|
1075 | 1090 | endTime='23:59:59', |
|
1076 | 1091 | online=1, |
|
1077 | 1092 | walk=1) |
|
1078 | 1093 | |
|
1079 | 1094 | # opObj00 = readUnitConfObj.addOperation(name='printInfo') |
|
1080 | 1095 | |
|
1081 | 1096 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) |
|
1082 | 1097 | |
|
1083 | 1098 | opObj10 = procUnitConfObj0.addOperation(name='selectChannels') |
|
1084 | 1099 | opObj10.addParameter(name='channelList', value='3,4,5', format='intlist') |
|
1085 | 1100 | |
|
1086 | 1101 | opObj10 = procUnitConfObj0.addOperation(name='selectHeights') |
|
1087 | 1102 | opObj10.addParameter(name='minHei', value='90', format='float') |
|
1088 | 1103 | opObj10.addParameter(name='maxHei', value='180', format='float') |
|
1089 | 1104 | |
|
1090 | 1105 | opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external') |
|
1091 | 1106 | opObj12.addParameter(name='n', value='10', format='int') |
|
1092 | 1107 | |
|
1093 | 1108 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) |
|
1094 | 1109 | procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int') |
|
1095 | 1110 | # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='') |
|
1096 | 1111 | |
|
1097 | 1112 | |
|
1098 | 1113 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') |
|
1099 | 1114 | opObj11.addParameter(name='idfigure', value='1', format='int') |
|
1100 | 1115 | opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str') |
|
1101 | 1116 | opObj11.addParameter(name='zmin', value='40', format='int') |
|
1102 | 1117 | opObj11.addParameter(name='zmax', value='90', format='int') |
|
1103 | 1118 | opObj11.addParameter(name='showprofile', value='1', format='int') |
|
1104 | 1119 | |
|
1105 | 1120 | # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='external') |
|
1106 | 1121 | # opObj11.addParameter(name='idfigure', value='2', format='int') |
|
1107 | 1122 | # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') |
|
1108 | 1123 | # opObj11.addParameter(name='zmin', value='40', format='int') |
|
1109 | 1124 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
1110 | 1125 | |
|
1111 | 1126 | |
|
1112 | 1127 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Voltage', inputId=procUnitConfObj0.getId()) |
|
1113 | 1128 | # |
|
1114 | 1129 | # opObj12 = procUnitConfObj2.addOperation(name='CohInt', optype='external') |
|
1115 | 1130 | # opObj12.addParameter(name='n', value='2', format='int') |
|
1116 | 1131 | # opObj12.addParameter(name='overlapping', value='1', format='int') |
|
1117 | 1132 | # |
|
1118 | 1133 | # procUnitConfObj3 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj2.getId()) |
|
1119 | 1134 | # procUnitConfObj3.addParameter(name='nFFTPoints', value='32', format='int') |
|
1120 | 1135 | # |
|
1121 | 1136 | # opObj11 = procUnitConfObj3.addOperation(name='SpectraPlot', optype='external') |
|
1122 | 1137 | # opObj11.addParameter(name='idfigure', value='2', format='int') |
|
1123 | 1138 | # opObj11.addParameter(name='wintitle', value='SpectraPlot1', format='str') |
|
1124 | 1139 | # opObj11.addParameter(name='zmin', value='40', format='int') |
|
1125 | 1140 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
1126 | 1141 | # opObj11.addParameter(name='showprofile', value='1', format='int') |
|
1127 | 1142 | |
|
1128 | 1143 | # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='external') |
|
1129 | 1144 | # opObj11.addParameter(name='idfigure', value='10', format='int') |
|
1130 | 1145 | # opObj11.addParameter(name='wintitle', value='RTI', format='str') |
|
1131 | 1146 | ## opObj11.addParameter(name='xmin', value='21', format='float') |
|
1132 | 1147 | ## opObj11.addParameter(name='xmax', value='22', format='float') |
|
1133 | 1148 | # opObj11.addParameter(name='zmin', value='40', format='int') |
|
1134 | 1149 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
1135 | 1150 | # opObj11.addParameter(name='showprofile', value='1', format='int') |
|
1136 | 1151 | # opObj11.addParameter(name='timerange', value=str(60), format='int') |
|
1137 | 1152 | |
|
1138 | 1153 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') |
|
1139 | 1154 | # opObj10.addParameter(name='channelList', value='0,2,4,6', format='intlist') |
|
1140 | 1155 | # |
|
1141 | 1156 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='external') |
|
1142 | 1157 | # opObj12.addParameter(name='n', value='2', format='int') |
|
1143 | 1158 | # |
|
1144 | 1159 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') |
|
1145 | 1160 | # opObj11.addParameter(name='idfigure', value='2', format='int') |
|
1146 | 1161 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') |
|
1147 | 1162 | # opObj11.addParameter(name='zmin', value='70', format='int') |
|
1148 | 1163 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
1149 | 1164 | # |
|
1150 | 1165 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') |
|
1151 | 1166 | # opObj10.addParameter(name='channelList', value='2,6', format='intlist') |
|
1152 | 1167 | # |
|
1153 | 1168 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='external') |
|
1154 | 1169 | # opObj12.addParameter(name='n', value='2', format='int') |
|
1155 | 1170 | # |
|
1156 | 1171 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') |
|
1157 | 1172 | # opObj11.addParameter(name='idfigure', value='3', format='int') |
|
1158 | 1173 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') |
|
1159 | 1174 | # opObj11.addParameter(name='zmin', value='70', format='int') |
|
1160 | 1175 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
1161 | 1176 | |
|
1162 | 1177 | |
|
1163 | 1178 | # opObj12 = procUnitConfObj1.addOperation(name='decoder') |
|
1164 | 1179 | # opObj12.addParameter(name='ncode', value='2', format='int') |
|
1165 | 1180 | # opObj12.addParameter(name='nbauds', value='8', format='int') |
|
1166 | 1181 | # opObj12.addParameter(name='code0', value='001110011', format='int') |
|
1167 | 1182 | # opObj12.addParameter(name='code1', value='001110011', format='int') |
|
1168 | 1183 | |
|
1169 | 1184 | |
|
1170 | 1185 | |
|
1171 | 1186 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId()) |
|
1172 | 1187 | # |
|
1173 | 1188 | # opObj21 = procUnitConfObj2.addOperation(name='IncohInt', optype='external') |
|
1174 | 1189 | # opObj21.addParameter(name='n', value='2', format='int') |
|
1175 | 1190 | # |
|
1176 | 1191 | # opObj11 = procUnitConfObj2.addOperation(name='SpectraPlot', optype='external') |
|
1177 | 1192 | # opObj11.addParameter(name='idfigure', value='4', format='int') |
|
1178 | 1193 | # opObj11.addParameter(name='wintitle', value='SpectraPlot OBJ 2', format='str') |
|
1179 | 1194 | # opObj11.addParameter(name='zmin', value='70', format='int') |
|
1180 | 1195 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
1181 | 1196 | |
|
1182 | 1197 | print "Escribiendo el archivo XML" |
|
1183 | 1198 | |
|
1184 | 1199 | controllerObj.writeXml(filename) |
|
1185 | 1200 | |
|
1186 | 1201 | print "Leyendo el archivo XML" |
|
1187 | 1202 | controllerObj.readXml(filename) |
|
1188 | 1203 | #controllerObj.printattr() |
|
1189 | 1204 | |
|
1190 | 1205 | controllerObj.createObjects() |
|
1191 | 1206 | controllerObj.connectObjects() |
|
1192 | 1207 | controllerObj.run() |
|
1193 | 1208 | |
|
1194 | 1209 | No newline at end of file |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
@@ -1,93 +1,94 | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | # Form implementation generated from reading ui file '/home/roj-idl71/SignalChain/initwindowv2.ui' |
|
4 | 4 | # |
|
5 | 5 | # Created: Wed Mar 6 15:32:39 2013 |
|
6 | 6 | # by: PyQt4 UI code generator 4.8.6 |
|
7 | 7 | # |
|
8 | 8 | # WARNING! All changes made in this file will be lost! |
|
9 | 9 | |
|
10 | 10 | from PyQt4 import QtCore, QtGui |
|
11 | 11 | |
|
12 | 12 | try: |
|
13 | 13 | _fromUtf8 = QtCore.QString.fromUtf8 |
|
14 | 14 | except AttributeError: |
|
15 | 15 | _fromUtf8 = lambda s: s |
|
16 | 16 | |
|
17 | 17 | import os |
|
18 | 18 | from schainpy.gui.figures import tools |
|
19 | 19 | |
|
20 | INITIAL_MSG = "Signal Chain GUI - v2.1" | |
|
20 | 21 | FIGURES_PATH = tools.get_path() |
|
21 | 22 | |
|
22 | 23 | class Ui_InitWindow(object): |
|
23 | 24 | def setupUi(self, Dialog): |
|
24 | 25 | Dialog.setObjectName(_fromUtf8("Dialog")) |
|
25 | 26 | Dialog.resize(652, 496) |
|
26 | 27 | Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8)) |
|
27 | 28 | self.gridLayout = QtGui.QGridLayout(Dialog) |
|
28 | 29 | self.gridLayout.setObjectName(_fromUtf8("gridLayout")) |
|
29 | 30 | self.verticalLayout_3 = QtGui.QVBoxLayout() |
|
30 | 31 | self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) |
|
31 | 32 | self.verticalLayout_4 = QtGui.QVBoxLayout() |
|
32 | 33 | self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4")) |
|
33 | 34 | self.label_3 = QtGui.QLabel(Dialog) |
|
34 | 35 | font = QtGui.QFont() |
|
35 | 36 | font.setFamily(_fromUtf8("Cambria")) |
|
36 | 37 | font.setPointSize(22) |
|
37 | 38 | font.setBold(False) |
|
38 | 39 | font.setWeight(50) |
|
39 | 40 | self.label_3.setFont(font) |
|
40 |
self.label_3.setText(QtGui.QApplication.translate("Dialog", |
|
|
41 | self.label_3.setText(QtGui.QApplication.translate("Dialog", INITIAL_MSG, None, QtGui.QApplication.UnicodeUTF8)) | |
|
41 | 42 | self.label_3.setObjectName(_fromUtf8("label_3")) |
|
42 | 43 | self.verticalLayout_4.addWidget(self.label_3) |
|
43 | 44 | self.line_2 = QtGui.QFrame(Dialog) |
|
44 | 45 | self.line_2.setFrameShape(QtGui.QFrame.HLine) |
|
45 | 46 | self.line_2.setFrameShadow(QtGui.QFrame.Sunken) |
|
46 | 47 | self.line_2.setObjectName(_fromUtf8("line_2")) |
|
47 | 48 | self.verticalLayout_4.addWidget(self.line_2) |
|
48 | 49 | self.label_4 = QtGui.QLabel(Dialog) |
|
49 | 50 | self.label_4.setText(_fromUtf8("")) |
|
50 | 51 | self.label_4.setPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"w.jpg") ))) |
|
51 | 52 | self.label_4.setScaledContents(True) |
|
52 | 53 | self.label_4.setObjectName(_fromUtf8("label_4")) |
|
53 | 54 | self.verticalLayout_4.addWidget(self.label_4) |
|
54 | 55 | self.verticalLayout_3.addLayout(self.verticalLayout_4) |
|
55 | 56 | self.horizontalLayout_3 = QtGui.QHBoxLayout() |
|
56 | 57 | self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) |
|
57 | 58 | self.horizontalLayout_4 = QtGui.QHBoxLayout() |
|
58 | 59 | self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) |
|
59 | 60 | spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
60 | 61 | self.horizontalLayout_4.addItem(spacerItem) |
|
61 | 62 | self.ExitBtn = QtGui.QPushButton(Dialog) |
|
62 | 63 | self.ExitBtn.setText(QtGui.QApplication.translate("Dialog", "Exit", None, QtGui.QApplication.UnicodeUTF8)) |
|
63 | 64 | self.ExitBtn.setObjectName(_fromUtf8("ExitBtn")) |
|
64 | 65 | self.horizontalLayout_4.addWidget(self.ExitBtn) |
|
65 | 66 | self.ContinueBtn = QtGui.QPushButton(Dialog) |
|
66 | 67 | self.ContinueBtn.setText(QtGui.QApplication.translate("Dialog", "Continue", None, QtGui.QApplication.UnicodeUTF8)) |
|
67 | 68 | self.ContinueBtn.setObjectName(_fromUtf8("ContinueBtn")) |
|
68 | 69 | self.horizontalLayout_4.addWidget(self.ContinueBtn) |
|
69 | 70 | spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
70 | 71 | self.horizontalLayout_4.addItem(spacerItem1) |
|
71 | 72 | self.horizontalLayout_3.addLayout(self.horizontalLayout_4) |
|
72 | 73 | self.verticalLayout_3.addLayout(self.horizontalLayout_3) |
|
73 | 74 | self.gridLayout.addLayout(self.verticalLayout_3, 0, 0, 1, 1) |
|
74 | 75 | |
|
75 | 76 | self.retranslateUi(Dialog) |
|
76 | 77 | QtCore.QMetaObject.connectSlotsByName(Dialog) |
|
77 | 78 | |
|
78 | 79 | def retranslateUi(self, Dialog): |
|
79 | 80 | pass |
|
80 | 81 | |
|
81 | 82 | |
|
82 | 83 | if __name__ == "__main__": |
|
83 | 84 | import sys |
|
84 | 85 | app = QtGui.QApplication(sys.argv) |
|
85 | 86 | Dialog = QtGui.QDialog() |
|
86 | 87 | ui = Ui_InitWindow() |
|
87 | 88 | ui.setupUi(Dialog) |
|
88 | 89 | Dialog.show() |
|
89 | 90 | sys.exit(app.exec_()) |
|
90 | 91 | |
|
91 | 92 | |
|
92 | 93 | |
|
93 | 94 |
@@ -1,451 +1,451 | |||
|
1 | 1 | from PyQt4 import QtCore, QtGui |
|
2 | 2 | |
|
3 | 3 | try: |
|
4 | 4 | _fromUtf8 = QtCore.QString.fromUtf8 |
|
5 | 5 | except AttributeError: |
|
6 | 6 | def _fromUtf8(s): |
|
7 | 7 | return s |
|
8 | 8 | |
|
9 | 9 | try: |
|
10 | 10 | _encoding = QtGui.QApplication.UnicodeUTF8 |
|
11 | 11 | def _translate(context, text, disambig): |
|
12 | 12 | return QtGui.QApplication.translate(context, text, disambig, _encoding) |
|
13 | 13 | except AttributeError: |
|
14 | 14 | def _translate(context, text, disambig): |
|
15 | 15 | return QtGui.QApplication.translate(context, text, disambig) |
|
16 | 16 | |
|
17 | 17 | class Ui_SpectraTab(object): |
|
18 | 18 | |
|
19 | 19 | def setupUi(self): |
|
20 | 20 | |
|
21 | 21 | self.tabSpectra = QtGui.QWidget() |
|
22 | 22 | self.tabSpectra.setObjectName(_fromUtf8("tabSpectra")) |
|
23 | 23 | self.gridLayout_7 = QtGui.QGridLayout(self.tabSpectra) |
|
24 | 24 | self.gridLayout_7.setObjectName(_fromUtf8("gridLayout_7")) |
|
25 | 25 | self.frame_5 = QtGui.QFrame(self.tabSpectra) |
|
26 | 26 | self.frame_5.setFrameShape(QtGui.QFrame.StyledPanel) |
|
27 | 27 | self.frame_5.setFrameShadow(QtGui.QFrame.Raised) |
|
28 | 28 | self.frame_5.setObjectName(_fromUtf8("frame_5")) |
|
29 | 29 | self.gridLayout_18 = QtGui.QGridLayout(self.frame_5) |
|
30 | 30 | self.gridLayout_18.setObjectName(_fromUtf8("gridLayout_18")) |
|
31 | 31 | self.specOpOk = QtGui.QPushButton(self.frame_5) |
|
32 | 32 | self.specOpOk.setObjectName(_fromUtf8("specOpOk")) |
|
33 | 33 | self.gridLayout_18.addWidget(self.specOpOk, 0, 0, 1, 1) |
|
34 | 34 | self.specGraphClear = QtGui.QPushButton(self.frame_5) |
|
35 | 35 | self.specGraphClear.setObjectName(_fromUtf8("specGraphClear")) |
|
36 | 36 | self.gridLayout_18.addWidget(self.specGraphClear, 0, 1, 1, 1) |
|
37 | 37 | self.gridLayout_7.addWidget(self.frame_5, 1, 1, 1, 1) |
|
38 | 38 | self.tabWidgetSpectra = QtGui.QTabWidget(self.tabSpectra) |
|
39 | 39 | self.tabWidgetSpectra.setObjectName(_fromUtf8("tabWidgetSpectra")) |
|
40 | 40 | self.tabopSpectra = QtGui.QWidget() |
|
41 | 41 | self.tabopSpectra.setObjectName(_fromUtf8("tabopSpectra")) |
|
42 | 42 | self.gridLayout_5 = QtGui.QGridLayout(self.tabopSpectra) |
|
43 | 43 | self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5")) |
|
44 | 44 | self.specOpCebCrossSpectra = QtGui.QCheckBox(self.tabopSpectra) |
|
45 | 45 | self.specOpCebCrossSpectra.setObjectName(_fromUtf8("specOpCebCrossSpectra")) |
|
46 | 46 | self.gridLayout_5.addWidget(self.specOpCebCrossSpectra, 4, 0, 1, 2) |
|
47 | 47 | self.specOpComChannel = QtGui.QComboBox(self.tabopSpectra) |
|
48 | 48 | self.specOpComChannel.setObjectName(_fromUtf8("specOpComChannel")) |
|
49 | 49 | self.specOpComChannel.addItem(_fromUtf8("")) |
|
50 | 50 | self.specOpComChannel.addItem(_fromUtf8("")) |
|
51 | 51 | self.gridLayout_5.addWidget(self.specOpComChannel, 8, 0, 1, 2) |
|
52 | 52 | self.specOpChannel = QtGui.QLineEdit(self.tabopSpectra) |
|
53 | 53 | self.specOpChannel.setObjectName(_fromUtf8("specOpChannel")) |
|
54 | 54 | self.gridLayout_5.addWidget(self.specOpChannel, 8, 3, 1, 2) |
|
55 | 55 | self.specOpComHeights = QtGui.QComboBox(self.tabopSpectra) |
|
56 | 56 | self.specOpComHeights.setObjectName(_fromUtf8("specOpComHeights")) |
|
57 | 57 | self.specOpComHeights.addItem(_fromUtf8("")) |
|
58 | 58 | self.specOpComHeights.addItem(_fromUtf8("")) |
|
59 | 59 | self.gridLayout_5.addWidget(self.specOpComHeights, 11, 0, 1, 2) |
|
60 | 60 | self.specOpHeights = QtGui.QLineEdit(self.tabopSpectra) |
|
61 | 61 | self.specOpHeights.setObjectName(_fromUtf8("specOpHeights")) |
|
62 | 62 | self.gridLayout_5.addWidget(self.specOpHeights, 11, 3, 1, 2) |
|
63 | 63 | self.specOpIncoherent = QtGui.QLineEdit(self.tabopSpectra) |
|
64 | 64 | self.specOpIncoherent.setObjectName(_fromUtf8("specOpIncoherent")) |
|
65 | 65 | self.gridLayout_5.addWidget(self.specOpIncoherent, 13, 3, 1, 2) |
|
66 | 66 | self.specOpCebRemoveDC = QtGui.QCheckBox(self.tabopSpectra) |
|
67 | 67 | self.specOpCebRemoveDC.setObjectName(_fromUtf8("specOpCebRemoveDC")) |
|
68 | 68 | self.gridLayout_5.addWidget(self.specOpCebRemoveDC, 14, 0, 1, 2) |
|
69 | 69 | self.specOpCebHeights = QtGui.QCheckBox(self.tabopSpectra) |
|
70 | 70 | self.specOpCebHeights.setObjectName(_fromUtf8("specOpCebHeights")) |
|
71 | 71 | self.gridLayout_5.addWidget(self.specOpCebHeights, 9, 0, 1, 1) |
|
72 | 72 | self.specOpCebChannel = QtGui.QCheckBox(self.tabopSpectra) |
|
73 | 73 | self.specOpCebChannel.setObjectName(_fromUtf8("specOpCebChannel")) |
|
74 | 74 | self.gridLayout_5.addWidget(self.specOpCebChannel, 7, 0, 1, 1) |
|
75 | 75 | self.specOppairsList = QtGui.QLineEdit(self.tabopSpectra) |
|
76 | 76 | self.specOppairsList.setObjectName(_fromUtf8("specOppairsList")) |
|
77 | 77 | self.gridLayout_5.addWidget(self.specOppairsList, 6, 3, 1, 2) |
|
78 | 78 | self.specOpnFFTpoints = QtGui.QLineEdit(self.tabopSpectra) |
|
79 | 79 | self.specOpnFFTpoints.setObjectName(_fromUtf8("specOpnFFTpoints")) |
|
80 | 80 | self.gridLayout_5.addWidget(self.specOpnFFTpoints, 2, 3, 1, 2) |
|
81 | 81 | self.label_31 = QtGui.QLabel(self.tabopSpectra) |
|
82 | 82 | self.label_31.setObjectName(_fromUtf8("label_31")) |
|
83 | 83 | self.gridLayout_5.addWidget(self.label_31, 6, 0, 1, 2) |
|
84 | 84 | self.label_26 = QtGui.QLabel(self.tabopSpectra) |
|
85 | 85 | self.label_26.setObjectName(_fromUtf8("label_26")) |
|
86 | 86 | self.gridLayout_5.addWidget(self.label_26, 2, 0, 1, 2) |
|
87 | 87 | self.specOpCebIncoherent = QtGui.QCheckBox(self.tabopSpectra) |
|
88 | 88 | self.specOpCebIncoherent.setObjectName(_fromUtf8("specOpCebIncoherent")) |
|
89 | 89 | self.gridLayout_5.addWidget(self.specOpCebIncoherent, 12, 0, 1, 1) |
|
90 | 90 | self.specOpCobIncInt = QtGui.QComboBox(self.tabopSpectra) |
|
91 | 91 | self.specOpCobIncInt.setObjectName(_fromUtf8("specOpCobIncInt")) |
|
92 | 92 | self.specOpCobIncInt.addItem(_fromUtf8("")) |
|
93 | 93 | self.specOpCobIncInt.addItem(_fromUtf8("")) |
|
94 | 94 | self.gridLayout_5.addWidget(self.specOpCobIncInt, 13, 0, 1, 2) |
|
95 | 95 | spacerItem9 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
96 | 96 | self.gridLayout_5.addItem(spacerItem9, 12, 3, 1, 1) |
|
97 | 97 | self.specOpCebRadarfrequency = QtGui.QCheckBox(self.tabopSpectra) |
|
98 | 98 | self.specOpCebRadarfrequency.setObjectName(_fromUtf8("specOpCebRadarfrequency")) |
|
99 | 99 | self.gridLayout_5.addWidget(self.specOpCebRadarfrequency, 0, 0, 1, 2) |
|
100 | 100 | spacerItem10 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
101 | 101 | self.gridLayout_5.addItem(spacerItem10, 9, 3, 1, 1) |
|
102 | 102 | spacerItem11 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
103 | 103 | self.gridLayout_5.addItem(spacerItem11, 7, 3, 1, 1) |
|
104 | 104 | self.specOpRadarfrequency = QtGui.QLineEdit(self.tabopSpectra) |
|
105 | 105 | self.specOpRadarfrequency.setObjectName(_fromUtf8("specOpRadarfrequency")) |
|
106 | 106 | self.gridLayout_5.addWidget(self.specOpRadarfrequency, 0, 3, 1, 2) |
|
107 | 107 | spacerItem12 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
108 | 108 | self.gridLayout_5.addItem(spacerItem12, 4, 3, 1, 1) |
|
109 | 109 | self.label_21 = QtGui.QLabel(self.tabopSpectra) |
|
110 | 110 | self.label_21.setObjectName(_fromUtf8("label_21")) |
|
111 | 111 | self.gridLayout_5.addWidget(self.label_21, 1, 0, 1, 1) |
|
112 | 112 | self.specOpProfiles = QtGui.QLineEdit(self.tabopSpectra) |
|
113 | 113 | self.specOpProfiles.setObjectName(_fromUtf8("specOpProfiles")) |
|
114 | 114 | self.gridLayout_5.addWidget(self.specOpProfiles, 1, 3, 1, 2) |
|
115 | 115 | self.specOpCebRemoveInt = QtGui.QCheckBox(self.tabopSpectra) |
|
116 | 116 | self.specOpCebRemoveInt.setObjectName(_fromUtf8("specOpCebRemoveInt")) |
|
117 | 117 | self.gridLayout_5.addWidget(self.specOpCebRemoveInt, 15, 0, 1, 1) |
|
118 | 118 | spacerItem13 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
119 | 119 | self.gridLayout_5.addItem(spacerItem13, 15, 3, 1, 1) |
|
120 | 120 | self.label_70 = QtGui.QLabel(self.tabopSpectra) |
|
121 | 121 | self.label_70.setObjectName(_fromUtf8("label_70")) |
|
122 | 122 | self.gridLayout_5.addWidget(self.label_70, 3, 0, 1, 1) |
|
123 | 123 | self.specOpCebgetNoise = QtGui.QCheckBox(self.tabopSpectra) |
|
124 | 124 | self.specOpCebgetNoise.setObjectName(_fromUtf8("specOpCebgetNoise")) |
|
125 | 125 | self.gridLayout_5.addWidget(self.specOpCebgetNoise, 16, 0, 1, 1) |
|
126 | 126 | self.specOpippFactor = QtGui.QLineEdit(self.tabopSpectra) |
|
127 | 127 | self.specOpippFactor.setObjectName(_fromUtf8("specOpippFactor")) |
|
128 | 128 | self.gridLayout_5.addWidget(self.specOpippFactor, 3, 3, 1, 2) |
|
129 | 129 | self.specOpComRemoveDC = QtGui.QComboBox(self.tabopSpectra) |
|
130 | 130 | self.specOpComRemoveDC.setObjectName(_fromUtf8("specOpComRemoveDC")) |
|
131 | 131 | self.specOpComRemoveDC.addItem(_fromUtf8("")) |
|
132 | 132 | self.specOpComRemoveDC.addItem(_fromUtf8("")) |
|
133 | 133 | self.gridLayout_5.addWidget(self.specOpComRemoveDC, 14, 3, 1, 2) |
|
134 | 134 | self.specOpgetNoise = QtGui.QLineEdit(self.tabopSpectra) |
|
135 | 135 | self.specOpgetNoise.setObjectName(_fromUtf8("specOpgetNoise")) |
|
136 | 136 | self.gridLayout_5.addWidget(self.specOpgetNoise, 16, 3, 1, 2) |
|
137 | 137 | self.tabWidgetSpectra.addTab(self.tabopSpectra, _fromUtf8("")) |
|
138 | 138 | |
|
139 | 139 | |
|
140 | 140 | self.tabgraphSpectra = QtGui.QWidget() |
|
141 | 141 | self.tabgraphSpectra.setObjectName(_fromUtf8("tabgraphSpectra")) |
|
142 | 142 | self.gridLayout_9 = QtGui.QGridLayout(self.tabgraphSpectra) |
|
143 | 143 | self.gridLayout_9.setObjectName(_fromUtf8("gridLayout_9")) |
|
144 | 144 | |
|
145 | 145 | spacerItem14 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) |
|
146 | 146 | self.gridLayout_9.addItem(spacerItem14, 14, 2, 1, 1) |
|
147 | 147 | |
|
148 | 148 | self.label_24 = QtGui.QLabel(self.tabgraphSpectra) |
|
149 | 149 | self.label_24.setObjectName(_fromUtf8("label_24")) |
|
150 | 150 | self.gridLayout_9.addWidget(self.label_24, 0, 0, 1, 1) |
|
151 | 151 | |
|
152 | 152 | self.specGraphPath = QtGui.QLineEdit(self.tabgraphSpectra) |
|
153 | 153 | self.specGraphPath.setObjectName(_fromUtf8("specGraphPath")) |
|
154 | 154 | self.gridLayout_9.addWidget(self.specGraphPath, 0, 1, 1, 6) |
|
155 | 155 | |
|
156 | 156 | self.specGraphToolPath = QtGui.QToolButton(self.tabgraphSpectra) |
|
157 | 157 | self.specGraphToolPath.setObjectName(_fromUtf8("specGraphToolPath")) |
|
158 | 158 | self.gridLayout_9.addWidget(self.specGraphToolPath, 0, 7, 1, 1) |
|
159 | 159 | |
|
160 | 160 | self.label_25 = QtGui.QLabel(self.tabgraphSpectra) |
|
161 | 161 | self.label_25.setObjectName(_fromUtf8("label_25")) |
|
162 | 162 | self.gridLayout_9.addWidget(self.label_25, 2, 0, 1, 1) |
|
163 | 163 | self.specGraphPrefix = QtGui.QLineEdit(self.tabgraphSpectra) |
|
164 | 164 | self.specGraphPrefix.setObjectName(_fromUtf8("specGraphPrefix")) |
|
165 | 165 | self.gridLayout_9.addWidget(self.specGraphPrefix, 2, 1, 1, 7) |
|
166 | 166 | |
|
167 | 167 | |
|
168 | 168 | self.label_40 = QtGui.QLabel(self.tabgraphSpectra) |
|
169 | 169 | self.label_40.setObjectName(_fromUtf8("label_40")) |
|
170 | 170 | self.gridLayout_9.addWidget(self.label_40, 6, 0, 1, 1) |
|
171 | 171 | self.label_41 = QtGui.QLabel(self.tabgraphSpectra) |
|
172 | 172 | self.label_41.setObjectName(_fromUtf8("label_41")) |
|
173 | 173 | self.gridLayout_9.addWidget(self.label_41, 8, 0, 1, 1) |
|
174 | 174 | self.label_42 = QtGui.QLabel(self.tabgraphSpectra) |
|
175 | 175 | self.label_42.setObjectName(_fromUtf8("label_42")) |
|
176 | 176 | self.gridLayout_9.addWidget(self.label_42, 9, 0, 1, 1) |
|
177 | 177 | self.label_44 = QtGui.QLabel(self.tabgraphSpectra) |
|
178 | 178 | self.label_44.setObjectName(_fromUtf8("label_44")) |
|
179 | 179 | self.gridLayout_9.addWidget(self.label_44, 10, 0, 1, 1) |
|
180 | 180 | self.label_46 = QtGui.QLabel(self.tabgraphSpectra) |
|
181 | 181 | self.label_46.setObjectName(_fromUtf8("label_46")) |
|
182 | 182 | self.gridLayout_9.addWidget(self.label_46, 11, 0, 1, 1) |
|
183 | 183 | self.label_45 = QtGui.QLabel(self.tabgraphSpectra) |
|
184 | 184 | self.label_45.setObjectName(_fromUtf8("label_45")) |
|
185 | 185 | self.gridLayout_9.addWidget(self.label_45, 13, 0, 1, 1) |
|
186 | 186 | |
|
187 | 187 | self.label_43 = QtGui.QLabel(self.tabgraphSpectra) |
|
188 | 188 | self.label_43.setObjectName(_fromUtf8("label_43")) |
|
189 | 189 | self.gridLayout_9.addWidget(self.label_43, 3, 3, 2, 1) |
|
190 | 190 | self.specGraphCebSpectraplot = QtGui.QCheckBox(self.tabgraphSpectra) |
|
191 | 191 | self.specGraphCebSpectraplot.setText(_fromUtf8("")) |
|
192 | 192 | self.specGraphCebSpectraplot.setObjectName(_fromUtf8("specGraphCebSpectraplot")) |
|
193 | 193 | self.gridLayout_9.addWidget(self.specGraphCebSpectraplot, 6, 3, 1, 1) |
|
194 | 194 | self.specGraphCebCrossSpectraplot = QtGui.QCheckBox(self.tabgraphSpectra) |
|
195 | 195 | self.specGraphCebCrossSpectraplot.setText(_fromUtf8("")) |
|
196 | 196 | self.specGraphCebCrossSpectraplot.setObjectName(_fromUtf8("specGraphCebCrossSpectraplot")) |
|
197 | 197 | self.gridLayout_9.addWidget(self.specGraphCebCrossSpectraplot, 8, 3, 1, 1) |
|
198 | 198 | self.specGraphCebRTIplot = QtGui.QCheckBox(self.tabgraphSpectra) |
|
199 | 199 | self.specGraphCebRTIplot.setText(_fromUtf8("")) |
|
200 | 200 | self.specGraphCebRTIplot.setObjectName(_fromUtf8("specGraphCebRTIplot")) |
|
201 | 201 | self.gridLayout_9.addWidget(self.specGraphCebRTIplot, 9, 3, 1, 1) |
|
202 | 202 | self.specGraphCebCoherencmap = QtGui.QCheckBox(self.tabgraphSpectra) |
|
203 | 203 | self.specGraphCebCoherencmap.setText(_fromUtf8("")) |
|
204 | 204 | self.specGraphCebCoherencmap.setObjectName(_fromUtf8("specGraphCebCoherencmap")) |
|
205 | 205 | self.gridLayout_9.addWidget(self.specGraphCebCoherencmap, 10, 3, 1, 1) |
|
206 | 206 | self.specGraphPowerprofile = QtGui.QCheckBox(self.tabgraphSpectra) |
|
207 | 207 | self.specGraphPowerprofile.setText(_fromUtf8("")) |
|
208 | 208 | self.specGraphPowerprofile.setObjectName(_fromUtf8("specGraphPowerprofile")) |
|
209 | 209 | self.gridLayout_9.addWidget(self.specGraphPowerprofile, 11, 3, 1, 1) |
|
210 | 210 | self.specGraphCebRTInoise = QtGui.QCheckBox(self.tabgraphSpectra) |
|
211 | 211 | self.specGraphCebRTInoise.setText(_fromUtf8("")) |
|
212 | 212 | self.specGraphCebRTInoise.setObjectName(_fromUtf8("specGraphCebRTInoise")) |
|
213 | 213 | self.gridLayout_9.addWidget(self.specGraphCebRTInoise, 13, 3, 1, 1) |
|
214 | 214 | |
|
215 | 215 | # spacerItem18 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
216 | 216 | # self.gridLayout_9.addItem(spacerItem18, 4, 3, 1, 1) |
|
217 | 217 | |
|
218 | 218 | self.label_47 = QtGui.QLabel(self.tabgraphSpectra) |
|
219 | 219 | self.label_47.setObjectName(_fromUtf8("label_47")) |
|
220 | 220 | self.gridLayout_9.addWidget(self.label_47, 3, 5, 2, 1) |
|
221 | 221 | self.specGraphSaveSpectra = QtGui.QCheckBox(self.tabgraphSpectra) |
|
222 | 222 | self.specGraphSaveSpectra.setText(_fromUtf8("")) |
|
223 | 223 | self.specGraphSaveSpectra.setObjectName(_fromUtf8("specGraphSaveSpectra")) |
|
224 | 224 | self.gridLayout_9.addWidget(self.specGraphSaveSpectra, 6, 5, 1, 1) |
|
225 | 225 | self.specGraphSaveCross = QtGui.QCheckBox(self.tabgraphSpectra) |
|
226 | 226 | self.specGraphSaveCross.setText(_fromUtf8("")) |
|
227 | 227 | self.specGraphSaveCross.setObjectName(_fromUtf8("specGraphSaveCross")) |
|
228 | 228 | self.gridLayout_9.addWidget(self.specGraphSaveCross, 8, 5, 1, 1) |
|
229 | 229 | self.specGraphSaveRTIplot = QtGui.QCheckBox(self.tabgraphSpectra) |
|
230 | 230 | self.specGraphSaveRTIplot.setText(_fromUtf8("")) |
|
231 | 231 | self.specGraphSaveRTIplot.setObjectName(_fromUtf8("specGraphSaveRTIplot")) |
|
232 | 232 | self.gridLayout_9.addWidget(self.specGraphSaveRTIplot, 9, 5, 1, 1) |
|
233 | 233 | self.specGraphSaveCoherencemap = QtGui.QCheckBox(self.tabgraphSpectra) |
|
234 | 234 | self.specGraphSaveCoherencemap.setText(_fromUtf8("")) |
|
235 | 235 | self.specGraphSaveCoherencemap.setObjectName(_fromUtf8("specGraphSaveCoherencemap")) |
|
236 | 236 | self.gridLayout_9.addWidget(self.specGraphSaveCoherencemap, 10, 5, 1, 1) |
|
237 | 237 | self.specGraphSavePowerprofile = QtGui.QCheckBox(self.tabgraphSpectra) |
|
238 | 238 | self.specGraphSavePowerprofile.setText(_fromUtf8("")) |
|
239 | 239 | self.specGraphSavePowerprofile.setObjectName(_fromUtf8("specGraphSavePowerprofile")) |
|
240 | 240 | self.gridLayout_9.addWidget(self.specGraphSavePowerprofile, 11, 5, 1, 1) |
|
241 | 241 | self.specGraphSaveRTInoise = QtGui.QCheckBox(self.tabgraphSpectra) |
|
242 | 242 | self.specGraphSaveRTInoise.setText(_fromUtf8("")) |
|
243 | 243 | self.specGraphSaveRTInoise.setObjectName(_fromUtf8("specGraphSaveRTInoise")) |
|
244 | 244 | self.gridLayout_9.addWidget(self.specGraphSaveRTInoise, 13, 5, 1, 1) |
|
245 | 245 | |
|
246 | 246 | self.label_19 = QtGui.QLabel(self.tabgraphSpectra) |
|
247 | 247 | self.label_19.setObjectName(_fromUtf8("label_19")) |
|
248 | 248 | self.gridLayout_9.addWidget(self.label_19, 3, 7, 2, 1) |
|
249 | 249 | self.specGraphftpSpectra = QtGui.QCheckBox(self.tabgraphSpectra) |
|
250 | 250 | self.specGraphftpSpectra.setText(_fromUtf8("")) |
|
251 | 251 | self.specGraphftpSpectra.setObjectName(_fromUtf8("specGraphftpSpectra")) |
|
252 | 252 | self.gridLayout_9.addWidget(self.specGraphftpSpectra, 6, 7, 1, 1) |
|
253 | 253 | self.specGraphftpCross = QtGui.QCheckBox(self.tabgraphSpectra) |
|
254 | 254 | self.specGraphftpCross.setText(_fromUtf8("")) |
|
255 | 255 | self.specGraphftpCross.setObjectName(_fromUtf8("specGraphftpCross")) |
|
256 | 256 | self.gridLayout_9.addWidget(self.specGraphftpCross, 8, 7, 1, 1) |
|
257 | 257 | self.specGraphftpRTIplot = QtGui.QCheckBox(self.tabgraphSpectra) |
|
258 | 258 | self.specGraphftpRTIplot.setText(_fromUtf8("")) |
|
259 | 259 | self.specGraphftpRTIplot.setObjectName(_fromUtf8("specGraphftpRTIplot")) |
|
260 | 260 | self.gridLayout_9.addWidget(self.specGraphftpRTIplot, 9, 7, 1, 1) |
|
261 | 261 | self.specGraphftpCoherencemap = QtGui.QCheckBox(self.tabgraphSpectra) |
|
262 | 262 | self.specGraphftpCoherencemap.setText(_fromUtf8("")) |
|
263 | 263 | self.specGraphftpCoherencemap.setObjectName(_fromUtf8("specGraphftpCoherencemap")) |
|
264 | 264 | self.gridLayout_9.addWidget(self.specGraphftpCoherencemap, 10, 7, 1, 1) |
|
265 | 265 | self.specGraphftpPowerprofile = QtGui.QCheckBox(self.tabgraphSpectra) |
|
266 | 266 | self.specGraphftpPowerprofile.setText(_fromUtf8("")) |
|
267 | 267 | self.specGraphftpPowerprofile.setObjectName(_fromUtf8("specGraphftpPowerprofile")) |
|
268 | 268 | self.gridLayout_9.addWidget(self.specGraphftpPowerprofile, 11, 7, 1, 1) |
|
269 | 269 | self.specGraphftpRTInoise = QtGui.QCheckBox(self.tabgraphSpectra) |
|
270 | 270 | self.specGraphftpRTInoise.setText(_fromUtf8("")) |
|
271 | 271 | self.specGraphftpRTInoise.setObjectName(_fromUtf8("specGraphftpRTInoise")) |
|
272 | 272 | self.gridLayout_9.addWidget(self.specGraphftpRTInoise, 13, 7, 1, 1) |
|
273 | 273 | |
|
274 | 274 | spacerItem19 = QtGui.QSpacerItem(39, 15, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
275 | 275 | self.gridLayout_9.addItem(spacerItem19, 27, 4, 1, 1) |
|
276 | 276 | |
|
277 | 277 | self.label_22 = QtGui.QLabel(self.tabgraphSpectra) |
|
278 | 278 | self.label_22.setObjectName(_fromUtf8("label_22")) |
|
279 | 279 | self.gridLayout_9.addWidget(self.label_22, 16, 0, 1, 1) |
|
280 | 280 | self.specGgraphFreq = QtGui.QLineEdit(self.tabgraphSpectra) |
|
281 | 281 | self.specGgraphFreq.setObjectName(_fromUtf8("specGgraphFreq")) |
|
282 | 282 | self.gridLayout_9.addWidget(self.specGgraphFreq, 16, 2, 1, 2) |
|
283 | 283 | |
|
284 | 284 | self.label_16 = QtGui.QLabel(self.tabgraphSpectra) |
|
285 | 285 | self.label_16.setObjectName(_fromUtf8("label_16")) |
|
286 | 286 | self.gridLayout_9.addWidget(self.label_16, 17, 0, 1, 1) |
|
287 | 287 | self.specGgraphHeight = QtGui.QLineEdit(self.tabgraphSpectra) |
|
288 | 288 | self.specGgraphHeight.setObjectName(_fromUtf8("specGgraphHeight")) |
|
289 | 289 | self.gridLayout_9.addWidget(self.specGgraphHeight, 17, 2, 1, 2) |
|
290 | 290 | |
|
291 | 291 | self.label_17 = QtGui.QLabel(self.tabgraphSpectra) |
|
292 | 292 | self.label_17.setObjectName(_fromUtf8("label_17")) |
|
293 | 293 | self.gridLayout_9.addWidget(self.label_17, 18, 0, 1, 1) |
|
294 | 294 | self.specGgraphDbsrange = QtGui.QLineEdit(self.tabgraphSpectra) |
|
295 | 295 | self.specGgraphDbsrange.setObjectName(_fromUtf8("specGgraphDbsrange")) |
|
296 | 296 | self.gridLayout_9.addWidget(self.specGgraphDbsrange, 18, 2, 1, 2) |
|
297 | 297 | |
|
298 | 298 | self.specGraphTminTmaxLabel = QtGui.QLabel(self.tabgraphSpectra) |
|
299 | 299 | self.specGraphTminTmaxLabel.setObjectName(_fromUtf8("specGraphTminTmaxLabel")) |
|
300 | 300 | self.gridLayout_9.addWidget(self.specGraphTminTmaxLabel, 19, 0, 1, 2) |
|
301 | 301 | self.specGgraphTminTmax = QtGui.QLineEdit(self.tabgraphSpectra) |
|
302 | 302 | self.specGgraphTminTmax.setObjectName(_fromUtf8("specGgraphTminTmax")) |
|
303 | 303 | self.gridLayout_9.addWidget(self.specGgraphTminTmax, 19, 2, 1, 2) |
|
304 | 304 | |
|
305 | 305 | self.specGraphMagLabel = QtGui.QLabel(self.tabgraphSpectra) |
|
306 | 306 | self.specGraphMagLabel.setObjectName(_fromUtf8("specGraphMagLabel")) |
|
307 | 307 | self.gridLayout_9.addWidget(self.specGraphMagLabel, 16, 4, 1, 2) |
|
308 | 308 | self.specGgraphmagnitud = QtGui.QLineEdit(self.tabgraphSpectra) |
|
309 | 309 | self.specGgraphmagnitud.setObjectName(_fromUtf8("specGgraphmagnitud")) |
|
310 | 310 | self.gridLayout_9.addWidget(self.specGgraphmagnitud, 16, 6, 1, 2) |
|
311 | 311 | |
|
312 | 312 | self.specGraphPhaseLabel = QtGui.QLabel(self.tabgraphSpectra) |
|
313 | 313 | self.specGraphPhaseLabel.setObjectName(_fromUtf8("specGraphPhaseLabel")) |
|
314 | 314 | self.gridLayout_9.addWidget(self.specGraphPhaseLabel, 17, 4, 1, 2) |
|
315 | 315 | self.specGgraphPhase = QtGui.QLineEdit(self.tabgraphSpectra) |
|
316 | 316 | self.specGgraphPhase.setObjectName(_fromUtf8("specGgraphPhase")) |
|
317 | 317 | self.gridLayout_9.addWidget(self.specGgraphPhase, 17, 6, 1, 2) |
|
318 | 318 | |
|
319 | 319 | self.label_6 = QtGui.QLabel(self.tabgraphSpectra) |
|
320 | 320 | self.label_6.setObjectName(_fromUtf8("label_6")) |
|
321 | 321 | self.gridLayout_9.addWidget(self.label_6, 18, 4, 1, 1) |
|
322 | 322 | self.specGgraphChannelList = QtGui.QLineEdit(self.tabgraphSpectra) |
|
323 | 323 | self.specGgraphChannelList.setObjectName(_fromUtf8("specGgraphChannelList")) |
|
324 | 324 | self.gridLayout_9.addWidget(self.specGgraphChannelList, 18, 6, 1, 2) |
|
325 | 325 | |
|
326 | 326 | self.label_29 = QtGui.QLabel(self.tabgraphSpectra) |
|
327 | 327 | self.label_29.setObjectName(_fromUtf8("label_29")) |
|
328 | 328 | self.gridLayout_9.addWidget(self.label_29, 19, 4, 1, 2) |
|
329 | 329 | self.specGgraphftpratio = QtGui.QLineEdit(self.tabgraphSpectra) |
|
330 | 330 | self.specGgraphftpratio.setObjectName(_fromUtf8("specGgraphftpratio")) |
|
331 | 331 | self.gridLayout_9.addWidget(self.specGgraphftpratio, 19, 6, 1, 2) |
|
332 | 332 | |
|
333 | 333 | self.label_48 = QtGui.QLabel(self.tabgraphSpectra) |
|
334 | 334 | self.label_48.setObjectName(_fromUtf8("label_48")) |
|
335 | 335 | self.gridLayout_9.addWidget(self.label_48, 20, 4, 1, 2) |
|
336 | 336 | self.specGgraphTimeRange = QtGui.QLineEdit(self.tabgraphSpectra) |
|
337 | 337 | self.specGgraphTimeRange.setObjectName(_fromUtf8("specGgraphTimeRange")) |
|
338 | 338 | self.gridLayout_9.addWidget(self.specGgraphTimeRange, 20, 6, 1, 2) |
|
339 | 339 | |
|
340 | 340 | spacerItem15 = QtGui.QSpacerItem(28, 15, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
341 | 341 | self.gridLayout_9.addItem(spacerItem15, 27, 6, 1, 2) |
|
342 | 342 | spacerItem16 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) |
|
343 | 343 | self.gridLayout_9.addItem(spacerItem16, 3, 5, 1, 1) |
|
344 | 344 | spacerItem17 = QtGui.QSpacerItem(49, 15, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
345 | 345 | self.gridLayout_9.addItem(spacerItem17, 27, 0, 1, 1) |
|
346 | 346 | |
|
347 | 347 | |
|
348 | 348 | |
|
349 | 349 | self.tabWidgetSpectra.addTab(self.tabgraphSpectra, _fromUtf8("")) |
|
350 | 350 | self.taboutputSpectra = QtGui.QWidget() |
|
351 | 351 | self.taboutputSpectra.setObjectName(_fromUtf8("taboutputSpectra")) |
|
352 | 352 | self.gridLayout_11 = QtGui.QGridLayout(self.taboutputSpectra) |
|
353 | 353 | self.gridLayout_11.setObjectName(_fromUtf8("gridLayout_11")) |
|
354 | 354 | self.label_39 = QtGui.QLabel(self.taboutputSpectra) |
|
355 | 355 | self.label_39.setObjectName(_fromUtf8("label_39")) |
|
356 | 356 | self.gridLayout_11.addWidget(self.label_39, 0, 0, 1, 1) |
|
357 | 357 | self.specOutputComData = QtGui.QComboBox(self.taboutputSpectra) |
|
358 | 358 | self.specOutputComData.setObjectName(_fromUtf8("specOutputComData")) |
|
359 | 359 | self.specOutputComData.addItem(_fromUtf8("")) |
|
360 | 360 | self.gridLayout_11.addWidget(self.specOutputComData, 0, 2, 1, 2) |
|
361 | 361 | self.label_34 = QtGui.QLabel(self.taboutputSpectra) |
|
362 | 362 | self.label_34.setObjectName(_fromUtf8("label_34")) |
|
363 | 363 | self.gridLayout_11.addWidget(self.label_34, 1, 0, 1, 1) |
|
364 | 364 | self.specOutputPath = QtGui.QLineEdit(self.taboutputSpectra) |
|
365 | 365 | self.specOutputPath.setObjectName(_fromUtf8("specOutputPath")) |
|
366 | 366 | self.gridLayout_11.addWidget(self.specOutputPath, 1, 2, 1, 1) |
|
367 | 367 | spacerItem20 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) |
|
368 | 368 | self.gridLayout_11.addItem(spacerItem20, 4, 2, 1, 1) |
|
369 | 369 | self.specOutputToolPath = QtGui.QToolButton(self.taboutputSpectra) |
|
370 | 370 | self.specOutputToolPath.setObjectName(_fromUtf8("specOutputToolPath")) |
|
371 | 371 | self.gridLayout_11.addWidget(self.specOutputToolPath, 1, 3, 1, 1) |
|
372 | 372 | self.specOutputblocksperfile = QtGui.QLineEdit(self.taboutputSpectra) |
|
373 | 373 | self.specOutputblocksperfile.setObjectName(_fromUtf8("specOutputblocksperfile")) |
|
374 | 374 | self.gridLayout_11.addWidget(self.specOutputblocksperfile, 2, 2, 1, 1) |
|
375 | 375 | self.label_9 = QtGui.QLabel(self.taboutputSpectra) |
|
376 | 376 | self.label_9.setObjectName(_fromUtf8("label_9")) |
|
377 | 377 | self.gridLayout_11.addWidget(self.label_9, 2, 0, 1, 2) |
|
378 | 378 | self.label_38 = QtGui.QLabel(self.taboutputSpectra) |
|
379 | 379 | self.label_38.setObjectName(_fromUtf8("label_38")) |
|
380 | 380 | self.gridLayout_11.addWidget(self.label_38, 3, 0, 1, 1) |
|
381 | 381 | self.specOutputprofileperblock = QtGui.QLineEdit(self.taboutputSpectra) |
|
382 | 382 | self.specOutputprofileperblock.setObjectName(_fromUtf8("specOutputprofileperblock")) |
|
383 | 383 | self.gridLayout_11.addWidget(self.specOutputprofileperblock, 3, 2, 1, 1) |
|
384 | 384 | self.tabWidgetSpectra.addTab(self.taboutputSpectra, _fromUtf8("")) |
|
385 | 385 | self.gridLayout_7.addWidget(self.tabWidgetSpectra, 0, 1, 1, 1) |
|
386 | 386 | |
|
387 | 387 | self.tabWidgetProject.addTab(self.tabSpectra, _fromUtf8("")) |
|
388 | 388 | |
|
389 | 389 | self.tabWidgetSpectra.setCurrentIndex(0) |
|
390 | 390 | |
|
391 | 391 | def retranslateUi(self): |
|
392 | 392 | |
|
393 | 393 | self.specOpOk.setText(_translate("MainWindow", "Ok", None)) |
|
394 | 394 | self.specGraphClear.setText(_translate("MainWindow", "Clear", None)) |
|
395 | 395 | self.specOpCebCrossSpectra.setText(_translate("MainWindow", "Select Cross Spectra", None)) |
|
396 | 396 | self.specOpComChannel.setItemText(0, _translate("MainWindow", "Value", None)) |
|
397 | 397 | self.specOpComChannel.setItemText(1, _translate("MainWindow", "Index", None)) |
|
398 | 398 | self.specOpComHeights.setItemText(0, _translate("MainWindow", "Value", None)) |
|
399 | 399 | self.specOpComHeights.setItemText(1, _translate("MainWindow", "Index", None)) |
|
400 | 400 | self.specOpCebRemoveDC.setText(_translate("MainWindow", "Remove DC", None)) |
|
401 | 401 | self.specOpCebHeights.setText(_translate("MainWindow", "Select Heights", None)) |
|
402 | 402 | self.specOpCebChannel.setText(_translate("MainWindow", "Select Channel", None)) |
|
403 | 403 | self.label_31.setText(_translate("MainWindow", "x-y pairs", None)) |
|
404 | 404 | self.label_26.setText(_translate("MainWindow", "nFFTPoints", None)) |
|
405 | 405 | self.specOpCebIncoherent.setText(_translate("MainWindow", "Incoherent Integration", None)) |
|
406 | 406 | self.specOpCobIncInt.setItemText(0, _translate("MainWindow", "Time Interval", None)) |
|
407 | 407 | self.specOpCobIncInt.setItemText(1, _translate("MainWindow", "Profiles", None)) |
|
408 |
self.specOpCebRadarfrequency.setText(_translate("MainWindow", "Radar |
|
|
408 | self.specOpCebRadarfrequency.setText(_translate("MainWindow", "Radar frequency (MHz)", None)) | |
|
409 | 409 | self.label_21.setText(_translate("MainWindow", "Profiles", None)) |
|
410 | 410 | self.specOpCebRemoveInt.setText(_translate("MainWindow", "Remove Interference", None)) |
|
411 | 411 | self.label_70.setText(_translate("MainWindow", "IppFactor", None)) |
|
412 | 412 | self.specOpCebgetNoise.setText(_translate("MainWindow", "Get Noise", None)) |
|
413 | 413 | self.specOpComRemoveDC.setItemText(0, _translate("MainWindow", "Mode 1", None)) |
|
414 | 414 | self.specOpComRemoveDC.setItemText(1, _translate("MainWindow", "Mode 2", None)) |
|
415 | 415 | self.tabWidgetSpectra.setTabText(self.tabWidgetSpectra.indexOf(self.tabopSpectra), _translate("MainWindow", "Operation", None)) |
|
416 | 416 | |
|
417 | 417 | self.label_44.setText(_translate("MainWindow", "Coherence Map", None)) |
|
418 | 418 | self.specGraphTminTmaxLabel.setText(_translate("MainWindow", "Time range:", None)) |
|
419 | 419 | self.label_25.setText(_translate("MainWindow", "Prefix", None)) |
|
420 | 420 | self.label_42.setText(_translate("MainWindow", "RTI Plot", None)) |
|
421 | 421 | self.label_16.setText(_translate("MainWindow", "Height range", None)) |
|
422 | 422 | self.label_17.setText(_translate("MainWindow", "dB range", None)) |
|
423 | 423 | self.specGraphMagLabel.setText(_translate("MainWindow", "Coh. Magnitud ", None)) |
|
424 | 424 | self.label_24.setText(_translate("MainWindow", "Path", None)) |
|
425 | 425 | self.label_46.setText(_translate("MainWindow", "Power Profile", None)) |
|
426 | 426 | self.label_22.setText(_translate("MainWindow", "Freq/Vel range:", None)) |
|
427 | 427 | self.label_41.setText(_translate("MainWindow", "Cross Spectra Plot", None)) |
|
428 | 428 | self.specGraphToolPath.setText(_translate("MainWindow", "...", None)) |
|
429 | 429 | self.label_6.setText(_translate("MainWindow", "Channel List:", None)) |
|
430 | 430 | self.label_40.setText(_translate("MainWindow", "Spectra Plot", None)) |
|
431 | 431 | self.label_43.setText(_translate("MainWindow", "Show", None)) |
|
432 | 432 | self.label_29.setText(_translate("MainWindow", "Writing Period:", None)) |
|
433 | 433 | self.label_47.setText(_translate("MainWindow", "Save", None)) |
|
434 | 434 | self.label_19.setText(_translate("MainWindow", "Ftp", None)) |
|
435 | 435 | self.label_45.setText(_translate("MainWindow", "Noise", None)) |
|
436 | 436 | self.label_48.setText(_translate("MainWindow", "Time Range:", None)) |
|
437 | 437 | self.specGraphPhaseLabel.setText(_translate("MainWindow", "Coh. Phase:", None)) |
|
438 | 438 | self.label_48.hide() |
|
439 | 439 | self.specGgraphTimeRange.hide() |
|
440 | 440 | self.tabWidgetSpectra.setTabText(self.tabWidgetSpectra.indexOf(self.tabgraphSpectra), _translate("MainWindow", "Graphics", None)) |
|
441 | 441 | |
|
442 | 442 | self.label_39.setText(_translate("MainWindow", "Type:", None)) |
|
443 | 443 | self.specOutputComData.setItemText(0, _translate("MainWindow", ".pdata", None)) |
|
444 | 444 | self.label_34.setText(_translate("MainWindow", "Path:", None)) |
|
445 | 445 | self.specOutputToolPath.setText(_translate("MainWindow", "...", None)) |
|
446 | 446 | self.label_9.setText(_translate("MainWindow", "Blocks per File: ", None)) |
|
447 | 447 | self.label_38.setText(_translate("MainWindow", "Profile per Block: ", None)) |
|
448 | 448 | self.tabWidgetSpectra.setTabText(self.tabWidgetSpectra.indexOf(self.taboutputSpectra), _translate("MainWindow", "Output", None)) |
|
449 | 449 | |
|
450 | 450 | self.tabWidgetProject.setTabText(self.tabWidgetProject.indexOf(self.tabSpectra), _translate("MainWindow", "Spectra", None)) |
|
451 | 451 | No newline at end of file |
@@ -1,324 +1,324 | |||
|
1 | 1 | |
|
2 | 2 | from PyQt4 import QtCore, QtGui |
|
3 | 3 | |
|
4 | 4 | try: |
|
5 | 5 | _fromUtf8 = QtCore.QString.fromUtf8 |
|
6 | 6 | except AttributeError: |
|
7 | 7 | def _fromUtf8(s): |
|
8 | 8 | return s |
|
9 | 9 | |
|
10 | 10 | try: |
|
11 | 11 | _encoding = QtGui.QApplication.UnicodeUTF8 |
|
12 | 12 | def _translate(context, text, disambig): |
|
13 | 13 | return QtGui.QApplication.translate(context, text, disambig, _encoding) |
|
14 | 14 | except AttributeError: |
|
15 | 15 | def _translate(context, text, disambig): |
|
16 | 16 | return QtGui.QApplication.translate(context, text, disambig) |
|
17 | 17 | |
|
18 | 18 | class Ui_VoltageTab(object): |
|
19 | 19 | |
|
20 | 20 | def setupUi(self): |
|
21 | 21 | |
|
22 | 22 | self.tabVoltage = QtGui.QWidget() |
|
23 | 23 | self.tabVoltage.setObjectName(_fromUtf8("tabVoltage")) |
|
24 | 24 | |
|
25 | 25 | self.gridLayout_3 = QtGui.QGridLayout(self.tabVoltage) |
|
26 | 26 | self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) |
|
27 | 27 | |
|
28 | 28 | self.frame_4 = QtGui.QFrame(self.tabVoltage) |
|
29 | 29 | self.frame_4.setFrameShape(QtGui.QFrame.StyledPanel) |
|
30 | 30 | self.frame_4.setFrameShadow(QtGui.QFrame.Raised) |
|
31 | 31 | self.frame_4.setObjectName(_fromUtf8("frame_4")) |
|
32 | 32 | |
|
33 | 33 | self.gridLayout_17 = QtGui.QGridLayout(self.frame_4) |
|
34 | 34 | self.gridLayout_17.setObjectName(_fromUtf8("gridLayout_17")) |
|
35 | 35 | self.volOpOk = QtGui.QPushButton(self.frame_4) |
|
36 | 36 | self.volOpOk.setObjectName(_fromUtf8("volOpOk")) |
|
37 | 37 | self.gridLayout_17.addWidget(self.volOpOk, 0, 0, 1, 1) |
|
38 | 38 | self.volGraphClear = QtGui.QPushButton(self.frame_4) |
|
39 | 39 | self.volGraphClear.setObjectName(_fromUtf8("volGraphClear")) |
|
40 | 40 | self.gridLayout_17.addWidget(self.volGraphClear, 0, 1, 1, 1) |
|
41 | 41 | self.gridLayout_3.addWidget(self.frame_4, 1, 1, 1, 1) |
|
42 | 42 | |
|
43 | 43 | |
|
44 | 44 | self.tabWidgetVoltage = QtGui.QTabWidget(self.tabVoltage) |
|
45 | 45 | self.tabWidgetVoltage.setObjectName(_fromUtf8("tabWidgetVoltage")) |
|
46 | 46 | self.tabopVoltage = QtGui.QWidget() |
|
47 | 47 | self.tabopVoltage.setObjectName(_fromUtf8("tabopVoltage")) |
|
48 | 48 | self.gridLayout = QtGui.QGridLayout(self.tabopVoltage) |
|
49 | 49 | self.gridLayout.setObjectName(_fromUtf8("gridLayout")) |
|
50 | 50 | self.volOpHeights = QtGui.QLineEdit(self.tabopVoltage) |
|
51 | 51 | self.volOpHeights.setObjectName(_fromUtf8("volOpHeights")) |
|
52 | 52 | self.gridLayout.addWidget(self.volOpHeights, 4, 4, 1, 1) |
|
53 | 53 | self.volOpComHeights = QtGui.QComboBox(self.tabopVoltage) |
|
54 | 54 | self.volOpComHeights.setObjectName(_fromUtf8("volOpComHeights")) |
|
55 | 55 | self.volOpComHeights.addItem(_fromUtf8("")) |
|
56 | 56 | self.volOpComHeights.addItem(_fromUtf8("")) |
|
57 | 57 | self.gridLayout.addWidget(self.volOpComHeights, 4, 0, 1, 3) |
|
58 | 58 | self.volOpComChannels = QtGui.QComboBox(self.tabopVoltage) |
|
59 | 59 | self.volOpComChannels.setObjectName(_fromUtf8("volOpComChannels")) |
|
60 | 60 | self.volOpComChannels.addItem(_fromUtf8("")) |
|
61 | 61 | self.volOpComChannels.addItem(_fromUtf8("")) |
|
62 | 62 | self.gridLayout.addWidget(self.volOpComChannels, 2, 0, 1, 3) |
|
63 | 63 | self.volOpCebProfile = QtGui.QCheckBox(self.tabopVoltage) |
|
64 | 64 | self.volOpCebProfile.setObjectName(_fromUtf8("volOpCebProfile")) |
|
65 | 65 | self.gridLayout.addWidget(self.volOpCebProfile, 6, 0, 1, 3) |
|
66 | 66 | self.volOpComProfile = QtGui.QComboBox(self.tabopVoltage) |
|
67 | 67 | self.volOpComProfile.setObjectName(_fromUtf8("volOpComProfile")) |
|
68 | 68 | self.volOpComProfile.addItem(_fromUtf8("")) |
|
69 | 69 | self.volOpComProfile.addItem(_fromUtf8("")) |
|
70 | 70 | self.volOpComProfile.addItem(_fromUtf8("")) |
|
71 | 71 | self.gridLayout.addWidget(self.volOpComProfile, 7, 0, 1, 3) |
|
72 | 72 | self.volOpCebDecodification = QtGui.QCheckBox(self.tabopVoltage) |
|
73 | 73 | self.volOpCebDecodification.setObjectName(_fromUtf8("volOpCebDecodification")) |
|
74 | 74 | self.gridLayout.addWidget(self.volOpCebDecodification, 8, 0, 1, 3) |
|
75 | 75 | self.volOpProfile = QtGui.QLineEdit(self.tabopVoltage) |
|
76 | 76 | self.volOpProfile.setObjectName(_fromUtf8("volOpProfile")) |
|
77 | 77 | self.gridLayout.addWidget(self.volOpProfile, 7, 4, 1, 1) |
|
78 | 78 | self.volOpFilter = QtGui.QLineEdit(self.tabopVoltage) |
|
79 | 79 | self.volOpFilter.setObjectName(_fromUtf8("volOpFilter")) |
|
80 | 80 | self.gridLayout.addWidget(self.volOpFilter, 5, 4, 1, 1) |
|
81 | 81 | spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
82 | 82 | self.gridLayout.addItem(spacerItem, 6, 4, 1, 1) |
|
83 | 83 | spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
84 | 84 | self.gridLayout.addItem(spacerItem1, 8, 4, 1, 1) |
|
85 | 85 | spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
86 | 86 | self.gridLayout.addItem(spacerItem2, 3, 4, 1, 1) |
|
87 | 87 | self.volOpChannel = QtGui.QLineEdit(self.tabopVoltage) |
|
88 | 88 | self.volOpChannel.setObjectName(_fromUtf8("volOpChannel")) |
|
89 | 89 | self.gridLayout.addWidget(self.volOpChannel, 2, 4, 1, 1) |
|
90 | 90 | self.volOpCebChannels = QtGui.QCheckBox(self.tabopVoltage) |
|
91 | 91 | self.volOpCebChannels.setObjectName(_fromUtf8("volOpCebChannels")) |
|
92 | 92 | self.gridLayout.addWidget(self.volOpCebChannels, 1, 0, 1, 3) |
|
93 | 93 | self.volOpCebHeights = QtGui.QCheckBox(self.tabopVoltage) |
|
94 | 94 | self.volOpCebHeights.setObjectName(_fromUtf8("volOpCebHeights")) |
|
95 | 95 | self.gridLayout.addWidget(self.volOpCebHeights, 3, 0, 1, 3) |
|
96 | 96 | self.volOpCebFilter = QtGui.QCheckBox(self.tabopVoltage) |
|
97 | 97 | self.volOpCebFilter.setObjectName(_fromUtf8("volOpCebFilter")) |
|
98 | 98 | self.gridLayout.addWidget(self.volOpCebFilter, 5, 0, 1, 3) |
|
99 | 99 | self.volOpRadarfrequency = QtGui.QLineEdit(self.tabopVoltage) |
|
100 | 100 | self.volOpRadarfrequency.setObjectName(_fromUtf8("volOpRadarfrequency")) |
|
101 | 101 | self.gridLayout.addWidget(self.volOpRadarfrequency, 0, 4, 1, 1) |
|
102 | 102 | self.volOpCebRadarfrequency = QtGui.QCheckBox(self.tabopVoltage) |
|
103 | 103 | self.volOpCebRadarfrequency.setObjectName(_fromUtf8("volOpCebRadarfrequency")) |
|
104 | 104 | self.gridLayout.addWidget(self.volOpCebRadarfrequency, 0, 0, 1, 3) |
|
105 | 105 | spacerItem3 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
106 | 106 | self.gridLayout.addItem(spacerItem3, 1, 4, 1, 1) |
|
107 | 107 | self.volOpCebFlip = QtGui.QCheckBox(self.tabopVoltage) |
|
108 | 108 | self.volOpCebFlip.setObjectName(_fromUtf8("volOpCebFlip")) |
|
109 | 109 | self.gridLayout.addWidget(self.volOpCebFlip, 11, 0, 1, 3) |
|
110 | 110 | self.volOpFlip = QtGui.QLineEdit(self.tabopVoltage) |
|
111 | 111 | self.volOpFlip.setObjectName(_fromUtf8("volOpFlip")) |
|
112 | 112 | self.gridLayout.addWidget(self.volOpFlip, 11, 4, 1, 1) |
|
113 | 113 | |
|
114 | 114 | self.volOpCebCohInt = QtGui.QCheckBox(self.tabopVoltage) |
|
115 | 115 | self.volOpCebCohInt.setObjectName(_fromUtf8("volOpCebCohInt")) |
|
116 | 116 | self.gridLayout.addWidget(self.volOpCebCohInt, 12, 0, 1, 3) |
|
117 | 117 | self.volOpCohInt = QtGui.QLineEdit(self.tabopVoltage) |
|
118 | 118 | self.volOpCohInt.setObjectName(_fromUtf8("volOpCohInt")) |
|
119 | 119 | self.gridLayout.addWidget(self.volOpCohInt, 12, 4, 1, 1) |
|
120 | 120 | |
|
121 | 121 | self.volLabCodeMode = QtGui.QLabel(self.tabopVoltage) |
|
122 | 122 | self.volLabCodeMode.setObjectName(_fromUtf8("volLabCodeMode")) |
|
123 | 123 | self.gridLayout.addWidget(self.volLabCodeMode, 8, 2, 1, 1) |
|
124 | 124 | self.volLabCodeType = QtGui.QLabel(self.tabopVoltage) |
|
125 | 125 | self.volLabCodeType.setObjectName(_fromUtf8("volLabCodeType")) |
|
126 | 126 | self.gridLayout.addWidget(self.volLabCodeType, 9, 2, 1, 1) |
|
127 | 127 | self.volLabCode = QtGui.QLabel(self.tabopVoltage) |
|
128 | 128 | self.volLabCode.setObjectName(_fromUtf8("volLabCode")) |
|
129 | 129 | self.gridLayout.addWidget(self.volLabCode, 10, 2, 1, 1) |
|
130 | 130 | self.volOpComMode = QtGui.QComboBox(self.tabopVoltage) |
|
131 | 131 | self.volOpComMode.setObjectName(_fromUtf8("volOpComMode")) |
|
132 | 132 | self.volOpComMode.addItem(_fromUtf8("")) |
|
133 | 133 | self.volOpComMode.addItem(_fromUtf8("")) |
|
134 | 134 | self.gridLayout.addWidget(self.volOpComMode, 8, 4, 1, 1) |
|
135 | 135 | self.volOpComCode = QtGui.QComboBox(self.tabopVoltage) |
|
136 | 136 | self.volOpComCode.setObjectName(_fromUtf8("volOpComCode")) |
|
137 | 137 | self.volOpComCode.addItem(_fromUtf8("")) |
|
138 | 138 | self.volOpComCode.addItem(_fromUtf8("")) |
|
139 | 139 | self.volOpComCode.addItem(_fromUtf8("")) |
|
140 | 140 | self.volOpComCode.addItem(_fromUtf8("")) |
|
141 | 141 | self.volOpComCode.addItem(_fromUtf8("")) |
|
142 | 142 | self.volOpComCode.addItem(_fromUtf8("")) |
|
143 | 143 | self.volOpComCode.addItem(_fromUtf8("")) |
|
144 | 144 | self.volOpComCode.addItem(_fromUtf8("")) |
|
145 | 145 | self.volOpComCode.addItem(_fromUtf8("")) |
|
146 | 146 | self.volOpComCode.addItem(_fromUtf8("")) |
|
147 | 147 | self.volOpComCode.addItem(_fromUtf8("")) |
|
148 | 148 | self.volOpComCode.addItem(_fromUtf8("")) |
|
149 | 149 | self.volOpComCode.addItem(_fromUtf8("")) |
|
150 | 150 | self.volOpComCode.addItem(_fromUtf8("")) |
|
151 | 151 | self.gridLayout.addWidget(self.volOpComCode, 9, 4, 1, 1) |
|
152 | 152 | self.tabWidgetVoltage.addTab(self.tabopVoltage, _fromUtf8("")) |
|
153 | 153 | self.volOpCode = QtGui.QLineEdit(self.tabopVoltage) |
|
154 | 154 | self.volOpCode.setObjectName(_fromUtf8("volOpCode")) |
|
155 | 155 | self.gridLayout.addWidget(self.volOpCode, 10, 4, 1, 1) |
|
156 | 156 | |
|
157 | 157 | self.tabgraphVoltage = QtGui.QWidget() |
|
158 | 158 | self.tabgraphVoltage.setObjectName(_fromUtf8("tabgraphVoltage")) |
|
159 | 159 | self.gridLayout_6 = QtGui.QGridLayout(self.tabgraphVoltage) |
|
160 | 160 | self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6")) |
|
161 | 161 | spacerItem4 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) |
|
162 | 162 | self.gridLayout_6.addItem(spacerItem4, 12, 3, 1, 1) |
|
163 | 163 | self.volGraphfreqrange = QtGui.QLineEdit(self.tabgraphVoltage) |
|
164 | 164 | self.volGraphfreqrange.setObjectName(_fromUtf8("volGraphfreqrange")) |
|
165 | 165 | self.gridLayout_6.addWidget(self.volGraphfreqrange, 9, 1, 1, 6) |
|
166 | 166 | self.volGraphPrefix = QtGui.QLineEdit(self.tabgraphVoltage) |
|
167 | 167 | self.volGraphPrefix.setObjectName(_fromUtf8("volGraphPrefix")) |
|
168 | 168 | self.gridLayout_6.addWidget(self.volGraphPrefix, 2, 1, 1, 6) |
|
169 | 169 | self.volGraphToolPath = QtGui.QToolButton(self.tabgraphVoltage) |
|
170 | 170 | self.volGraphToolPath.setObjectName(_fromUtf8("volGraphToolPath")) |
|
171 | 171 | self.gridLayout_6.addWidget(self.volGraphToolPath, 1, 5, 1, 2) |
|
172 | 172 | self.volGraphPath = QtGui.QLineEdit(self.tabgraphVoltage) |
|
173 | 173 | self.volGraphPath.setObjectName(_fromUtf8("volGraphPath")) |
|
174 | 174 | self.gridLayout_6.addWidget(self.volGraphPath, 1, 1, 1, 4) |
|
175 | 175 | self.label_14 = QtGui.QLabel(self.tabgraphVoltage) |
|
176 | 176 | self.label_14.setObjectName(_fromUtf8("label_14")) |
|
177 | 177 | self.gridLayout_6.addWidget(self.label_14, 6, 0, 1, 1) |
|
178 | 178 | spacerItem5 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) |
|
179 | 179 | self.gridLayout_6.addItem(spacerItem5, 3, 3, 1, 1) |
|
180 | 180 | self.label_8 = QtGui.QLabel(self.tabgraphVoltage) |
|
181 | 181 | self.label_8.setObjectName(_fromUtf8("label_8")) |
|
182 | 182 | self.gridLayout_6.addWidget(self.label_8, 8, 0, 1, 1) |
|
183 | 183 | self.label_49 = QtGui.QLabel(self.tabgraphVoltage) |
|
184 | 184 | self.label_49.setObjectName(_fromUtf8("label_49")) |
|
185 | 185 | self.gridLayout_6.addWidget(self.label_49, 4, 3, 1, 1) |
|
186 | 186 | self.label_51 = QtGui.QLabel(self.tabgraphVoltage) |
|
187 | 187 | self.label_51.setObjectName(_fromUtf8("label_51")) |
|
188 | 188 | self.gridLayout_6.addWidget(self.label_51, 9, 0, 1, 1) |
|
189 | 189 | self.volGraphCebshow = QtGui.QCheckBox(self.tabgraphVoltage) |
|
190 | 190 | self.volGraphCebshow.setText(_fromUtf8("")) |
|
191 | 191 | self.volGraphCebshow.setObjectName(_fromUtf8("volGraphCebshow")) |
|
192 | 192 | self.gridLayout_6.addWidget(self.volGraphCebshow, 6, 3, 1, 1) |
|
193 | 193 | self.label_12 = QtGui.QLabel(self.tabgraphVoltage) |
|
194 | 194 | self.label_12.setObjectName(_fromUtf8("label_12")) |
|
195 | 195 | self.gridLayout_6.addWidget(self.label_12, 1, 0, 1, 1) |
|
196 | 196 | self.label_13 = QtGui.QLabel(self.tabgraphVoltage) |
|
197 | 197 | self.label_13.setObjectName(_fromUtf8("label_13")) |
|
198 | 198 | self.gridLayout_6.addWidget(self.label_13, 2, 0, 1, 1) |
|
199 | 199 | self.label_52 = QtGui.QLabel(self.tabgraphVoltage) |
|
200 | 200 | self.label_52.setObjectName(_fromUtf8("label_52")) |
|
201 | 201 | self.gridLayout_6.addWidget(self.label_52, 11, 0, 1, 1) |
|
202 | 202 | spacerItem6 = QtGui.QSpacerItem(40, 12, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
203 | 203 | self.gridLayout_6.addItem(spacerItem6, 14, 5, 1, 2) |
|
204 | 204 | spacerItem7 = QtGui.QSpacerItem(18, 12, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
205 | 205 | self.gridLayout_6.addItem(spacerItem7, 14, 3, 1, 1) |
|
206 | 206 | self.volGraphChannelList = QtGui.QLineEdit(self.tabgraphVoltage) |
|
207 | 207 | self.volGraphChannelList.setObjectName(_fromUtf8("volGraphChannelList")) |
|
208 | 208 | self.gridLayout_6.addWidget(self.volGraphChannelList, 8, 1, 1, 6) |
|
209 | 209 | self.volGraphHeightrange = QtGui.QLineEdit(self.tabgraphVoltage) |
|
210 | 210 | self.volGraphHeightrange.setObjectName(_fromUtf8("volGraphHeightrange")) |
|
211 | 211 | self.gridLayout_6.addWidget(self.volGraphHeightrange, 11, 1, 1, 6) |
|
212 | 212 | self.label_50 = QtGui.QLabel(self.tabgraphVoltage) |
|
213 | 213 | self.label_50.setObjectName(_fromUtf8("label_50")) |
|
214 | 214 | self.gridLayout_6.addWidget(self.label_50, 4, 4, 1, 1) |
|
215 | 215 | self.volGraphCebSave = QtGui.QCheckBox(self.tabgraphVoltage) |
|
216 | 216 | self.volGraphCebSave.setText(_fromUtf8("")) |
|
217 | 217 | self.volGraphCebSave.setObjectName(_fromUtf8("volGraphCebSave")) |
|
218 | 218 | self.gridLayout_6.addWidget(self.volGraphCebSave, 6, 4, 1, 1) |
|
219 | 219 | self.tabWidgetVoltage.addTab(self.tabgraphVoltage, _fromUtf8("")) |
|
220 | 220 | |
|
221 | 221 | self.taboutputVoltage = QtGui.QWidget() |
|
222 | 222 | self.taboutputVoltage.setObjectName(_fromUtf8("taboutputVoltage")) |
|
223 | 223 | self.gridLayout_12 = QtGui.QGridLayout(self.taboutputVoltage) |
|
224 | 224 | self.gridLayout_12.setObjectName(_fromUtf8("gridLayout_12")) |
|
225 | 225 | self.label_36 = QtGui.QLabel(self.taboutputVoltage) |
|
226 | 226 | self.label_36.setObjectName(_fromUtf8("label_36")) |
|
227 | 227 | self.gridLayout_12.addWidget(self.label_36, 0, 0, 1, 1) |
|
228 | 228 | self.label_37 = QtGui.QLabel(self.taboutputVoltage) |
|
229 | 229 | self.label_37.setObjectName(_fromUtf8("label_37")) |
|
230 | 230 | self.gridLayout_12.addWidget(self.label_37, 1, 0, 1, 1) |
|
231 | 231 | self.volOutputPath = QtGui.QLineEdit(self.taboutputVoltage) |
|
232 | 232 | self.volOutputPath.setObjectName(_fromUtf8("volOutputPath")) |
|
233 | 233 | self.gridLayout_12.addWidget(self.volOutputPath, 1, 2, 1, 1) |
|
234 | 234 | self.volOutputToolPath = QtGui.QToolButton(self.taboutputVoltage) |
|
235 | 235 | self.volOutputToolPath.setObjectName(_fromUtf8("volOutputToolPath")) |
|
236 | 236 | self.gridLayout_12.addWidget(self.volOutputToolPath, 1, 3, 1, 1) |
|
237 | 237 | self.volOutputComData = QtGui.QComboBox(self.taboutputVoltage) |
|
238 | 238 | self.volOutputComData.setObjectName(_fromUtf8("volOutputComData")) |
|
239 | 239 | self.volOutputComData.addItem(_fromUtf8("")) |
|
240 | 240 | self.gridLayout_12.addWidget(self.volOutputComData, 0, 2, 1, 2) |
|
241 | 241 | spacerItem8 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) |
|
242 | 242 | self.gridLayout_12.addItem(spacerItem8, 5, 2, 1, 1) |
|
243 | 243 | self.volOutputblocksperfile = QtGui.QLineEdit(self.taboutputVoltage) |
|
244 | 244 | self.volOutputblocksperfile.setObjectName(_fromUtf8("volOutputblocksperfile")) |
|
245 | 245 | self.gridLayout_12.addWidget(self.volOutputblocksperfile, 3, 2, 1, 1) |
|
246 | 246 | self.label_7 = QtGui.QLabel(self.taboutputVoltage) |
|
247 | 247 | self.label_7.setObjectName(_fromUtf8("label_7")) |
|
248 | 248 | self.gridLayout_12.addWidget(self.label_7, 3, 0, 1, 1) |
|
249 | 249 | self.label_35 = QtGui.QLabel(self.taboutputVoltage) |
|
250 | 250 | self.label_35.setObjectName(_fromUtf8("label_35")) |
|
251 | 251 | self.gridLayout_12.addWidget(self.label_35, 4, 0, 1, 1) |
|
252 | 252 | self.volOutputprofilesperblock = QtGui.QLineEdit(self.taboutputVoltage) |
|
253 | 253 | self.volOutputprofilesperblock.setObjectName(_fromUtf8("volOutputprofilesperblock")) |
|
254 | 254 | self.gridLayout_12.addWidget(self.volOutputprofilesperblock, 4, 2, 1, 1) |
|
255 | 255 | self.tabWidgetVoltage.addTab(self.taboutputVoltage, _fromUtf8("")) |
|
256 | 256 | self.gridLayout_3.addWidget(self.tabWidgetVoltage, 0, 1, 1, 1) |
|
257 | 257 | |
|
258 | 258 | self.tabWidgetProject.addTab(self.tabVoltage, _fromUtf8("")) |
|
259 | 259 | |
|
260 | 260 | self.tabWidgetVoltage.setCurrentIndex(0) |
|
261 | 261 | |
|
262 | 262 | def retranslateUi(self): |
|
263 | 263 | |
|
264 | 264 | self.volOpOk.setText(_translate("MainWindow", "Ok", None)) |
|
265 | 265 | self.volGraphClear.setText(_translate("MainWindow", "Clear", None)) |
|
266 | 266 | self.volOpComHeights.setItemText(0, _translate("MainWindow", "Value", None)) |
|
267 | 267 | self.volOpComHeights.setItemText(1, _translate("MainWindow", "Index", None)) |
|
268 | 268 | self.volOpComChannels.setItemText(0, _translate("MainWindow", "Value", None)) |
|
269 | 269 | self.volOpComChannels.setItemText(1, _translate("MainWindow", "Index", None)) |
|
270 | 270 | self.volOpCebProfile.setText(_translate("MainWindow", "Profile Selector", None)) |
|
271 | 271 | self.volOpComProfile.setItemText(0, _translate("MainWindow", "Profile List", None)) |
|
272 | 272 | self.volOpComProfile.setItemText(1, _translate("MainWindow", "Profile Range", None)) |
|
273 | 273 | self.volOpComProfile.setItemText(2, _translate("MainWindow", "List of Profile Ranges", None)) |
|
274 | 274 | self.volOpCebDecodification.setText(_translate("MainWindow", "Decoder", None)) |
|
275 | 275 | self.volOpCebCohInt.setText(_translate("MainWindow", "Coherent Integration", None)) |
|
276 | 276 | self.volOpCebFlip.setText(_translate("MainWindow", "Flip", None)) |
|
277 | 277 | self.volLabCodeType.setText(_translate("MainWindow", "Code type:", None)) |
|
278 | 278 | self.volOpCebChannels.setText(_translate("MainWindow", "Select Channels", None)) |
|
279 | 279 | self.volOpCebHeights.setText(_translate("MainWindow", "Select Heights", None)) |
|
280 | 280 | self.volOpCebFilter.setText(_translate("MainWindow", "Filter", None)) |
|
281 |
self.volOpCebRadarfrequency.setText(_translate("MainWindow", "Radar |
|
|
281 | self.volOpCebRadarfrequency.setText(_translate("MainWindow", "Radar frequency (MHz)", None)) | |
|
282 | 282 | self.volLabCodeMode.setText(_translate("MainWindow", "Mode:", None)) |
|
283 | 283 | self.volLabCode.setText(_translate("MainWindow", "Code:", None)) |
|
284 | 284 | self.volOpComCode.setItemText(0, _translate("MainWindow", "Read from header", None)) |
|
285 | 285 | self.volOpComCode.setItemText(1, _translate("MainWindow", "Barker 3", None)) |
|
286 | 286 | self.volOpComCode.setItemText(2, _translate("MainWindow", "Barker 4", None)) |
|
287 | 287 | self.volOpComCode.setItemText(3, _translate("MainWindow", "Barker 5", None)) |
|
288 | 288 | self.volOpComCode.setItemText(4, _translate("MainWindow", "Barker 7", None)) |
|
289 | 289 | self.volOpComCode.setItemText(5, _translate("MainWindow", "Barker 11", None)) |
|
290 | 290 | self.volOpComCode.setItemText(6, _translate("MainWindow", "Barker 13", None)) |
|
291 | 291 | self.volOpComCode.setItemText(7, _translate("MainWindow", "Barker 3 + Comp.", None)) |
|
292 | 292 | self.volOpComCode.setItemText(8, _translate("MainWindow", "Barker 4 + Comp.", None)) |
|
293 | 293 | self.volOpComCode.setItemText(9, _translate("MainWindow", "Barker 5 + Comp.", None)) |
|
294 | 294 | self.volOpComCode.setItemText(10, _translate("MainWindow", "Barker 7 + Comp.", None)) |
|
295 | 295 | self.volOpComCode.setItemText(11, _translate("MainWindow", "Barker 11+ Comp.", None)) |
|
296 | 296 | self.volOpComCode.setItemText(12, _translate("MainWindow", "Barker 13+ Comp.", None)) |
|
297 | 297 | self.volOpComCode.setItemText(13, _translate("MainWindow", "User defined", None)) |
|
298 | 298 | self.volOpComMode.setItemText(0, _translate("MainWindow", "Time", None)) |
|
299 | 299 | self.volOpComMode.setItemText(1, _translate("MainWindow", "Frequency", None)) |
|
300 | 300 | self.tabWidgetVoltage.setTabText(self.tabWidgetVoltage.indexOf(self.tabopVoltage), _translate("MainWindow", "Operation", None)) |
|
301 | 301 | |
|
302 | 302 | self.volGraphToolPath.setText(_translate("MainWindow", "...", None)) |
|
303 | 303 | self.label_14.setText(_translate("MainWindow", "Scope", None)) |
|
304 | 304 | self.label_8.setText(_translate("MainWindow", "Channel List", None)) |
|
305 | 305 | self.label_49.setText(_translate("MainWindow", "Show", None)) |
|
306 | 306 | self.label_51.setText(_translate("MainWindow", "Height range", None)) |
|
307 | 307 | self.label_12.setText(_translate("MainWindow", "Path :", None)) |
|
308 | 308 | self.label_13.setText(_translate("MainWindow", "Figure name:", None)) |
|
309 | 309 | self.label_52.setText(_translate("MainWindow", "Amplitude", None)) |
|
310 | 310 | self.label_50.setText(_translate("MainWindow", "Save", None)) |
|
311 | 311 | self.tabWidgetVoltage.setTabText(self.tabWidgetVoltage.indexOf(self.tabgraphVoltage), _translate("MainWindow", "Graphics", None)) |
|
312 | 312 | |
|
313 | 313 | self.label_36.setText(_translate("MainWindow", "Type:", None)) |
|
314 | 314 | self.label_37.setText(_translate("MainWindow", "Path:", None)) |
|
315 | 315 | self.volOutputToolPath.setText(_translate("MainWindow", "...", None)) |
|
316 | 316 | self.volOutputComData.setItemText(0, _translate("MainWindow", ".rawdata", None)) |
|
317 | 317 | self.label_7.setText(_translate("MainWindow", "Blocks per File : ", None)) |
|
318 | 318 | self.label_35.setText(_translate("MainWindow", "Profiles per Block: ", None)) |
|
319 | 319 | self.tabWidgetVoltage.setTabText(self.tabWidgetVoltage.indexOf(self.taboutputVoltage), _translate("MainWindow", "Output", None)) |
|
320 | 320 | |
|
321 | 321 | self.tabWidgetProject.setTabText(self.tabWidgetProject.indexOf(self.tabVoltage), _translate("MainWindow", "Voltage", None)) |
|
322 | 322 | |
|
323 | 323 | |
|
324 | 324 | No newline at end of file |
@@ -1,581 +1,583 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Jul 3, 2014 |
|
3 | 3 | |
|
4 | 4 | @author: roj-idl71 |
|
5 | 5 | ''' |
|
6 | 6 | import datetime |
|
7 | 7 | import numpy |
|
8 | 8 | |
|
9 | 9 | try: |
|
10 | 10 | from gevent import sleep |
|
11 | 11 | except: |
|
12 | 12 | from time import sleep |
|
13 | 13 | |
|
14 | 14 | from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader |
|
15 | 15 | from schainpy.model.data.jrodata import Voltage |
|
16 | 16 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation |
|
17 | 17 | |
|
18 | 18 | try: |
|
19 | 19 | import digital_rf_hdf5 |
|
20 | 20 | except: |
|
21 | 21 | print 'You should install "digital_rf_hdf5" module if you want to read USRP data' |
|
22 | 22 | |
|
23 | 23 | class USRPReader(ProcessingUnit): |
|
24 | 24 | ''' |
|
25 | 25 | classdocs |
|
26 | 26 | ''' |
|
27 | 27 | |
|
28 | 28 | def __init__(self): |
|
29 | 29 | ''' |
|
30 | 30 | Constructor |
|
31 | 31 | ''' |
|
32 | 32 | |
|
33 | 33 | ProcessingUnit.__init__(self) |
|
34 | 34 | |
|
35 | 35 | self.dataOut = Voltage() |
|
36 | 36 | self.__printInfo = True |
|
37 | 37 | self.__flagDiscontinuousBlock = False |
|
38 | 38 | self.__bufferIndex = 9999999 |
|
39 | 39 | |
|
40 | 40 | self.__ippKm = None |
|
41 | 41 | self.__codeType = 0 |
|
42 | 42 | self.__nCode = None |
|
43 | 43 | self.__nBaud = None |
|
44 | 44 | self.__code = None |
|
45 | 45 | |
|
46 | 46 | def __getCurrentSecond(self): |
|
47 | 47 | |
|
48 | 48 | return self.__thisUnixSample/self.__sample_rate |
|
49 | 49 | |
|
50 | 50 | thisSecond = property(__getCurrentSecond, "I'm the 'thisSecond' property.") |
|
51 | 51 | |
|
52 | 52 | def __setFileHeader(self): |
|
53 | 53 | ''' |
|
54 | 54 | In this method will be initialized every parameter of dataOut object (header, no data) |
|
55 | 55 | ''' |
|
56 | 56 | nProfiles = self.__sample_rate #Number of profiles by second |
|
57 | 57 | |
|
58 | 58 | self.dataOut.radarControllerHeaderObj = RadarControllerHeader(ippKm=self.__ippKm, |
|
59 | 59 | txA=0, |
|
60 | 60 | txB=0, |
|
61 | 61 | nWindows=1, |
|
62 | 62 | nHeights=self.__nSamples, |
|
63 | 63 | firstHeight=self.__firstHeigth, |
|
64 | 64 | deltaHeight=self.__deltaHeigth, |
|
65 | 65 | codeType=self.__codeType, |
|
66 | 66 | nCode=self.__nCode, nBaud=self.__nBaud, |
|
67 | 67 | code = self.__code) |
|
68 | 68 | |
|
69 | 69 | self.dataOut.systemHeaderObj = SystemHeader(nSamples=self.__nSamples, |
|
70 | 70 | nProfiles=nProfiles, |
|
71 | 71 | nChannels=len(self.__channelList), |
|
72 | 72 | adcResolution=14) |
|
73 | 73 | |
|
74 | 74 | self.dataOut.type = "Voltage" |
|
75 | 75 | |
|
76 | 76 | self.dataOut.data = None |
|
77 | 77 | |
|
78 | 78 | self.dataOut.dtype = numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
79 | 79 | |
|
80 | 80 | # self.dataOut.nChannels = 0 |
|
81 | 81 | |
|
82 | 82 | # self.dataOut.nHeights = 0 |
|
83 | 83 | |
|
84 | 84 | self.dataOut.nProfiles = nProfiles |
|
85 | 85 | |
|
86 | 86 | self.dataOut.heightList = self.__firstHeigth + numpy.arange(self.__nSamples, dtype = numpy.float)*self.__deltaHeigth |
|
87 | 87 | |
|
88 | 88 | self.dataOut.channelList = self.__channelList |
|
89 | 89 | |
|
90 | 90 | self.dataOut.blocksize = self.dataOut.getNChannels() * self.dataOut.getNHeights() |
|
91 | 91 | |
|
92 | 92 | # self.dataOut.channelIndexList = None |
|
93 | 93 | |
|
94 | 94 | self.dataOut.flagNoData = True |
|
95 | 95 | |
|
96 | 96 | #Set to TRUE if the data is discontinuous |
|
97 | 97 | self.dataOut.flagDiscontinuousBlock = False |
|
98 | 98 | |
|
99 | 99 | self.dataOut.utctime = None |
|
100 | 100 | |
|
101 | 101 | self.dataOut.timeZone = self.__timezone/60 #timezone like jroheader, difference in minutes between UTC and localtime |
|
102 | 102 | |
|
103 | 103 | self.dataOut.dstFlag = 0 |
|
104 | 104 | |
|
105 | 105 | self.dataOut.errorCount = 0 |
|
106 | 106 | |
|
107 | 107 | self.dataOut.nCohInt = 1 |
|
108 | 108 | |
|
109 | 109 | self.dataOut.flagDecodeData = False #asumo que la data esta decodificada |
|
110 | 110 | |
|
111 | 111 | self.dataOut.flagDeflipData = False #asumo que la data esta sin flip |
|
112 | 112 | |
|
113 | 113 | self.dataOut.flagShiftFFT = False |
|
114 | 114 | |
|
115 | 115 | self.dataOut.ippSeconds = 1.0*self.__nSamples/self.__sample_rate |
|
116 | 116 | |
|
117 | 117 | #Time interval between profiles |
|
118 | 118 | #self.dataOut.timeInterval = self.dataOut.ippSeconds * self.dataOut.nCohInt |
|
119 | 119 | |
|
120 | 120 | self.dataOut.frequency = self.__frequency |
|
121 | 121 | |
|
122 | 122 | self.dataOut.realtime = self.__online |
|
123 | 123 | |
|
124 | 124 | def findDatafiles(self, path, startDate=None, endDate=None): |
|
125 | 125 | |
|
126 | 126 | try: |
|
127 | 127 | digitalReadObj = digital_rf_hdf5.read_hdf5(path, load_all_metadata=True) |
|
128 | 128 | except: |
|
129 | 129 | digitalReadObj = digital_rf_hdf5.read_hdf5(path) |
|
130 | 130 | |
|
131 | 131 | channelNameList = digitalReadObj.get_channels() |
|
132 | 132 | |
|
133 | 133 | if not channelNameList: |
|
134 | 134 | return [] |
|
135 | 135 | |
|
136 | 136 | metadata_dict = digitalReadObj.get_rf_file_metadata(channelNameList[0]) |
|
137 | 137 | |
|
138 | 138 | sample_rate = metadata_dict['sample_rate'][0] |
|
139 | 139 | |
|
140 | 140 | this_metadata_file = digitalReadObj.get_metadata(channelNameList[0]) |
|
141 | 141 | |
|
142 | 142 | try: |
|
143 | 143 | timezone = this_metadata_file['timezone'].value |
|
144 | 144 | except: |
|
145 | 145 | timezone = 0 |
|
146 | 146 | |
|
147 | 147 | startUTCSecond, endUTCSecond = digitalReadObj.get_bounds(channelNameList[0])/sample_rate - timezone |
|
148 | 148 | |
|
149 | 149 | startDatetime = datetime.datetime.utcfromtimestamp(startUTCSecond) |
|
150 | 150 | endDatatime = datetime.datetime.utcfromtimestamp(endUTCSecond) |
|
151 | 151 | |
|
152 | 152 | if not startDate: |
|
153 | 153 | startDate = startDatetime.date() |
|
154 | 154 | |
|
155 | 155 | if not endDate: |
|
156 | 156 | endDate = endDatatime.date() |
|
157 | 157 | |
|
158 | 158 | dateList = [] |
|
159 | 159 | |
|
160 | 160 | thisDatetime = startDatetime |
|
161 | 161 | |
|
162 | 162 | while(thisDatetime<=endDatatime): |
|
163 | 163 | |
|
164 | 164 | thisDate = thisDatetime.date() |
|
165 | 165 | |
|
166 | 166 | if thisDate < startDate: |
|
167 | 167 | continue |
|
168 | 168 | |
|
169 | 169 | if thisDate > endDate: |
|
170 | 170 | break |
|
171 | 171 | |
|
172 | 172 | dateList.append(thisDate) |
|
173 | 173 | thisDatetime += datetime.timedelta(1) |
|
174 | 174 | |
|
175 | 175 | return dateList |
|
176 | 176 | |
|
177 | 177 | def setup(self, path = None, |
|
178 | 178 | startDate = None, |
|
179 | 179 | endDate = None, |
|
180 | 180 | startTime = datetime.time(0,0,0), |
|
181 | 181 | endTime = datetime.time(23,59,59), |
|
182 | 182 | channelList = None, |
|
183 | 183 | nSamples = None, |
|
184 | 184 | ippKm = 60, |
|
185 | 185 | online = False, |
|
186 | 186 | delay = 60, |
|
187 | 187 | buffer_size = None, |
|
188 | 188 | nbuffer = 1024, |
|
189 | 189 | **kwargs): |
|
190 | 190 | ''' |
|
191 | 191 | In this method we should set all initial parameters. |
|
192 | 192 | |
|
193 | 193 | Inputs: |
|
194 | 194 | path |
|
195 | 195 | startDate |
|
196 | 196 | endDate |
|
197 | 197 | startTime |
|
198 | 198 | endTime |
|
199 | 199 | set |
|
200 | 200 | expLabel |
|
201 | 201 | ext |
|
202 | 202 | online |
|
203 | 203 | delay |
|
204 | 204 | ''' |
|
205 | 205 | |
|
206 | 206 | if not buffer_size: |
|
207 | 207 | buffer_size = nbuffer |
|
208 | 208 | |
|
209 | 209 | try: |
|
210 | 210 | self.digitalReadObj = digital_rf_hdf5.read_hdf5(path, load_all_metadata=True) |
|
211 | 211 | except: |
|
212 | 212 | self.digitalReadObj = digital_rf_hdf5.read_hdf5(path) |
|
213 | 213 | |
|
214 | 214 | channelNameList = self.digitalReadObj.get_channels() |
|
215 | 215 | |
|
216 | 216 | if not channelNameList: |
|
217 | 217 | raise IOError, "[Reading] The path doesn,t have any files .. " |
|
218 | 218 | |
|
219 | 219 | if not channelList: |
|
220 | 220 | channelList = range(len(channelNameList)) |
|
221 | 221 | |
|
222 | 222 | ########## Reading metadata ###################### |
|
223 | 223 | |
|
224 | 224 | metadata_dict = self.digitalReadObj.get_rf_file_metadata(channelNameList[channelList[0]]) |
|
225 | 225 | |
|
226 | 226 | self.__sample_rate = metadata_dict['sample_rate'][0] |
|
227 | 227 | self.__samples_per_file = metadata_dict['samples_per_file'][0] |
|
228 | 228 | self.__deltaHeigth = 1e6*0.15/self.__sample_rate |
|
229 | 229 | |
|
230 | 230 | this_metadata_file = self.digitalReadObj.get_metadata(channelNameList[channelList[0]]) |
|
231 | 231 | |
|
232 | 232 | self.__frequency = this_metadata_file['center_frequencies'].value |
|
233 | 233 | try: |
|
234 | 234 | self.__timezone = this_metadata_file['timezone'].value |
|
235 | 235 | except: |
|
236 | 236 | self.__timezone = 0 |
|
237 | 237 | |
|
238 | 238 | self.__firstHeigth = 0 |
|
239 | 239 | |
|
240 | 240 | try: |
|
241 | 241 | codeType = this_metadata_file['codeType'].value |
|
242 | 242 | except: |
|
243 | 243 | codeType = 0 |
|
244 | 244 | |
|
245 | 245 | nCode = 0 |
|
246 | 246 | nBaud = 0 |
|
247 | 247 | code = None |
|
248 | 248 | |
|
249 | 249 | if codeType: |
|
250 | 250 | nCode = this_metadata_file['nCode'].value |
|
251 | 251 | nBaud = this_metadata_file['nBaud'].value |
|
252 | 252 | code = this_metadata_file['code'].value |
|
253 | 253 | |
|
254 | 254 | if not ippKm: |
|
255 | 255 | try: |
|
256 | 256 | #seconds to km |
|
257 | 257 | ippKm = 1e6*0.15*this_metadata_file['ipp'].value |
|
258 | 258 | except: |
|
259 | 259 | ippKm = None |
|
260 | 260 | |
|
261 | 261 | #################################################### |
|
262 | 262 | startUTCSecond = None |
|
263 | 263 | endUTCSecond = None |
|
264 | 264 | |
|
265 | 265 | if startDate: |
|
266 | 266 | startDatetime = datetime.datetime.combine(startDate, startTime) |
|
267 | 267 | startUTCSecond = (startDatetime-datetime.datetime(1970,1,1)).total_seconds() + self.__timezone |
|
268 | 268 | |
|
269 | 269 | if endDate: |
|
270 | 270 | endDatetime = datetime.datetime.combine(endDate, endTime) |
|
271 | 271 | endUTCSecond = (endDatetime-datetime.datetime(1970,1,1)).total_seconds() + self.__timezone |
|
272 | 272 | |
|
273 | 273 | start_index, end_index = self.digitalReadObj.get_bounds(channelNameList[channelList[0]]) |
|
274 | 274 | |
|
275 | 275 | if not startUTCSecond: |
|
276 | 276 | startUTCSecond = start_index/self.__sample_rate |
|
277 | 277 | |
|
278 | 278 | if start_index > startUTCSecond*self.__sample_rate: |
|
279 | 279 | startUTCSecond = start_index/self.__sample_rate |
|
280 | 280 | |
|
281 | 281 | if not endUTCSecond: |
|
282 | 282 | endUTCSecond = end_index/self.__sample_rate |
|
283 | 283 | |
|
284 | 284 | if end_index < endUTCSecond*self.__sample_rate: |
|
285 | 285 | endUTCSecond = end_index/self.__sample_rate |
|
286 | 286 | |
|
287 | 287 | if not nSamples: |
|
288 | 288 | if not ippKm: |
|
289 | 289 | raise ValueError, "[Reading] nSamples or ippKm should be defined" |
|
290 | 290 | |
|
291 | 291 | nSamples = ippKm / (1e6*0.15/self.__sample_rate) |
|
292 | 292 | |
|
293 | 293 | channelBoundList = [] |
|
294 | 294 | channelNameListFiltered = [] |
|
295 | 295 | |
|
296 | 296 | for thisIndexChannel in channelList: |
|
297 | 297 | thisChannelName = channelNameList[thisIndexChannel] |
|
298 | 298 | start_index, end_index = self.digitalReadObj.get_bounds(thisChannelName) |
|
299 | 299 | channelBoundList.append((start_index, end_index)) |
|
300 | 300 | channelNameListFiltered.append(thisChannelName) |
|
301 | 301 | |
|
302 | 302 | self.profileIndex = 0 |
|
303 | 303 | |
|
304 | 304 | self.__delay = delay |
|
305 | 305 | self.__ippKm = ippKm |
|
306 | 306 | self.__codeType = codeType |
|
307 | 307 | self.__nCode = nCode |
|
308 | 308 | self.__nBaud = nBaud |
|
309 | 309 | self.__code = code |
|
310 | 310 | |
|
311 | 311 | self.__datapath = path |
|
312 | 312 | self.__online = online |
|
313 | 313 | self.__channelList = channelList |
|
314 | 314 | self.__channelNameList = channelNameListFiltered |
|
315 | 315 | self.__channelBoundList = channelBoundList |
|
316 | 316 | self.__nSamples = nSamples |
|
317 | 317 | self.__samples_to_read = buffer_size*nSamples |
|
318 | 318 | self.__nChannels = len(self.__channelList) |
|
319 | 319 | |
|
320 | 320 | self.__startUTCSecond = startUTCSecond |
|
321 | 321 | self.__endUTCSecond = endUTCSecond |
|
322 | 322 | |
|
323 | 323 | self.__timeInterval = 1.0 * self.__samples_to_read/self.__sample_rate #Time interval |
|
324 | 324 | |
|
325 | 325 | if online: |
|
326 | 326 | # self.__thisUnixSample = int(endUTCSecond*self.__sample_rate - 4*self.__samples_to_read) |
|
327 | 327 | startUTCSecond = numpy.floor(endUTCSecond) |
|
328 | 328 | |
|
329 | 329 | self.__thisUnixSample = int(startUTCSecond*self.__sample_rate) - self.__samples_to_read |
|
330 | 330 | |
|
331 | 331 | self.__data_buffer = numpy.zeros((self.__nChannels, self.__samples_to_read), dtype = numpy.complex) |
|
332 | 332 | |
|
333 | 333 | self.__setFileHeader() |
|
334 | 334 | self.isConfig = True |
|
335 | 335 | |
|
336 | 336 | print "[Reading] USRP Data was found from %s to %s " %( |
|
337 | 337 | datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone), |
|
338 | 338 | datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone) |
|
339 | 339 | ) |
|
340 | 340 | |
|
341 |
print "[Reading] Starting process from " |
|
|
341 | print "[Reading] Starting process from %s to %s" %(datetime.datetime.utcfromtimestamp(startUTCSecond - self.__timezone), | |
|
342 | datetime.datetime.utcfromtimestamp(endUTCSecond - self.__timezone) | |
|
343 | ) | |
|
342 | 344 | |
|
343 | 345 | def __reload(self): |
|
344 | 346 | |
|
345 | 347 | if not self.__online: |
|
346 | 348 | return |
|
347 | 349 | |
|
348 | 350 | |
|
349 | 351 | # print "%s not in range [%s, %s]" %( |
|
350 | 352 | # datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), |
|
351 | 353 | # datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone), |
|
352 | 354 | # datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone) |
|
353 | 355 | # ) |
|
354 | 356 | print "[Reading] reloading metadata ..." |
|
355 | 357 | |
|
356 | 358 | try: |
|
357 | 359 | self.digitalReadObj.reload(complete_update=True) |
|
358 | 360 | except: |
|
359 | 361 | self.digitalReadObj.reload() |
|
360 | 362 | |
|
361 | 363 | start_index, end_index = self.digitalReadObj.get_bounds(self.__channelNameList[self.__channelList[0]]) |
|
362 | 364 | |
|
363 | 365 | if start_index > self.__startUTCSecond*self.__sample_rate: |
|
364 | 366 | self.__startUTCSecond = 1.0*start_index/self.__sample_rate |
|
365 | 367 | |
|
366 | 368 | if end_index > self.__endUTCSecond*self.__sample_rate: |
|
367 | 369 | self.__endUTCSecond = 1.0*end_index/self.__sample_rate |
|
368 | 370 | |
|
369 | 371 | print "[Reading] New timerange found [%s, %s] " %( |
|
370 | 372 | datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone), |
|
371 | 373 | datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone) |
|
372 | 374 | ) |
|
373 | 375 | |
|
374 | 376 | return True |
|
375 | 377 | |
|
376 | 378 | return False |
|
377 | 379 | |
|
378 | 380 | def __readNextBlock(self, seconds=30, volt_scale = 218776): |
|
379 | 381 | ''' |
|
380 | 382 | ''' |
|
381 | 383 | |
|
382 | 384 | #Set the next data |
|
383 | 385 | self.__flagDiscontinuousBlock = False |
|
384 | 386 | self.__thisUnixSample += self.__samples_to_read |
|
385 | 387 | |
|
386 | 388 | if self.__thisUnixSample + 2*self.__samples_to_read > self.__endUTCSecond*self.__sample_rate: |
|
387 | 389 | print "[Reading] There are no more data into selected timerange" |
|
388 | 390 | |
|
389 | 391 | self.__reload() |
|
390 | 392 | |
|
391 | 393 | if self.__thisUnixSample + 2*self.__samples_to_read > self.__endUTCSecond*self.__sample_rate: |
|
392 | 394 | self.__thisUnixSample -= self.__samples_to_read |
|
393 | 395 | return False |
|
394 | 396 | |
|
395 | 397 | indexChannel = 0 |
|
396 | 398 | |
|
397 | 399 | dataOk = False |
|
398 | 400 | |
|
399 | 401 | for thisChannelName in self.__channelNameList: |
|
400 | 402 | |
|
401 | 403 | try: |
|
402 | 404 | result = self.digitalReadObj.read_vector_c81d(self.__thisUnixSample, |
|
403 | 405 | self.__samples_to_read, |
|
404 | 406 | thisChannelName) |
|
405 | 407 | |
|
406 | 408 | except IOError, e: |
|
407 | 409 | #read next profile |
|
408 | 410 | self.__flagDiscontinuousBlock = True |
|
409 | 411 | print e |
|
410 | 412 | break |
|
411 | 413 | |
|
412 | 414 | if result.shape[0] != self.__samples_to_read: |
|
413 | 415 | self.__flagDiscontinuousBlock = True |
|
414 | 416 | print "[Reading] %s: Too few samples were found, just %d samples" %(datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), |
|
415 | 417 | result.shape[0]) |
|
416 | 418 | break |
|
417 | 419 | |
|
418 | 420 | self.__data_buffer[indexChannel,:] = result*volt_scale |
|
419 | 421 | |
|
420 | 422 | indexChannel += 1 |
|
421 | 423 | |
|
422 | 424 | dataOk = True |
|
423 | 425 | |
|
424 | 426 | self.__utctime = self.__thisUnixSample/self.__sample_rate |
|
425 | 427 | |
|
426 | 428 | if not dataOk: |
|
427 | 429 | return False |
|
428 | 430 | |
|
429 | 431 | print "[Reading] %s: %d samples <> %f sec" %(datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), |
|
430 | 432 | self.__samples_to_read, |
|
431 | 433 | self.__timeInterval) |
|
432 | 434 | |
|
433 | 435 | self.__bufferIndex = 0 |
|
434 | 436 | |
|
435 | 437 | return True |
|
436 | 438 | |
|
437 | 439 | def __isBufferEmpty(self): |
|
438 | 440 | |
|
439 | 441 | if self.__bufferIndex <= self.__samples_to_read - self.__nSamples: |
|
440 | 442 | return False |
|
441 | 443 | |
|
442 | 444 | return True |
|
443 | 445 | |
|
444 | 446 | def getData(self, seconds=30, nTries=5): |
|
445 | 447 | |
|
446 | 448 | ''' |
|
447 | 449 | This method gets the data from files and put the data into the dataOut object |
|
448 | 450 | |
|
449 | 451 | In addition, increase el the buffer counter in one. |
|
450 | 452 | |
|
451 | 453 | Return: |
|
452 | 454 | data : retorna un perfil de voltages (alturas * canales) copiados desde el |
|
453 | 455 | buffer. Si no hay mas archivos a leer retorna None. |
|
454 | 456 | |
|
455 | 457 | Affected: |
|
456 | 458 | self.dataOut |
|
457 | 459 | self.profileIndex |
|
458 | 460 | self.flagDiscontinuousBlock |
|
459 | 461 | self.flagIsNewBlock |
|
460 | 462 | ''' |
|
461 | 463 | |
|
462 | 464 | err_counter = 0 |
|
463 | 465 | self.dataOut.flagNoData = True |
|
464 | 466 | |
|
465 | 467 | if self.__isBufferEmpty(): |
|
466 | 468 | |
|
467 | 469 | self.__flagDiscontinuousBlock = False |
|
468 | 470 | |
|
469 | 471 | while True: |
|
470 | 472 | if self.__readNextBlock(): |
|
471 | 473 | break |
|
472 | 474 | |
|
473 | 475 | if self.__thisUnixSample > self.__endUTCSecond*self.__sample_rate: |
|
474 | 476 | return False |
|
475 | 477 | |
|
476 | 478 | if self.__flagDiscontinuousBlock: |
|
477 | 479 | print '[Reading] discontinuous block found ... continue with the next block' |
|
478 | 480 | continue |
|
479 | 481 | |
|
480 | 482 | if not self.__online: |
|
481 | 483 | return False |
|
482 | 484 | |
|
483 | 485 | err_counter += 1 |
|
484 | 486 | if err_counter > nTries: |
|
485 | 487 | return False |
|
486 | 488 | |
|
487 | 489 | print '[Reading] waiting %d seconds to read a new block' %seconds |
|
488 | 490 | sleep(seconds) |
|
489 | 491 | |
|
490 | 492 | self.dataOut.data = self.__data_buffer[:,self.__bufferIndex:self.__bufferIndex+self.__nSamples] |
|
491 | 493 | self.dataOut.utctime = (self.__thisUnixSample + self.__bufferIndex)/self.__sample_rate |
|
492 | 494 | self.dataOut.flagNoData = False |
|
493 | 495 | self.dataOut.flagDiscontinuousBlock = self.__flagDiscontinuousBlock |
|
494 | 496 | |
|
495 | 497 | self.__bufferIndex += self.__nSamples |
|
496 | 498 | self.profileIndex += 1 |
|
497 | 499 | |
|
498 | 500 | return True |
|
499 | 501 | |
|
500 | 502 | def printInfo(self): |
|
501 | 503 | ''' |
|
502 | 504 | ''' |
|
503 | 505 | if self.__printInfo == False: |
|
504 | 506 | return |
|
505 | 507 | |
|
506 | 508 | # self.systemHeaderObj.printInfo() |
|
507 | 509 | # self.radarControllerHeaderObj.printInfo() |
|
508 | 510 | |
|
509 | 511 | self.__printInfo = False |
|
510 | 512 | |
|
511 | 513 | def printNumberOfBlock(self): |
|
512 | 514 | ''' |
|
513 | 515 | ''' |
|
514 | 516 | |
|
515 | 517 | print self.profileIndex |
|
516 | 518 | |
|
517 | 519 | def run(self, **kwargs): |
|
518 | 520 | ''' |
|
519 | 521 | This method will be called many times so here you should put all your code |
|
520 | 522 | ''' |
|
521 | 523 | |
|
522 | 524 | if not self.isConfig: |
|
523 | 525 | self.setup(**kwargs) |
|
524 | 526 | |
|
525 | 527 | self.getData(seconds=self.__delay) |
|
526 | 528 | |
|
527 | 529 | return |
|
528 | 530 | |
|
529 | 531 | class USRPWriter(Operation): |
|
530 | 532 | ''' |
|
531 | 533 | classdocs |
|
532 | 534 | ''' |
|
533 | 535 | |
|
534 | 536 | def __init__(self): |
|
535 | 537 | ''' |
|
536 | 538 | Constructor |
|
537 | 539 | ''' |
|
538 | 540 | self.dataOut = None |
|
539 | 541 | |
|
540 | 542 | def setup(self, dataIn, path, blocksPerFile, set=0, ext=None): |
|
541 | 543 | ''' |
|
542 | 544 | In this method we should set all initial parameters. |
|
543 | 545 | |
|
544 | 546 | Input: |
|
545 | 547 | dataIn : Input data will also be outputa data |
|
546 | 548 | |
|
547 | 549 | ''' |
|
548 | 550 | self.dataOut = dataIn |
|
549 | 551 | |
|
550 | 552 | |
|
551 | 553 | |
|
552 | 554 | |
|
553 | 555 | |
|
554 | 556 | self.isConfig = True |
|
555 | 557 | |
|
556 | 558 | return |
|
557 | 559 | |
|
558 | 560 | def run(self, dataIn, **kwargs): |
|
559 | 561 | ''' |
|
560 | 562 | This method will be called many times so here you should put all your code |
|
561 | 563 | |
|
562 | 564 | Inputs: |
|
563 | 565 | |
|
564 | 566 | dataIn : object with the data |
|
565 | 567 | |
|
566 | 568 | ''' |
|
567 | 569 | |
|
568 | 570 | if not self.isConfig: |
|
569 | 571 | self.setup(dataIn, **kwargs) |
|
570 | 572 | |
|
571 | 573 | |
|
572 | 574 | if __name__ == '__main__': |
|
573 | 575 | |
|
574 | 576 | readObj = USRPReader() |
|
575 | 577 | |
|
576 | 578 | while True: |
|
577 | 579 | readObj.run(path='/Volumes/DATA/haystack/passive_radar/') |
|
578 | 580 | # readObj.printInfo() |
|
579 | 581 | readObj.printNumberOfBlock() |
|
580 | 582 | |
|
581 | 583 | No newline at end of file |
@@ -1,949 +1,965 | |||
|
1 | 1 | ''' |
|
2 | 2 | @author: Daniel Suarez |
|
3 | 3 | ''' |
|
4 | 4 | import os |
|
5 | 5 | import glob |
|
6 | 6 | import ftplib |
|
7 | 7 | |
|
8 | 8 | try: |
|
9 | 9 | import paramiko |
|
10 | 10 | import scp |
|
11 | 11 | except: |
|
12 | 12 | print "You should install paramiko if you will use SSH protocol to upload files to a server" |
|
13 | 13 | |
|
14 | 14 | import multiprocessing |
|
15 | 15 | |
|
16 | 16 | import time |
|
17 | 17 | import threading |
|
18 | 18 | |
|
19 | 19 | |
|
20 | 20 | try: |
|
21 | 21 | from gevent import sleep |
|
22 | 22 | except: |
|
23 | 23 | from time import sleep |
|
24 | 24 | |
|
25 | 25 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation |
|
26 | 26 | |
|
27 | 27 | class Remote(threading.Thread): |
|
28 | 28 | """ |
|
29 | 29 | Remote is a parent class used to define the behaviour of FTP and SSH class. These clases are |
|
30 | 30 | used to upload or download files remotely. |
|
31 | 31 | |
|
32 | 32 | Non-standard Python modules used: |
|
33 | 33 | None |
|
34 | 34 | |
|
35 | 35 | Written by: |
|
36 | 36 | |
|
37 | 37 | "Miguel Urco":mailto:miguel.urco@jro.igp.gob.pe Jun. 03, 2015 |
|
38 | 38 | |
|
39 | 39 | """ |
|
40 | 40 | |
|
41 | 41 | server = None |
|
42 | 42 | username = None |
|
43 | 43 | password = None |
|
44 | 44 | remotefolder = None |
|
45 | 45 | |
|
46 | 46 | period = 60 |
|
47 | 47 | fileList = [] |
|
48 | 48 | bussy = False |
|
49 | 49 | |
|
50 | 50 | def __init__(self, server, username, password, remotefolder, period=60): |
|
51 | 51 | |
|
52 | 52 | threading.Thread.__init__(self) |
|
53 | 53 | self._stop = threading.Event() |
|
54 | 54 | |
|
55 | self.setDaemon(True) | |
|
56 | ||
|
55 | 57 | self.status = 0 |
|
56 | 58 | |
|
57 | 59 | self.period = period |
|
58 | 60 | self.fileList = [] |
|
59 | 61 | self.bussy = False |
|
60 | 62 | |
|
61 | 63 | self.stopFlag = False |
|
62 | 64 | |
|
63 | 65 | print "[Remote Server] Opening server: %s" %server |
|
64 | 66 | if self.open(server, username, password, remotefolder): |
|
65 | 67 | print "[Remote Server] %s server was opened successfully" %server |
|
66 | 68 | |
|
67 | 69 | def stop(self): |
|
68 | 70 | |
|
69 | 71 | self.stopFlag = True |
|
70 | 72 | |
|
71 | 73 | def open(self): |
|
72 | 74 | """ |
|
73 | 75 | Connect to server and create a connection class (FTP or SSH) to remote server. |
|
74 | 76 | """ |
|
75 | 77 | raise NotImplementedError, "Implement this method in child class" |
|
76 | 78 | |
|
77 | 79 | def close(self): |
|
78 | 80 | """ |
|
79 | 81 | Close connection to server |
|
80 | 82 | """ |
|
81 | 83 | raise NotImplementedError, "Implement this method in child class" |
|
82 | 84 | |
|
83 | 85 | def mkdir(self, remotefolder): |
|
84 | 86 | """ |
|
85 | 87 | Create a folder remotely |
|
86 | 88 | """ |
|
87 | 89 | raise NotImplementedError, "Implement this method in child class" |
|
88 | 90 | |
|
89 | 91 | def cd(self, remotefolder): |
|
90 | 92 | """ |
|
91 | 93 | Change working directory in remote server |
|
92 | 94 | """ |
|
93 | 95 | raise NotImplementedError, "Implement this method in child class" |
|
94 | 96 | |
|
95 | 97 | def download(self, filename, localfolder=None): |
|
96 | 98 | """ |
|
97 | 99 | Download a file from server to local host |
|
98 | 100 | """ |
|
99 | 101 | raise NotImplementedError, "Implement this method in child class" |
|
100 | 102 | |
|
101 | 103 | def sendFile(self, fullfilename): |
|
102 | 104 | """ |
|
103 | 105 | sendFile method is used to upload a local file to the current directory in remote server |
|
104 | 106 | |
|
105 | 107 | Inputs: |
|
106 | 108 | fullfilename - full path name of local file to store in remote directory |
|
107 | 109 | |
|
108 | 110 | Returns: |
|
109 | 111 | 0 in error case else 1 |
|
110 | 112 | """ |
|
111 | 113 | raise NotImplementedError, "Implement this method in child class" |
|
112 | 114 | |
|
113 | 115 | def upload(self, fullfilename, remotefolder=None): |
|
114 | 116 | """ |
|
115 | 117 | upload method is used to upload a local file to remote directory. This method changes |
|
116 | 118 | working directory before sending a file. |
|
117 | 119 | |
|
118 | 120 | Inputs: |
|
119 | 121 | fullfilename - full path name of local file to store in remote directory |
|
120 | 122 | |
|
121 | 123 | remotefolder - remote directory |
|
122 | 124 | |
|
123 | 125 | Returns: |
|
124 | 126 | 0 in error case else 1 |
|
125 | 127 | """ |
|
126 | 128 | print "[Remote Server] Uploading %s to %s:%s" %(fullfilename, self.server, self.remotefolder) |
|
127 | 129 | |
|
128 | 130 | if not self.status: |
|
129 | 131 | return 0 |
|
130 | 132 | |
|
131 | 133 | if remotefolder == None: |
|
132 | 134 | remotefolder = self.remotefolder |
|
133 | 135 | |
|
134 | 136 | if not self.cd(remotefolder): |
|
135 | 137 | return 0 |
|
136 | 138 | |
|
137 | 139 | if not self.sendFile(fullfilename): |
|
138 | 140 | print "[Remote Server] Error uploading file %s" %fullfilename |
|
139 | 141 | return 0 |
|
140 | 142 | |
|
141 | 143 | print "[Remote Server] upload finished successfully" |
|
142 | 144 | |
|
143 | 145 | return 1 |
|
144 | 146 | |
|
145 | 147 | def delete(self, filename): |
|
146 | 148 | """ |
|
147 | 149 | Remove a file from remote server |
|
148 | 150 | """ |
|
149 | 151 | pass |
|
150 | 152 | |
|
151 | 153 | def updateFileList(self, fileList): |
|
152 | 154 | """ |
|
153 | 155 | Remove a file from remote server |
|
154 | 156 | """ |
|
155 | 157 | |
|
156 | 158 | if fileList == self.fileList: |
|
157 |
return |
|
|
159 | return 0 | |
|
158 | 160 | |
|
159 | 161 | init = time.time() |
|
160 | 162 | |
|
161 | 163 | while(self.bussy): |
|
162 | 164 | sleep(0.1) |
|
163 | 165 | if time.time() - init > 2*self.period: |
|
164 | 166 | return 0 |
|
165 | 167 | |
|
166 | 168 | self.fileList = fileList |
|
167 | 169 | |
|
168 | 170 | return 1 |
|
169 | 171 | |
|
170 | 172 | def run(self): |
|
171 | 173 | |
|
172 | 174 | if not self.status: |
|
173 | 175 | print "Finishing FTP service" |
|
174 | 176 | return |
|
175 | 177 | |
|
176 | 178 | if not self.cd(self.remotefolder): |
|
177 | 179 | raise ValueError, "Could not access to the new remote directory: %s" %self.remotefolder |
|
178 | 180 | |
|
179 | 181 | sts = True |
|
180 | 182 | |
|
181 | 183 | while True: |
|
182 | 184 | |
|
183 | 185 | sleep(self.period) |
|
184 | 186 | |
|
185 | 187 | self.bussy = True |
|
186 | 188 | |
|
187 | 189 | for thisFile in self.fileList: |
|
188 | 190 | sts = self.upload(thisFile, self.remotefolder) |
|
189 | 191 | if not sts: break |
|
190 | 192 | |
|
191 | if not sts: break | |
|
192 | ||
|
193 | 193 | self.bussy = False |
|
194 | 194 | |
|
195 | if not sts: break | |
|
196 | ||
|
195 | 197 | if self.stopFlag: |
|
196 | 198 | break |
|
197 | 199 | |
|
198 | 200 | print "[Remote Server] Thread stopped successfully" |
|
199 | 201 | |
|
200 | 202 | class FTPClient(Remote): |
|
201 | 203 | |
|
202 | 204 | __ftpClientObj = None |
|
203 | 205 | |
|
204 | 206 | def __init__(self, server, username, password, remotefolder, period=60): |
|
205 | 207 | """ |
|
206 | 208 | """ |
|
207 | 209 | Remote.__init__(self, server, username, password, remotefolder, period) |
|
208 | 210 | |
|
209 | 211 | def open(self, server, username, password, remotefolder): |
|
210 | 212 | |
|
211 | 213 | """ |
|
212 | 214 | This method is used to set FTP parameters and establish a connection to remote server |
|
213 | 215 | |
|
214 | 216 | Inputs: |
|
215 | 217 | server - remote server IP Address |
|
216 | 218 | |
|
217 | 219 | username - remote server Username |
|
218 | 220 | |
|
219 | 221 | password - remote server password |
|
220 | 222 | |
|
221 | 223 | remotefolder - remote server current working directory |
|
222 | 224 | |
|
223 | 225 | Return: void |
|
224 | 226 | |
|
225 | 227 | Affects: |
|
226 | 228 | self.status - in case of error or fail connection this parameter is set to 0 else 1 |
|
227 | 229 | |
|
228 | 230 | """ |
|
229 | 231 | |
|
230 | 232 | if server == None: |
|
231 | 233 | raise ValueError, "FTP server should be defined" |
|
232 | 234 | |
|
233 | 235 | if username == None: |
|
234 | 236 | raise ValueError, "FTP username should be defined" |
|
235 | 237 | |
|
236 | 238 | if password == None: |
|
237 | 239 | raise ValueError, "FTP password should be defined" |
|
238 | 240 | |
|
239 | 241 | if remotefolder == None: |
|
240 | 242 | raise ValueError, "FTP remote folder should be defined" |
|
241 | 243 | |
|
242 | 244 | try: |
|
243 | 245 | ftpClientObj = ftplib.FTP(server) |
|
244 | 246 | except ftplib.all_errors: |
|
245 | 247 | print "FTP server connection fail: %s" %server |
|
246 | 248 | self.status = 0 |
|
247 | 249 | return 0 |
|
248 | 250 | |
|
249 | 251 | try: |
|
250 | 252 | ftpClientObj.login(username, password) |
|
251 | 253 | except ftplib.all_errors: |
|
252 | 254 | print "FTP username or password are incorrect" |
|
253 | 255 | self.status = 0 |
|
254 | 256 | return 0 |
|
255 | 257 | |
|
256 | 258 | if remotefolder == None: |
|
257 | 259 | remotefolder = ftpClientObj.pwd() |
|
258 | 260 | else: |
|
259 | 261 | try: |
|
260 | 262 | ftpClientObj.cwd(remotefolder) |
|
261 | 263 | except ftplib.all_errors: |
|
262 | 264 | print "FTP remote folder is invalid: %s" %remotefolder |
|
263 | 265 | remotefolder = ftpClientObj.pwd() |
|
264 | 266 | |
|
265 | 267 | self.server = server |
|
266 | 268 | self.username = username |
|
267 | 269 | self.password = password |
|
268 | 270 | self.remotefolder = remotefolder |
|
269 | 271 | self.__ftpClientObj = ftpClientObj |
|
270 | 272 | self.status = 1 |
|
271 | 273 | |
|
272 | 274 | return 1 |
|
273 | 275 | |
|
274 | 276 | def close(self): |
|
275 | 277 | """ |
|
276 | 278 | Close connection to remote server |
|
277 | 279 | """ |
|
278 | 280 | if not self.status: |
|
279 | 281 | return 0 |
|
280 | 282 | |
|
281 | 283 | self.__ftpClientObj.close() |
|
282 | 284 | |
|
283 | 285 | def mkdir(self, remotefolder): |
|
284 | 286 | """ |
|
285 | 287 | mkdir is used to make a new directory in remote server |
|
286 | 288 | |
|
287 | 289 | Input: |
|
288 | 290 | remotefolder - directory name |
|
289 | 291 | |
|
290 | 292 | Return: |
|
291 | 293 | 0 in error case else 1 |
|
292 | 294 | """ |
|
293 | 295 | if not self.status: |
|
294 | 296 | return 0 |
|
295 | 297 | |
|
296 | 298 | try: |
|
297 | 299 | self.__ftpClientObj.mkd(dirname) |
|
298 | 300 | except ftplib.all_errors: |
|
299 | 301 | print "Error creating remote folder: %s" %remotefolder |
|
300 | 302 | return 0 |
|
301 | 303 | |
|
302 | 304 | return 1 |
|
303 | 305 | |
|
304 | 306 | def cd(self, remotefolder): |
|
305 | 307 | """ |
|
306 | 308 | cd is used to change remote working directory on server |
|
307 | 309 | |
|
308 | 310 | Input: |
|
309 | 311 | remotefolder - current working directory |
|
310 | 312 | |
|
311 | 313 | Affects: |
|
312 | 314 | self.remotefolder |
|
313 | 315 | |
|
314 | 316 | Return: |
|
315 | 317 | 0 in case of error else 1 |
|
316 | 318 | """ |
|
317 | 319 | if not self.status: |
|
318 | 320 | return 0 |
|
319 | 321 | |
|
320 | 322 | if remotefolder == self.remotefolder: |
|
321 | 323 | return 1 |
|
322 | 324 | |
|
323 | 325 | try: |
|
324 | 326 | self.__ftpClientObj.cwd(remotefolder) |
|
325 | 327 | except ftplib.all_errors: |
|
326 | 328 | print 'Error changing to %s' %remotefolder |
|
327 | 329 | print 'Trying to create remote folder' |
|
328 | 330 | |
|
329 | 331 | if not self.mkdir(remotefolder): |
|
330 | 332 | print 'Remote folder could not be created' |
|
331 | 333 | return 0 |
|
332 | 334 | |
|
333 | 335 | try: |
|
334 | 336 | self.__ftpClientObj.cwd(remotefolder) |
|
335 | 337 | except ftplib.all_errors: |
|
336 | 338 | return 0 |
|
337 | 339 | |
|
338 | 340 | self.remotefolder = remotefolder |
|
339 | 341 | |
|
340 | 342 | return 1 |
|
341 | 343 | |
|
342 | 344 | def sendFile(self, fullfilename): |
|
343 | 345 | |
|
344 | 346 | if not self.status: |
|
345 | 347 | return 0 |
|
346 | 348 | |
|
347 | 349 | file = open(fullfilename, 'rb') |
|
348 | 350 | |
|
349 |
filename = os.path. |
|
|
351 | filename = os.path.basename(fullfilename) | |
|
350 | 352 | |
|
351 | 353 | command = "STOR %s" %filename |
|
352 | 354 | |
|
353 | 355 | try: |
|
354 | 356 | self.__ftpClientObj.storbinary(command, file) |
|
355 | 357 | except ftplib.all_errors: |
|
356 | 358 | return 0 |
|
357 | 359 | |
|
358 | 360 | try: |
|
359 | 361 | self.__ftpClientObj.sendcmd('SITE CHMOD 755 ' + filename) |
|
360 | 362 | except ftplib.all_errors, e: |
|
361 | 363 | print e |
|
362 | 364 | |
|
363 | 365 | file.close() |
|
364 | 366 | |
|
365 | 367 | return 1 |
|
366 | 368 | |
|
367 | 369 | class SSHClient(Remote): |
|
368 | 370 | |
|
369 | 371 | __sshClientObj = None |
|
370 | 372 | __scpClientObj = None |
|
371 | 373 | |
|
372 | 374 | def __init__(self, server, username, password, remotefolder, period=60): |
|
373 | 375 | """ |
|
374 | 376 | """ |
|
375 | 377 | Remote.__init__(self, server, username, password, remotefolder, period) |
|
376 | 378 | |
|
377 | 379 | def open(self, server, username, password, remotefolder, port=22): |
|
378 | 380 | |
|
379 | 381 | """ |
|
380 | 382 | This method is used to set SSH parameters and establish a connection to a remote server |
|
381 | 383 | |
|
382 | 384 | Inputs: |
|
383 | 385 | server - remote server IP Address |
|
384 | 386 | |
|
385 | 387 | username - remote server Username |
|
386 | 388 | |
|
387 | 389 | password - remote server password |
|
388 | 390 | |
|
389 | 391 | remotefolder - remote server current working directory |
|
390 | 392 | |
|
391 | 393 | Return: void |
|
392 | 394 | |
|
393 | 395 | Affects: |
|
394 | 396 | self.status - in case of error or fail connection this parameter is set to 0 else 1 |
|
395 | 397 | |
|
396 | 398 | """ |
|
397 | 399 | |
|
398 | 400 | if server == None: |
|
399 | 401 | raise ValueError, "SSH server should be defined" |
|
400 | 402 | |
|
401 | 403 | if username == None: |
|
402 | 404 | raise ValueError, "SSH username should be defined" |
|
403 | 405 | |
|
404 | 406 | if password == None: |
|
405 | 407 | raise ValueError, "SSH password should be defined" |
|
406 | 408 | |
|
407 | 409 | if remotefolder == None: |
|
408 | 410 | raise ValueError, "SSH remote folder should be defined" |
|
409 | 411 | |
|
410 | 412 | try: |
|
411 | 413 | sshClientObj = paramiko.SSHClient() |
|
412 | 414 | except: |
|
413 | 415 | print "SSH server connection fail: %s" %server |
|
414 | 416 | self.status = 0 |
|
415 | 417 | return 0 |
|
416 | 418 | |
|
417 | 419 | sshClientObj.load_system_host_keys() |
|
418 | 420 | sshClientObj.set_missing_host_key_policy(paramiko.WarningPolicy()) |
|
419 | 421 | |
|
420 | 422 | try: |
|
421 | 423 | sshClientObj.connect(server, username=username, password=password, port=port) |
|
422 | 424 | except : |
|
423 | 425 | print "SSH username or password are incorrect: %s" |
|
424 | 426 | self.status = 0 |
|
425 | 427 | return 0 |
|
426 | 428 | |
|
427 | 429 | scpClientObj = scp.SCPClient(sshClientObj.get_transport(), socket_timeout=30) |
|
428 | 430 | |
|
429 | 431 | if remotefolder == None: |
|
430 | 432 | remotefolder = self.pwd() |
|
431 | 433 | |
|
432 | 434 | self.server = server |
|
433 | 435 | self.username = username |
|
434 | 436 | self.password = password |
|
435 | 437 | self.__sshClientObj = sshClientObj |
|
436 | 438 | self.__scpClientObj = scpClientObj |
|
437 | 439 | self.status = 1 |
|
438 | 440 | |
|
439 | 441 | if not self.cd(remotefolder): |
|
440 | 442 | raise ValueError, "Could not access to remote folder: %s" %remotefolder |
|
441 | 443 | return 0 |
|
442 | 444 | |
|
443 | 445 | self.remotefolder = remotefolder |
|
444 | 446 | |
|
445 | 447 | return 1 |
|
446 | 448 | |
|
447 | 449 | def close(self): |
|
448 | 450 | """ |
|
449 | 451 | Close connection to remote server |
|
450 | 452 | """ |
|
451 | 453 | if not self.status: |
|
452 | 454 | return 0 |
|
453 | 455 | |
|
454 | 456 | self.__sshObj.close() |
|
455 | 457 | |
|
456 | 458 | def __execute(self, command): |
|
457 | 459 | """ |
|
458 | 460 | __execute a command on remote server |
|
459 | 461 | |
|
460 | 462 | Input: |
|
461 | 463 | command - Exmaple 'ls -l' |
|
462 | 464 | |
|
463 | 465 | Return: |
|
464 | 466 | 0 in error case else 1 |
|
465 | 467 | """ |
|
466 | 468 | if not self.status: |
|
467 | 469 | return 0 |
|
468 | 470 | |
|
469 | 471 | stdin, stdout, stderr = self.__sshClientObj.exec_command(command) |
|
470 | 472 | |
|
471 | 473 | result = stderr.readlines() |
|
472 | 474 | if len(result) > 1: |
|
473 | 475 | return 0 |
|
474 | 476 | |
|
475 | 477 | result = stdout.readlines() |
|
476 | 478 | if len(result) > 1: |
|
477 | 479 | return result[0][:-1] |
|
478 | 480 | |
|
479 | 481 | return 1 |
|
480 | 482 | |
|
481 | 483 | def mkdir(self, remotefolder): |
|
482 | 484 | """ |
|
483 | 485 | mkdir is used to make a new directory in remote server |
|
484 | 486 | |
|
485 | 487 | Input: |
|
486 | 488 | remotefolder - directory name |
|
487 | 489 | |
|
488 | 490 | Return: |
|
489 | 491 | 0 in error case else 1 |
|
490 | 492 | """ |
|
491 | 493 | |
|
492 | 494 | command = 'mkdir %s' %remotefolder |
|
493 | 495 | |
|
494 | 496 | return self.__execute(command) |
|
495 | 497 | |
|
496 | 498 | def pwd(self): |
|
497 | 499 | |
|
498 | 500 | command = 'pwd' |
|
499 | 501 | |
|
500 | 502 | return self.__execute(command) |
|
501 | 503 | |
|
502 | 504 | def cd(self, remotefolder): |
|
503 | 505 | """ |
|
504 | 506 | cd is used to change remote working directory on server |
|
505 | 507 | |
|
506 | 508 | Input: |
|
507 | 509 | remotefolder - current working directory |
|
508 | 510 | |
|
509 | 511 | Affects: |
|
510 | 512 | self.remotefolder |
|
511 | 513 | |
|
512 | 514 | Return: |
|
513 | 515 | 0 in case of error else 1 |
|
514 | 516 | """ |
|
515 | 517 | if not self.status: |
|
516 | 518 | return 0 |
|
517 | 519 | |
|
518 | 520 | if remotefolder == self.remotefolder: |
|
519 | 521 | return 1 |
|
520 | 522 | |
|
521 | 523 | chk_command = "cd %s; pwd" %remotefolder |
|
522 | 524 | mkdir_command = "mkdir %s" %remotefolder |
|
523 | 525 | |
|
524 | 526 | if not self.__execute(chk_command): |
|
525 | 527 | if not self.__execute(mkdir_command): |
|
526 | 528 | self.remotefolder = None |
|
527 | 529 | return 0 |
|
528 | 530 | |
|
529 | 531 | self.remotefolder = remotefolder |
|
530 | 532 | |
|
531 | 533 | return 1 |
|
532 | 534 | |
|
533 | 535 | def sendFile(self, fullfilename): |
|
534 | 536 | |
|
535 | 537 | if not self.status: |
|
536 | 538 | return 0 |
|
537 | 539 | |
|
538 | 540 | try: |
|
539 | 541 | self.__scpClientObj.put(fullfilename, remote_path=self.remotefolder) |
|
540 | 542 | except: |
|
541 | 543 | return 0 |
|
542 | 544 | |
|
543 | 545 | remotefile = os.path.join(self.remotefolder, os.path.split(fullfilename)[-1]) |
|
544 | 546 | command = 'chmod 775 %s' %remotefile |
|
545 | 547 | |
|
546 | 548 | return self.__execute(command) |
|
547 | 549 | |
|
548 | 550 | class SendToServer(ProcessingUnit): |
|
549 | 551 | |
|
550 | 552 | def __init__(self): |
|
551 | 553 | |
|
552 | 554 | ProcessingUnit.__init__(self) |
|
553 | 555 | |
|
554 | 556 | self.isConfig = False |
|
555 | 557 | self.clientObj = None |
|
556 | 558 | |
|
557 | 559 | def setup(self, server, username, password, remotefolder, localfolder, ext='.png', period=60, protocol='ftp', **kwargs): |
|
558 | 560 | |
|
559 | 561 | self.clientObj = None |
|
560 | 562 | self.localfolder = localfolder |
|
561 | 563 | self.ext = ext |
|
562 | 564 | self.period = period |
|
563 | 565 | |
|
564 | 566 | if str.lower(protocol) == 'ftp': |
|
565 | 567 | self.clientObj = FTPClient(server, username, password, remotefolder, period) |
|
566 | 568 | |
|
567 | 569 | if str.lower(protocol) == 'ssh': |
|
568 | 570 | self.clientObj = SSHClient(server, username, password, remotefolder, period) |
|
569 | 571 | |
|
570 | 572 | if not self.clientObj: |
|
571 | 573 | raise ValueError, "%s has been chosen as remote access protocol but it is not valid" %protocol |
|
572 | 574 | |
|
573 | 575 | self.clientObj.start() |
|
574 | 576 | |
|
575 | 577 | def findFiles(self): |
|
576 | 578 | |
|
577 | filenameList = glob.glob1(self.localfolder, '*%s' %self.ext) | |
|
579 | if not type(self.localfolder) == list: | |
|
580 | folderList = [self.localfolder] | |
|
581 | else: | |
|
582 | folderList = self.localfolder | |
|
578 | 583 | |
|
579 |
|
|
|
580 | return [] | |
|
581 | ||
|
582 | fullfilenameList = [os.path.join(self.localfolder, thisFile) for thisFile in filenameList] | |
|
584 | fullfilenameList = [] | |
|
585 | ||
|
586 | for thisFolder in folderList: | |
|
583 | 587 | |
|
588 | filenameList = glob.glob1(thisFolder, '*%s' %self.ext) | |
|
589 | ||
|
590 | if len(filenameList) < 1: | |
|
591 | continue | |
|
592 | ||
|
593 | for thisFile in filenameList: | |
|
594 | fullfilename = os.path.join(thisFolder, thisFile) | |
|
595 | fullfilenameList.append(fullfilename) | |
|
596 | ||
|
584 | 597 | return fullfilenameList |
|
585 | 598 | |
|
586 | 599 | def run(self, **kwargs): |
|
587 | 600 | |
|
588 | 601 | if not self.isConfig: |
|
589 | 602 | self.init = time.time() |
|
590 | 603 | self.setup(**kwargs) |
|
591 | 604 | self.isConfig = True |
|
592 | 605 | |
|
593 | 606 | if time.time() - self.init >= self.period: |
|
594 | 607 | fullfilenameList = self.findFiles() |
|
595 | self.clientObj.updateFileList(fullfilenameList) | |
|
608 | ||
|
609 | if self.clientObj.updateFileList(fullfilenameList): | |
|
610 | print "[Remote Server]: Sending the next files ", str(fullfilenameList) | |
|
611 | ||
|
596 | 612 | self.init = time.time() |
|
597 | 613 | |
|
598 | 614 | def close(self): |
|
599 | 615 | print "[Remote Server] Stopping thread" |
|
600 | 616 | self.clientObj.stop() |
|
601 | 617 | |
|
602 | 618 | |
|
603 | 619 | class FTP(object): |
|
604 | 620 | """ |
|
605 | 621 | Ftp is a public class used to define custom File Transfer Protocol from "ftplib" python module |
|
606 | 622 | |
|
607 | 623 | Non-standard Python modules used: None |
|
608 | 624 | |
|
609 | 625 | Written by "Daniel Suarez":mailto:daniel.suarez@jro.igp.gob.pe Oct. 26, 2010 |
|
610 | 626 | """ |
|
611 | 627 | |
|
612 | 628 | def __init__(self,server = None, username=None, password=None, remotefolder=None): |
|
613 | 629 | """ |
|
614 | 630 | This method is used to setting parameters for FTP and establishing connection to remote server |
|
615 | 631 | |
|
616 | 632 | Inputs: |
|
617 | 633 | server - remote server IP Address |
|
618 | 634 | |
|
619 | 635 | username - remote server Username |
|
620 | 636 | |
|
621 | 637 | password - remote server password |
|
622 | 638 | |
|
623 | 639 | remotefolder - remote server current working directory |
|
624 | 640 | |
|
625 | 641 | Return: void |
|
626 | 642 | |
|
627 | 643 | Affects: |
|
628 | 644 | self.status - in Error Case or Connection Failed this parameter is set to 1 else 0 |
|
629 | 645 | |
|
630 | 646 | self.folderList - sub-folder list of remote folder |
|
631 | 647 | |
|
632 | 648 | self.fileList - file list of remote folder |
|
633 | 649 | |
|
634 | 650 | |
|
635 | 651 | """ |
|
636 | 652 | |
|
637 | 653 | if ((server == None) and (username==None) and (password==None) and (remotefolder==None)): |
|
638 | 654 | server, username, password, remotefolder = self.parmsByDefault() |
|
639 | 655 | |
|
640 | 656 | self.server = server |
|
641 | 657 | self.username = username |
|
642 | 658 | self.password = password |
|
643 | 659 | self.remotefolder = remotefolder |
|
644 | 660 | self.file = None |
|
645 | 661 | self.ftp = None |
|
646 | 662 | self.status = 0 |
|
647 | 663 | |
|
648 | 664 | try: |
|
649 | 665 | self.ftp = ftplib.FTP(self.server) |
|
650 | 666 | self.ftp.login(self.username,self.password) |
|
651 | 667 | self.ftp.cwd(self.remotefolder) |
|
652 | 668 | # print 'Connect to FTP Server: Successfully' |
|
653 | 669 | |
|
654 | 670 | except ftplib.all_errors: |
|
655 | 671 | print 'Error FTP Service' |
|
656 | 672 | self.status = 1 |
|
657 | 673 | return |
|
658 | 674 | |
|
659 | 675 | |
|
660 | 676 | |
|
661 | 677 | self.dirList = [] |
|
662 | 678 | |
|
663 | 679 | try: |
|
664 | 680 | self.dirList = self.ftp.nlst() |
|
665 | 681 | |
|
666 | 682 | except ftplib.error_perm, resp: |
|
667 | 683 | if str(resp) == "550 No files found": |
|
668 | 684 | print "no files in this directory" |
|
669 | 685 | self.status = 1 |
|
670 | 686 | return |
|
671 | 687 | |
|
672 | 688 | except ftplib.all_errors: |
|
673 | 689 | print 'Error Displaying Dir-Files' |
|
674 | 690 | self.status = 1 |
|
675 | 691 | return |
|
676 | 692 | |
|
677 | 693 | self.fileList = [] |
|
678 | 694 | self.folderList = [] |
|
679 | 695 | #only for test |
|
680 | 696 | for f in self.dirList: |
|
681 | 697 | name, ext = os.path.splitext(f) |
|
682 | 698 | if ext != '': |
|
683 | 699 | self.fileList.append(f) |
|
684 | 700 | # print 'filename: %s - size: %d'%(f,self.ftp.size(f)) |
|
685 | 701 | |
|
686 | 702 | def parmsByDefault(self): |
|
687 | 703 | server = 'jro-app.igp.gob.pe' |
|
688 | 704 | username = 'wmaster' |
|
689 | 705 | password = 'mst2010vhf' |
|
690 | 706 | remotefolder = '/home/wmaster/graficos' |
|
691 | 707 | |
|
692 | 708 | return server, username, password, remotefolder |
|
693 | 709 | |
|
694 | 710 | |
|
695 | 711 | def mkd(self,dirname): |
|
696 | 712 | """ |
|
697 | 713 | mkd is used to make directory in remote server |
|
698 | 714 | |
|
699 | 715 | Input: |
|
700 | 716 | dirname - directory name |
|
701 | 717 | |
|
702 | 718 | Return: |
|
703 | 719 | 1 in error case else 0 |
|
704 | 720 | """ |
|
705 | 721 | try: |
|
706 | 722 | self.ftp.mkd(dirname) |
|
707 | 723 | except: |
|
708 | 724 | print 'Error creating remote folder:%s'%dirname |
|
709 | 725 | return 1 |
|
710 | 726 | |
|
711 | 727 | return 0 |
|
712 | 728 | |
|
713 | 729 | |
|
714 | 730 | def delete(self,filename): |
|
715 | 731 | """ |
|
716 | 732 | delete is used to delete file in current working directory of remote server |
|
717 | 733 | |
|
718 | 734 | Input: |
|
719 | 735 | filename - filename to delete in remote folder |
|
720 | 736 | |
|
721 | 737 | Return: |
|
722 | 738 | 1 in error case else 0 |
|
723 | 739 | """ |
|
724 | 740 | |
|
725 | 741 | try: |
|
726 | 742 | self.ftp.delete(filename) |
|
727 | 743 | except: |
|
728 | 744 | print 'Error deleting remote file:%s'%filename |
|
729 | 745 | return 1 |
|
730 | 746 | |
|
731 | 747 | return 0 |
|
732 | 748 | |
|
733 | 749 | def download(self,filename,localfolder): |
|
734 | 750 | """ |
|
735 | 751 | download is used to downloading file from remote folder into local folder |
|
736 | 752 | |
|
737 | 753 | Inputs: |
|
738 | 754 | filename - filename to donwload |
|
739 | 755 | |
|
740 | 756 | localfolder - directory local to store filename |
|
741 | 757 | |
|
742 | 758 | Returns: |
|
743 | 759 | self.status - 1 in error case else 0 |
|
744 | 760 | """ |
|
745 | 761 | |
|
746 | 762 | self.status = 0 |
|
747 | 763 | |
|
748 | 764 | |
|
749 | 765 | if not(filename in self.fileList): |
|
750 | 766 | print 'filename:%s not exists'%filename |
|
751 | 767 | self.status = 1 |
|
752 | 768 | return self.status |
|
753 | 769 | |
|
754 | 770 | newfilename = os.path.join(localfolder,filename) |
|
755 | 771 | |
|
756 | 772 | self.file = open(newfilename, 'wb') |
|
757 | 773 | |
|
758 | 774 | try: |
|
759 | 775 | print 'Download: ' + filename |
|
760 | 776 | self.ftp.retrbinary('RETR ' + filename, self.__handleDownload) |
|
761 | 777 | print 'Download Complete' |
|
762 | 778 | except ftplib.all_errors: |
|
763 | 779 | print 'Error Downloading ' + filename |
|
764 | 780 | self.status = 1 |
|
765 | 781 | return self.status |
|
766 | 782 | |
|
767 | 783 | self.file.close() |
|
768 | 784 | |
|
769 | 785 | return self.status |
|
770 | 786 | |
|
771 | 787 | |
|
772 | 788 | def __handleDownload(self,block): |
|
773 | 789 | """ |
|
774 | 790 | __handleDownload is used to handle writing file |
|
775 | 791 | """ |
|
776 | 792 | self.file.write(block) |
|
777 | 793 | |
|
778 | 794 | |
|
779 | 795 | def upload(self,filename,remotefolder=None): |
|
780 | 796 | """ |
|
781 | 797 | upload is used to uploading local file to remote directory |
|
782 | 798 | |
|
783 | 799 | Inputs: |
|
784 | 800 | filename - full path name of local file to store in remote directory |
|
785 | 801 | |
|
786 | 802 | remotefolder - remote directory |
|
787 | 803 | |
|
788 | 804 | Returns: |
|
789 | 805 | self.status - 1 in error case else 0 |
|
790 | 806 | """ |
|
791 | 807 | |
|
792 | 808 | if remotefolder == None: |
|
793 | 809 | remotefolder = self.remotefolder |
|
794 | 810 | |
|
795 | 811 | self.status = 0 |
|
796 | 812 | |
|
797 | 813 | try: |
|
798 | 814 | self.ftp.cwd(remotefolder) |
|
799 | 815 | |
|
800 | 816 | self.file = open(filename, 'rb') |
|
801 | 817 | |
|
802 | 818 | (head, tail) = os.path.split(filename) |
|
803 | 819 | |
|
804 | 820 | command = "STOR " + tail |
|
805 | 821 | |
|
806 | 822 | print 'Uploading: ' + tail |
|
807 | 823 | self.ftp.storbinary(command, self.file) |
|
808 | 824 | print 'Upload Completed' |
|
809 | 825 | |
|
810 | 826 | except ftplib.all_errors: |
|
811 | 827 | print 'Error Uploading ' + tail |
|
812 | 828 | self.status = 1 |
|
813 | 829 | return self.status |
|
814 | 830 | |
|
815 | 831 | self.file.close() |
|
816 | 832 | |
|
817 | 833 | #back to initial directory in __init__() |
|
818 | 834 | self.ftp.cwd(self.remotefolder) |
|
819 | 835 | |
|
820 | 836 | return self.status |
|
821 | 837 | |
|
822 | 838 | |
|
823 | 839 | def dir(self,remotefolder): |
|
824 | 840 | """ |
|
825 | 841 | dir is used to change working directory of remote server and get folder and file list |
|
826 | 842 | |
|
827 | 843 | Input: |
|
828 | 844 | remotefolder - current working directory |
|
829 | 845 | |
|
830 | 846 | Affects: |
|
831 | 847 | self.fileList - file list of working directory |
|
832 | 848 | |
|
833 | 849 | Return: |
|
834 | 850 | infoList - list with filenames and size of file in bytes |
|
835 | 851 | |
|
836 | 852 | self.folderList - folder list |
|
837 | 853 | """ |
|
838 | 854 | |
|
839 | 855 | self.remotefolder = remotefolder |
|
840 | 856 | print 'Change to ' + self.remotefolder |
|
841 | 857 | try: |
|
842 | 858 | self.ftp.cwd(remotefolder) |
|
843 | 859 | except ftplib.all_errors: |
|
844 | 860 | print 'Error Change to ' + self.remotefolder |
|
845 | 861 | infoList = None |
|
846 | 862 | self.folderList = None |
|
847 | 863 | return infoList,self.folderList |
|
848 | 864 | |
|
849 | 865 | self.dirList = [] |
|
850 | 866 | |
|
851 | 867 | try: |
|
852 | 868 | self.dirList = self.ftp.nlst() |
|
853 | 869 | |
|
854 | 870 | except ftplib.error_perm, resp: |
|
855 | 871 | if str(resp) == "550 No files found": |
|
856 | 872 | print "no files in this directory" |
|
857 | 873 | infoList = None |
|
858 | 874 | self.folderList = None |
|
859 | 875 | return infoList,self.folderList |
|
860 | 876 | except ftplib.all_errors: |
|
861 | 877 | print 'Error Displaying Dir-Files' |
|
862 | 878 | infoList = None |
|
863 | 879 | self.folderList = None |
|
864 | 880 | return infoList,self.folderList |
|
865 | 881 | |
|
866 | 882 | infoList = [] |
|
867 | 883 | self.fileList = [] |
|
868 | 884 | self.folderList = [] |
|
869 | 885 | for f in self.dirList: |
|
870 | 886 | name,ext = os.path.splitext(f) |
|
871 | 887 | if ext != '': |
|
872 | 888 | self.fileList.append(f) |
|
873 | 889 | value = (f,self.ftp.size(f)) |
|
874 | 890 | infoList.append(value) |
|
875 | 891 | |
|
876 | 892 | if ext == '': |
|
877 | 893 | self.folderList.append(f) |
|
878 | 894 | |
|
879 | 895 | return infoList,self.folderList |
|
880 | 896 | |
|
881 | 897 | |
|
882 | 898 | def close(self): |
|
883 | 899 | """ |
|
884 | 900 | close is used to close and end FTP connection |
|
885 | 901 | |
|
886 | 902 | Inputs: None |
|
887 | 903 | |
|
888 | 904 | Return: void |
|
889 | 905 | |
|
890 | 906 | """ |
|
891 | 907 | self.ftp.close() |
|
892 | 908 | |
|
893 | 909 | class SendByFTP(Operation): |
|
894 | 910 | |
|
895 | 911 | def __init__(self): |
|
896 | 912 | |
|
897 | 913 | self.status = 1 |
|
898 | 914 | self.counter = 0 |
|
899 | 915 | |
|
900 | 916 | def error_print(self, ValueError): |
|
901 | 917 | |
|
902 | 918 | print ValueError, 'Error FTP' |
|
903 | 919 | print "don't worry the program is running..." |
|
904 | 920 | |
|
905 | 921 | def worker_ftp(self, server, username, password, remotefolder, filenameList): |
|
906 | 922 | |
|
907 | 923 | self.ftpClientObj = FTP(server, username, password, remotefolder) |
|
908 | 924 | for filename in filenameList: |
|
909 | 925 | self.ftpClientObj.upload(filename) |
|
910 | 926 | self.ftpClientObj.close() |
|
911 | 927 | |
|
912 | 928 | def ftp_thread(self, server, username, password, remotefolder): |
|
913 | 929 | if not(self.status): |
|
914 | 930 | return |
|
915 | 931 | |
|
916 | 932 | p = multiprocessing.Process(target=self.worker_ftp, args=(server, username, password, remotefolder, self.filenameList,)) |
|
917 | 933 | p.start() |
|
918 | 934 | |
|
919 | 935 | p.join(3) |
|
920 | 936 | |
|
921 | 937 | if p.is_alive(): |
|
922 | 938 | p.terminate() |
|
923 | 939 | p.join() |
|
924 | 940 | print 'killing ftp process...' |
|
925 | 941 | self.status = 0 |
|
926 | 942 | return |
|
927 | 943 | |
|
928 | 944 | self.status = 1 |
|
929 | 945 | return |
|
930 | 946 | |
|
931 | 947 | def filterByExt(self, ext, localfolder): |
|
932 | 948 | fnameList = glob.glob1(localfolder,ext) |
|
933 | 949 | self.filenameList = [os.path.join(localfolder,x) for x in fnameList] |
|
934 | 950 | |
|
935 | 951 | if len(self.filenameList) == 0: |
|
936 | 952 | self.status = 0 |
|
937 | 953 | |
|
938 | 954 | def run(self, dataOut, ext, localfolder, remotefolder, server, username, password, period=1): |
|
939 | 955 | |
|
940 | 956 | self.counter += 1 |
|
941 | 957 | if self.counter >= period: |
|
942 | 958 | self.filterByExt(ext, localfolder) |
|
943 | 959 | |
|
944 | 960 | self.ftp_thread(server, username, password, remotefolder) |
|
945 | 961 | |
|
946 | 962 | self.counter = 0 |
|
947 | 963 | |
|
948 | 964 | self.status = 1 |
|
949 | 965 |
General Comments 0
You need to be logged in to leave comments.
Login now