##// END OF EJS Templates
v2.2.0: Controller updated
Miguel Valdez -
r708:e5ce72bc2207
parent child
Show More
@@ -1,38 +1,36
1 1 Prerequisites:
2 2
3 3 Core:
4 4 -numpy 1.8.0
5 5 -scipy
6 6 -math
7 7 -matplotlib
8 8 -h5py
9 9 -ftplib
10 10 -paramiko (optional for SendTFilesToServer)
11 11 -stuffr (optional for jroIO_hf)
12 12 -pyfits (Fits data)
13 13
14 14 GUI:
15 15 -PyQt4
16 16 -wxPython
17 -msgpack-numpy
18 -cPickle
19 17
20 18 Signal Chain Installation:
21 19
22 20 1. Install numpy, matplotlib, TKAgg
23 21 2. Install digital_rf_hdf5 module (developed by Haystack Observatory)
24 22 if you want to use USRP data
25 23 3. untar schainpy-x.x.x.tar.gz
26 24 4. cd schainpy-x.x.x
27 25 5. execute:
28 26 [hostname]$ sudo pyhon setup.py install
29 27 6. testing gui:
30 28 [hostname]$ schainGUI (enter)
31 29
32 30 If you want to use serialization and zerorpc you will need to install the next packages:
33 31
34 32 1. zerorpc
35 33 [hostname]$ sudo port install zerorpc
36 34
37 35 2. cPickle, msgpack and msgpack_numpy
38 36 [hostname]$ sudo port install cPickle msgpack mspack_numpy No newline at end of file
@@ -1,7 +1,7
1 1 '''
2 2 Created on Feb 7, 2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 __version__ = "2.1.5" No newline at end of file
7 __version__ = "2.2.0" No newline at end of file
@@ -1,1263 +1,1289
1 1 '''
2 2 Created on September , 2012
3 3 @author:
4 4 '''
5 5
6 6 import sys
7 7 import ast
8 8 import datetime
9 9 import traceback
10 10 import schainpy
11 11 import schainpy.admin
12 12
13 13 from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring
14 14 from xml.dom import minidom
15 15
16 16 from schainpy.model import *
17 17 from time import sleep
18 18
19 19 def prettify(elem):
20 20 """Return a pretty-printed XML string for the Element.
21 21 """
22 22 rough_string = 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 == 'list':
62 62 strList = value.split(',')
63 63
64 64 self.__formated_value = strList
65 65
66 66 return self.__formated_value
67 67
68 68 if format == 'intlist':
69 69 """
70 70 Example:
71 71 value = (0,1,2)
72 72 """
73 73 value = value.replace('(', '')
74 74 value = value.replace(')', '')
75 75
76 76 value = value.replace('[', '')
77 77 value = value.replace(']', '')
78 78
79 79 strList = value.split(',')
80 80 intList = [int(float(x)) for x in strList]
81 81
82 82 self.__formated_value = intList
83 83
84 84 return self.__formated_value
85 85
86 86 if format == 'floatlist':
87 87 """
88 88 Example:
89 89 value = (0.5, 1.4, 2.7)
90 90 """
91 91
92 92 value = value.replace('(', '')
93 93 value = value.replace(')', '')
94 94
95 95 value = value.replace('[', '')
96 96 value = value.replace(']', '')
97 97
98 98 strList = value.split(',')
99 99 floatList = [float(x) for x in strList]
100 100
101 101 self.__formated_value = floatList
102 102
103 103 return self.__formated_value
104 104
105 105 if format == 'date':
106 106 strList = value.split('/')
107 107 intList = [int(x) for x in strList]
108 108 date = datetime.date(intList[0], intList[1], intList[2])
109 109
110 110 self.__formated_value = date
111 111
112 112 return self.__formated_value
113 113
114 114 if format == 'time':
115 115 strList = value.split(':')
116 116 intList = [int(x) for x in strList]
117 117 time = datetime.time(intList[0], intList[1], intList[2])
118 118
119 119 self.__formated_value = time
120 120
121 121 return self.__formated_value
122 122
123 123 if format == 'pairslist':
124 124 """
125 125 Example:
126 126 value = (0,1),(1,2)
127 127 """
128 128
129 129 value = value.replace('(', '')
130 130 value = value.replace(')', '')
131 131
132 132 value = value.replace('[', '')
133 133 value = value.replace(']', '')
134 134
135 135 strList = value.split(',')
136 136 intList = [int(item) for item in strList]
137 137 pairList = []
138 138 for i in range(len(intList)/2):
139 139 pairList.append((intList[i*2], intList[i*2 + 1]))
140 140
141 141 self.__formated_value = pairList
142 142
143 143 return self.__formated_value
144 144
145 145 if format == 'multilist':
146 146 """
147 147 Example:
148 148 value = (0,1,2),(3,4,5)
149 149 """
150 150 multiList = ast.literal_eval(value)
151 151
152 152 if type(multiList[0]) == int:
153 153 multiList = ast.literal_eval("(" + value + ")")
154 154
155 155 self.__formated_value = multiList
156 156
157 157 return self.__formated_value
158 158
159 159 if format == 'bool':
160 160 value = int(value)
161 161
162 162 if format == 'int':
163 163 value = float(value)
164 164
165 165 format_func = eval(format)
166 166
167 167 self.__formated_value = format_func(value)
168 168
169 169 return self.__formated_value
170 170
171 171 def updateId(self, new_id):
172 172
173 173 self.id = str(new_id)
174 174
175 175 def setup(self, id, name, value, format='str'):
176 176
177 177 self.id = str(id)
178 178 self.name = name
179 179 self.value = str(value)
180 180 self.format = str.lower(format)
181 181
182 182 try:
183 183 self.getValue()
184 184 except:
185 185 return 0
186 186
187 187 return 1
188 188
189 189 def update(self, name, value, format='str'):
190 190
191 191 self.name = name
192 192 self.value = str(value)
193 193 self.format = format
194 194
195 195 def makeXml(self, opElement):
196 196
197 197 parmElement = SubElement(opElement, self.ELEMENTNAME)
198 198 parmElement.set('id', str(self.id))
199 199 parmElement.set('name', self.name)
200 200 parmElement.set('value', self.value)
201 201 parmElement.set('format', self.format)
202 202
203 203 def readXml(self, parmElement):
204 204
205 205 self.id = parmElement.get('id')
206 206 self.name = parmElement.get('name')
207 207 self.value = parmElement.get('value')
208 208 self.format = str.lower(parmElement.get('format'))
209 209
210 210 #Compatible with old signal chain version
211 211 if self.format == 'int' and self.name == 'idfigure':
212 212 self.name = 'id'
213 213
214 214 def printattr(self):
215 215
216 216 print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format)
217 217
218 218 class OperationConf():
219 219
220 220 id = None
221 221 name = None
222 222 priority = None
223 223 type = None
224 224
225 225 parmConfObjList = []
226 226
227 227 ELEMENTNAME = 'Operation'
228 228
229 229 def __init__(self):
230 230
231 231 self.id = '0'
232 232 self.name = None
233 233 self.priority = None
234 234 self.type = 'self'
235 235
236 236
237 237 def __getNewId(self):
238 238
239 239 return int(self.id)*10 + len(self.parmConfObjList) + 1
240 240
241 241 def updateId(self, new_id):
242 242
243 243 self.id = str(new_id)
244 244
245 245 n = 1
246 246 for parmObj in self.parmConfObjList:
247 247
248 248 idParm = str(int(new_id)*10 + n)
249 249 parmObj.updateId(idParm)
250 250
251 251 n += 1
252 252
253 253 def getElementName(self):
254 254
255 255 return self.ELEMENTNAME
256 256
257 257 def getParameterObjList(self):
258 258
259 259 return self.parmConfObjList
260 260
261 261 def getParameterObj(self, parameterName):
262 262
263 263 for parmConfObj in self.parmConfObjList:
264 264
265 265 if parmConfObj.name != parameterName:
266 266 continue
267 267
268 268 return parmConfObj
269 269
270 270 return None
271 271
272 272 def getParameterObjfromValue(self, parameterValue):
273 273
274 274 for parmConfObj in self.parmConfObjList:
275 275
276 276 if parmConfObj.getValue() != parameterValue:
277 277 continue
278 278
279 279 return parmConfObj.getValue()
280 280
281 281 return None
282 282
283 283 def getParameterValue(self, parameterName):
284 284
285 285 parameterObj = self.getParameterObj(parameterName)
286 286
287 287 # if not parameterObj:
288 288 # return None
289 289
290 290 value = parameterObj.getValue()
291 291
292 292 return value
293 293
294 294 def setup(self, id, name, priority, type):
295 295
296 296 self.id = str(id)
297 297 self.name = name
298 298 self.type = type
299 299 self.priority = priority
300 300
301 301 self.parmConfObjList = []
302 302
303 303 def removeParameters(self):
304 304
305 305 for obj in self.parmConfObjList:
306 306 del obj
307 307
308 308 self.parmConfObjList = []
309 309
310 310 def addParameter(self, name, value, format='str'):
311 311
312 312 id = self.__getNewId()
313 313
314 314 parmConfObj = ParameterConf()
315 315 if not parmConfObj.setup(id, name, value, format):
316 316 return None
317 317
318 318 self.parmConfObjList.append(parmConfObj)
319 319
320 320 return parmConfObj
321 321
322 322 def changeParameter(self, name, value, format='str'):
323 323
324 324 parmConfObj = self.getParameterObj(name)
325 325 parmConfObj.update(name, value, format)
326 326
327 327 return parmConfObj
328 328
329 329 def makeXml(self, procUnitElement):
330 330
331 331 opElement = SubElement(procUnitElement, self.ELEMENTNAME)
332 332 opElement.set('id', str(self.id))
333 333 opElement.set('name', self.name)
334 334 opElement.set('type', self.type)
335 335 opElement.set('priority', str(self.priority))
336 336
337 337 for parmConfObj in self.parmConfObjList:
338 338 parmConfObj.makeXml(opElement)
339 339
340 340 def readXml(self, opElement):
341 341
342 342 self.id = opElement.get('id')
343 343 self.name = opElement.get('name')
344 344 self.type = opElement.get('type')
345 345 self.priority = opElement.get('priority')
346 346
347 347 #Compatible with old signal chain version
348 348 #Use of 'run' method instead 'init'
349 349 if self.type == 'self' and self.name == 'init':
350 350 self.name = 'run'
351 351
352 352 self.parmConfObjList = []
353 353
354 354 parmElementList = opElement.getiterator(ParameterConf().getElementName())
355 355
356 356 for parmElement in parmElementList:
357 357 parmConfObj = ParameterConf()
358 358 parmConfObj.readXml(parmElement)
359 359
360 360 #Compatible with old signal chain version
361 361 #If an 'plot' OPERATION is found, changes name operation by the value of its type PARAMETER
362 362 if self.type != 'self' and self.name == 'Plot':
363 363 if parmConfObj.format == 'str' and parmConfObj.name == 'type':
364 364 self.name = parmConfObj.value
365 365 continue
366 366
367 367 self.parmConfObjList.append(parmConfObj)
368 368
369 369 def printattr(self):
370 370
371 371 print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME,
372 372 self.id,
373 373 self.name,
374 374 self.type,
375 375 self.priority)
376 376
377 377 for parmConfObj in self.parmConfObjList:
378 378 parmConfObj.printattr()
379 379
380 380 def createObject(self, plotter_queue=None):
381 381
382 382 if self.type == 'self':
383 383 raise ValueError, "This operation type cannot be created"
384 384
385 385 if self.type == 'plotter':
386 386 #Plotter(plotter_name)
387 if not plotter_queue:
388 raise ValueError, "plotter_queue is not defined. Use:\nmyProject = Project()\nmyProject.setPlotterQueue(plotter_queue)"
389
387 390 opObj = Plotter(self.name, plotter_queue)
388 391
389 392 if self.type == 'external' or self.type == 'other':
390 393 className = eval(self.name)
391 394 opObj = className()
392 395
393 396 return opObj
394 397
395 398 class ProcUnitConf():
396 399
397 400 id = None
398 401 name = None
399 402 datatype = None
400 403 inputId = None
401 404 parentId = None
402 405
403 406 opConfObjList = []
404 407
405 408 procUnitObj = None
406 409 opObjList = []
407 410
408 411 ELEMENTNAME = 'ProcUnit'
409 412
410 413 def __init__(self):
411 414
412 415 self.id = None
413 416 self.datatype = None
414 417 self.name = None
415 418 self.inputId = None
416 419
417 420 self.opConfObjList = []
418 421
419 422 self.procUnitObj = None
420 423 self.opObjDict = {}
421 424
422 425 def __getPriority(self):
423 426
424 427 return len(self.opConfObjList)+1
425 428
426 429 def __getNewId(self):
427 430
428 431 return int(self.id)*10 + len(self.opConfObjList) + 1
429 432
430 433 def getElementName(self):
431 434
432 435 return self.ELEMENTNAME
433 436
434 437 def getId(self):
435 438
436 439 return self.id
437 440
438 441 def updateId(self, new_id, parentId=parentId):
439 442
440 443
441 444 new_id = int(parentId)*10 + (int(self.id) % 10)
442 445 new_inputId = int(parentId)*10 + (int(self.inputId) % 10)
443 446
444 447 #If this proc unit has not inputs
445 448 if self.inputId == '0':
446 449 new_inputId = 0
447 450
448 451 n = 1
449 452 for opConfObj in self.opConfObjList:
450 453
451 454 idOp = str(int(new_id)*10 + n)
452 455 opConfObj.updateId(idOp)
453 456
454 457 n += 1
455 458
456 459 self.parentId = str(parentId)
457 460 self.id = str(new_id)
458 461 self.inputId = str(new_inputId)
459 462
460 463
461 464 def getInputId(self):
462 465
463 466 return self.inputId
464 467
465 468 def getOperationObjList(self):
466 469
467 470 return self.opConfObjList
468 471
469 472 def getOperationObj(self, name=None):
470 473
471 474 for opConfObj in self.opConfObjList:
472 475
473 476 if opConfObj.name != name:
474 477 continue
475 478
476 479 return opConfObj
477 480
478 481 return None
479 482
480 483 def getOpObjfromParamValue(self, value=None):
481 484
482 485 for opConfObj in self.opConfObjList:
483 486 if opConfObj.getParameterObjfromValue(parameterValue=value) != value:
484 487 continue
485 488 return opConfObj
486 489 return None
487 490
488 491 def getProcUnitObj(self):
489 492
490 493 return self.procUnitObj
491 494
492 495 def setup(self, id, name, datatype, inputId, parentId=None):
493 496
494 497 #Compatible with old signal chain version
495 498 if datatype==None and name==None:
496 499 raise ValueError, "datatype or name should be defined"
497 500
498 501 if name==None:
499 502 if 'Proc' in datatype:
500 503 name = datatype
501 504 else:
502 505 name = '%sProc' %(datatype)
503 506
504 507 if datatype==None:
505 508 datatype = name.replace('Proc','')
506 509
507 510 self.id = str(id)
508 511 self.name = name
509 512 self.datatype = datatype
510 513 self.inputId = inputId
511 514 self.parentId = parentId
512 515
513 516 self.opConfObjList = []
514 517
515 518 self.addOperation(name='run', optype='self')
516 519
517 520 def removeOperations(self):
518 521
519 522 for obj in self.opConfObjList:
520 523 del obj
521 524
522 525 self.opConfObjList = []
523 526 self.addOperation(name='run')
524 527
525 528 def addParameter(self, **kwargs):
526 529 '''
527 530 Add parameters to "run" operation
528 531 '''
529 532 opObj = self.opConfObjList[0]
530 533
531 534 opObj.addParameter(**kwargs)
532 535
533 536 return opObj
534 537
535 538 def addOperation(self, name, optype='self'):
536 539
537 540 id = self.__getNewId()
538 541 priority = self.__getPriority()
539 542
540 543 opConfObj = OperationConf()
541 544 opConfObj.setup(id, name=name, priority=priority, type=optype)
542 545
543 546 self.opConfObjList.append(opConfObj)
544 547
545 548 return opConfObj
546 549
547 550 def makeXml(self, projectElement):
548 551
549 552 procUnitElement = SubElement(projectElement, self.ELEMENTNAME)
550 553 procUnitElement.set('id', str(self.id))
551 554 procUnitElement.set('name', self.name)
552 555 procUnitElement.set('datatype', self.datatype)
553 556 procUnitElement.set('inputId', str(self.inputId))
554 557
555 558 for opConfObj in self.opConfObjList:
556 559 opConfObj.makeXml(procUnitElement)
557 560
558 561 def readXml(self, upElement):
559 562
560 563 self.id = upElement.get('id')
561 564 self.name = upElement.get('name')
562 565 self.datatype = upElement.get('datatype')
563 566 self.inputId = upElement.get('inputId')
564 567
565 568 if self.ELEMENTNAME == "ReadUnit":
566 569 self.datatype = self.datatype.replace("Reader", "")
567 570
568 571 if self.ELEMENTNAME == "ProcUnit":
569 572 self.datatype = self.datatype.replace("Proc", "")
570 573
571 574 if self.inputId == 'None':
572 575 self.inputId = '0'
573 576
574 577 self.opConfObjList = []
575 578
576 579 opElementList = upElement.getiterator(OperationConf().getElementName())
577 580
578 581 for opElement in opElementList:
579 582 opConfObj = OperationConf()
580 583 opConfObj.readXml(opElement)
581 584 self.opConfObjList.append(opConfObj)
582 585
583 586 def printattr(self):
584 587
585 588 print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME,
586 589 self.id,
587 590 self.name,
588 591 self.datatype,
589 592 self.inputId)
590 593
591 594 for opConfObj in self.opConfObjList:
592 595 opConfObj.printattr()
593 596
594 597 def createObjects(self, plotter_queue=None):
595 598
596 599 className = eval(self.name)
597 600 procUnitObj = className()
598 601
599 602 for opConfObj in self.opConfObjList:
600 603
601 604 if opConfObj.type == 'self':
602 605 continue
603 606
604 607 opObj = opConfObj.createObject(plotter_queue)
605 608
606 609 self.opObjDict[opConfObj.id] = opObj
607 610 procUnitObj.addOperation(opObj, opConfObj.id)
608 611
609 612 self.procUnitObj = procUnitObj
610 613
611 614 return procUnitObj
612 615
613 616 def run(self):
614 617
615 618 is_ok = False
616 619
617 620 for opConfObj in self.opConfObjList:
618 621
619 622 kwargs = {}
620 623 for parmConfObj in opConfObj.getParameterObjList():
621 624 if opConfObj.name == 'run' and parmConfObj.name == 'datatype':
622 625 continue
623 626
624 627 kwargs[parmConfObj.name] = parmConfObj.getValue()
625 628
626 629 #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id)
627 630 sts = self.procUnitObj.call(opType = opConfObj.type,
628 631 opName = opConfObj.name,
629 632 opId = opConfObj.id,
630 633 **kwargs)
631 634 is_ok = is_ok or sts
632 635
633 636 return is_ok
634 637
635 638 def close(self):
636 639
637 640 for opConfObj in self.opConfObjList:
638 641 if opConfObj.type == 'self':
639 642 continue
640 643
641 644 opObj = self.procUnitObj.getOperationObj(opConfObj.id)
642 645 opObj.close()
643 646
644 647 self.procUnitObj.close()
645 648
646 649 return
647 650
648 651 class ReadUnitConf(ProcUnitConf):
649 652
650 653 path = None
651 654 startDate = None
652 655 endDate = None
653 656 startTime = None
654 657 endTime = None
655 658
656 659 ELEMENTNAME = 'ReadUnit'
657 660
658 661 def __init__(self):
659 662
660 663 self.id = None
661 664 self.datatype = None
662 665 self.name = None
663 666 self.inputId = None
664 667
665 668 self.parentId = None
666 669
667 670 self.opConfObjList = []
668 671 self.opObjList = []
669 672
670 673 def getElementName(self):
671 674
672 675 return self.ELEMENTNAME
673 676
674 677 def setup(self, id, name, datatype, path, startDate="", endDate="", startTime="", endTime="", parentId=None, **kwargs):
675 678
676 679 #Compatible with old signal chain version
677 680 if datatype==None and name==None:
678 681 raise ValueError, "datatype or name should be defined"
679 682
680 683 if name==None:
681 684 if 'Reader' in datatype:
682 685 name = datatype
683 686 else:
684 687 name = '%sReader' %(datatype)
685 688
686 689 if datatype==None:
687 690 datatype = name.replace('Reader','')
688 691
689 692 self.id = id
690 693 self.name = name
691 694 self.datatype = datatype
692 695
693 696 self.path = os.path.abspath(path)
694 697 self.startDate = startDate
695 698 self.endDate = endDate
696 699 self.startTime = startTime
697 700 self.endTime = endTime
698 701
699 702 self.inputId = '0'
700 703 self.parentId = parentId
701 704
702 705 self.addRunOperation(**kwargs)
703 706
704 707 def update(self, datatype, path, startDate, endDate, startTime, endTime, parentId=None, name=None, **kwargs):
705 708
706 709 #Compatible with old signal chain version
707 710 if datatype==None and name==None:
708 711 raise ValueError, "datatype or name should be defined"
709 712
710 713 if name==None:
711 714 if 'Reader' in datatype:
712 715 name = datatype
713 716 else:
714 717 name = '%sReader' %(datatype)
715 718
716 719 if datatype==None:
717 720 datatype = name.replace('Reader','')
718 721
719 722 self.datatype = datatype
720 723 self.name = name
721 724 self.path = path
722 725 self.startDate = startDate
723 726 self.endDate = endDate
724 727 self.startTime = startTime
725 728 self.endTime = endTime
726 729
727 730 self.inputId = '0'
728 731 self.parentId = parentId
729 732
730 733 self.updateRunOperation(**kwargs)
731 734
732 735 def removeOperations(self):
733 736
734 737 for obj in self.opConfObjList:
735 738 del obj
736 739
737 740 self.opConfObjList = []
738 741
739 742 def addRunOperation(self, **kwargs):
740 743
741 744 opObj = self.addOperation(name = 'run', optype = 'self')
742 745
743 746 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
744 747 opObj.addParameter(name='path' , value=self.path, format='str')
745 748 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
746 749 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
747 750 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
748 751 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
749 752
750 753 for key, value in kwargs.items():
751 754 opObj.addParameter(name=key, value=value, format=type(value).__name__)
752 755
753 756 return opObj
754 757
755 758 def updateRunOperation(self, **kwargs):
756 759
757 760 opObj = self.getOperationObj(name = 'run')
758 761 opObj.removeParameters()
759 762
760 763 opObj.addParameter(name='datatype' , value=self.datatype, format='str')
761 764 opObj.addParameter(name='path' , value=self.path, format='str')
762 765 opObj.addParameter(name='startDate' , value=self.startDate, format='date')
763 766 opObj.addParameter(name='endDate' , value=self.endDate, format='date')
764 767 opObj.addParameter(name='startTime' , value=self.startTime, format='time')
765 768 opObj.addParameter(name='endTime' , value=self.endTime, format='time')
766 769
767 770 for key, value in kwargs.items():
768 771 opObj.addParameter(name=key, value=value, format=type(value).__name__)
769 772
770 773 return opObj
771 774
772 775 # def makeXml(self, projectElement):
773 776 #
774 777 # procUnitElement = SubElement(projectElement, self.ELEMENTNAME)
775 778 # procUnitElement.set('id', str(self.id))
776 779 # procUnitElement.set('name', self.name)
777 780 # procUnitElement.set('datatype', self.datatype)
778 781 # procUnitElement.set('inputId', str(self.inputId))
779 782 #
780 783 # for opConfObj in self.opConfObjList:
781 784 # opConfObj.makeXml(procUnitElement)
782 785
783 786 def readXml(self, upElement):
784 787
785 788 self.id = upElement.get('id')
786 789 self.name = upElement.get('name')
787 790 self.datatype = upElement.get('datatype')
788 791 self.inputId = upElement.get('inputId')
789 792
790 793 if self.ELEMENTNAME == "ReadUnit":
791 794 self.datatype = self.datatype.replace("Reader", "")
792 795
793 796 if self.inputId == 'None':
794 797 self.inputId = '0'
795 798
796 799 self.opConfObjList = []
797 800
798 801 opElementList = upElement.getiterator(OperationConf().getElementName())
799 802
800 803 for opElement in opElementList:
801 804 opConfObj = OperationConf()
802 805 opConfObj.readXml(opElement)
803 806 self.opConfObjList.append(opConfObj)
804 807
805 808 if opConfObj.name == 'run':
806 809 self.path = opConfObj.getParameterValue('path')
807 810 self.startDate = opConfObj.getParameterValue('startDate')
808 811 self.endDate = opConfObj.getParameterValue('endDate')
809 812 self.startTime = opConfObj.getParameterValue('startTime')
810 813 self.endTime = opConfObj.getParameterValue('endTime')
811 814
812 815 class Project():
813 816
814 817 id = None
815 818 name = None
816 819 description = None
817 820 filename = None
818 821
819 822 procUnitConfObjDict = None
820 823
821 824 ELEMENTNAME = 'Project'
822 825
823 826 __plotterQueue = None
824 827
825 def __init__(self, filename=None, plotter_queue=None):
828 def __init__(self, plotter_queue=None):
826 829
827 830 self.id = None
828 831 self.name = None
829 832 self.description = None
830 833
831 self.filename = filename
832 834 self.__plotterQueue = plotter_queue
833 835
834 836 self.procUnitConfObjDict = {}
835 837
836 838 def __getNewId(self):
837 839
838 840 id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1
839 841
840 842 return str(id)
841 843
842 844 def getElementName(self):
843 845
844 846 return self.ELEMENTNAME
845 847
846 848 def getId(self):
847 849
848 850 return self.id
849 851
850 852 def updateId(self, new_id):
851 853
852 854 self.id = str(new_id)
853 855
854 856 keyList = self.procUnitConfObjDict.keys()
855 857 keyList.sort()
856 858
857 859 n = 1
858 860 newProcUnitConfObjDict = {}
859 861
860 862 for procKey in keyList:
861 863
862 864 procUnitConfObj = self.procUnitConfObjDict[procKey]
863 865 idProcUnit = str(int(self.id)*10 + n)
864 866 procUnitConfObj.updateId(idProcUnit, parentId = self.id)
865 867
866 868 newProcUnitConfObjDict[idProcUnit] = procUnitConfObj
867 869 n += 1
868 870
869 871 self.procUnitConfObjDict = newProcUnitConfObjDict
870 872
871 873 def setup(self, id, name, description):
872 874
873 875 self.id = str(id)
874 876 self.name = name
875 877 self.description = description
876 878
877 879 def update(self, name, description):
878 880
879 881 self.name = name
880 882 self.description = description
881 883
882 884 def addReadUnit(self, id=None, datatype=None, name=None, **kwargs):
883 885
884 886 if id is None:
885 887 idReadUnit = self.__getNewId()
886 888 else:
887 889 idReadUnit = str(id)
888 890
889 891 readUnitConfObj = ReadUnitConf()
890 892 readUnitConfObj.setup(idReadUnit, name, datatype, parentId=self.id, **kwargs)
891 893
892 894 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
893 895
894 896 return readUnitConfObj
895 897
896 898 def addProcUnit(self, inputId='0', datatype=None, name=None):
897 899
898 900 idProcUnit = self.__getNewId()
899 901
900 902 procUnitConfObj = ProcUnitConf()
901 903 procUnitConfObj.setup(idProcUnit, name, datatype, inputId, parentId=self.id)
902 904
903 905 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
904 906
905 907 return procUnitConfObj
906 908
907 909 def removeProcUnit(self, id):
908 910
909 911 if id in self.procUnitConfObjDict.keys():
910 912 self.procUnitConfObjDict.pop(id)
911 913
912 914 def getReadUnitId(self):
913 915
914 916 readUnitConfObj = self.getReadUnitObj()
915 917
916 918 return readUnitConfObj.id
917 919
918 920 def getReadUnitObj(self):
919 921
920 922 for obj in self.procUnitConfObjDict.values():
921 923 if obj.getElementName() == "ReadUnit":
922 924 return obj
923 925
924 926 return None
925 927
926 928 def getProcUnitObj(self, id=None, name=None):
927 929
928 930 if id != None:
929 931 return self.procUnitConfObjDict[id]
930 932
931 933 if name != None:
932 934 return self.getProcUnitObjByName(name)
933 935
934 936 return None
935 937
936 938 def getProcUnitObjByName(self, name):
937 939
938 940 for obj in self.procUnitConfObjDict.values():
939 941 if obj.name == name:
940 942 return obj
941 943
942 944 return None
943 945
944 946 def procUnitItems(self):
945 947
946 948 return self.procUnitConfObjDict.items()
947 949
948 950 def makeXml(self):
949 951
950 952 projectElement = Element('Project')
951 953 projectElement.set('id', str(self.id))
952 954 projectElement.set('name', self.name)
953 955 projectElement.set('description', self.description)
954 956
955 957 for procUnitConfObj in self.procUnitConfObjDict.values():
956 958 procUnitConfObj.makeXml(projectElement)
957 959
958 960 self.projectElement = projectElement
959 961
960 962 def writeXml(self, filename=None):
961 963
962 964 if filename == None:
963 filename = self.filename
965 if self.filename:
966 filename = self.filename
967 else:
968 filename = "schain.xml"
964 969
965 970 if not filename:
966 971 print "filename has not been defined. Use setFilename(filename) for do it."
967 972 return 0
968 973
969 974 abs_file = os.path.abspath(filename)
970 975
971 976 if not os.access(os.path.dirname(abs_file), os.W_OK):
972 977 print "No write permission on %s" %os.path.dirname(abs_file)
973 978 return 0
974 979
975 980 if os.path.isfile(abs_file) and not(os.access(abs_file, os.W_OK)):
976 981 print "File %s already exists and it could not be overwriten" %abs_file
977 982 return 0
978 983
979 984 self.makeXml()
980 985
981 986 ElementTree(self.projectElement).write(abs_file, method='xml')
982 987
988 self.filename = abs_file
989
983 990 return 1
984 991
985 992 def readXml(self, filename = None):
986
987 if filename == None:
988 filename = self.filename
989 993
990 994 abs_file = os.path.abspath(filename)
991 995
992 996 if not os.path.isfile(abs_file):
993 997 print "%s does not exist" %abs_file
994 998 return 0
995 999
996 1000 self.projectElement = None
997 1001 self.procUnitConfObjDict = {}
998 1002
999 1003 self.projectElement = ElementTree().parse(abs_file)
1000 1004
1001 1005 self.project = self.projectElement.tag
1002 1006
1003 1007 self.id = self.projectElement.get('id')
1004 1008 self.name = self.projectElement.get('name')
1005 1009 self.description = self.projectElement.get('description')
1006 1010
1007 1011 readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName())
1008 1012
1009 1013 for readUnitElement in readUnitElementList:
1010 1014 readUnitConfObj = ReadUnitConf()
1011 1015 readUnitConfObj.readXml(readUnitElement)
1012 1016
1013 1017 if readUnitConfObj.parentId == None:
1014 1018 readUnitConfObj.parentId = self.id
1015 1019
1016 1020 self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj
1017 1021
1018 1022 procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName())
1019 1023
1020 1024 for procUnitElement in procUnitElementList:
1021 1025 procUnitConfObj = ProcUnitConf()
1022 1026 procUnitConfObj.readXml(procUnitElement)
1023 1027
1024 1028 if procUnitConfObj.parentId == None:
1025 1029 procUnitConfObj.parentId = self.id
1026 1030
1027 1031 self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj
1028 1032
1029 if self.filename == None:
1030 self.filename = abs_file
1033 self.filename = abs_file
1031 1034
1032 1035 return 1
1033 1036
1034 1037 def printattr(self):
1035 1038
1036 1039 print "Project[%s]: name = %s, description = %s" %(self.id,
1037 1040 self.name,
1038 1041 self.description)
1039 1042
1040 1043 for procUnitConfObj in self.procUnitConfObjDict.values():
1041 1044 procUnitConfObj.printattr()
1042 1045
1043 1046 def createObjects(self):
1044 1047
1045 1048 for procUnitConfObj in self.procUnitConfObjDict.values():
1046 1049 procUnitConfObj.createObjects(self.__plotterQueue)
1047 1050
1048 1051 def __connect(self, objIN, thisObj):
1049 1052
1050 1053 thisObj.setInput(objIN.getOutputObj())
1051 1054
1052 1055 def connectObjects(self):
1053 1056
1054 1057 for thisPUConfObj in self.procUnitConfObjDict.values():
1055 1058
1056 1059 inputId = thisPUConfObj.getInputId()
1057 1060
1058 1061 if int(inputId) == 0:
1059 1062 continue
1060 1063
1061 1064 #Get input object
1062 1065 puConfINObj = self.procUnitConfObjDict[inputId]
1063 1066 puObjIN = puConfINObj.getProcUnitObj()
1064 1067
1065 1068 #Get current object
1066 1069 thisPUObj = thisPUConfObj.getProcUnitObj()
1067 1070
1068 1071 self.__connect(puObjIN, thisPUObj)
1069 1072
1070 1073 def __handleError(self, procUnitConfObj):
1071 1074
1072 1075 import socket
1073 1076
1074 1077 err = traceback.format_exception(sys.exc_info()[0],
1075 1078 sys.exc_info()[1],
1076 1079 sys.exc_info()[2])
1077 1080
1078 1081 subject = "SChain v%s: Error running %s\n" %(schainpy.__version__, procUnitConfObj.name)
1079 1082
1080 1083 subtitle = "%s: %s\n" %(procUnitConfObj.getElementName() ,procUnitConfObj.name)
1081 1084 subtitle += "Hostname: %s\n" %socket.gethostbyname(socket.gethostname())
1082 1085 subtitle += "Working directory: %s\n" %os.path.abspath("./")
1083 1086 subtitle += "Configuration file: %s\n" %self.filename
1084 1087 subtitle += "Time: %s\n" %str(datetime.datetime.now())
1085 1088
1086 1089 readUnitConfObj = self.getReadUnitObj()
1087 1090 if readUnitConfObj:
1088 1091 subtitle += "\nInput parameters:\n"
1089 1092 subtitle += "[Data path = %s]\n" %readUnitConfObj.path
1090 1093 subtitle += "[Data type = %s]\n" %readUnitConfObj.datatype
1091 1094 subtitle += "[Start date = %s]\n" %readUnitConfObj.startDate
1092 1095 subtitle += "[End date = %s]\n" %readUnitConfObj.endDate
1093 1096 subtitle += "[Start time = %s]\n" %readUnitConfObj.startTime
1094 1097 subtitle += "[End time = %s]\n" %readUnitConfObj.endTime
1095 1098
1096 1099 message = "".join(err)
1097 1100
1098 1101 sys.stderr.write(message)
1099 1102
1100 1103 adminObj = schainpy.admin.SchainNotify()
1101 1104 adminObj.sendAlert(message=message,
1102 1105 subject=subject,
1103 1106 subtitle=subtitle,
1104 1107 filename=self.filename)
1105 1108
1106 1109 def isPaused(self):
1107 1110 return 0
1108 1111
1109 1112 def isStopped(self):
1110 1113 return 0
1111 1114
1112 1115 def runController(self):
1113 1116 """
1114 1117 returns 0 when this process has been stopped, 1 otherwise
1115 1118 """
1116 1119
1117 1120 if self.isPaused():
1118 1121 print "Process suspended"
1119 1122
1120 1123 while True:
1121 1124 sleep(0.1)
1122 1125
1123 1126 if not self.isPaused():
1124 1127 break
1125 1128
1126 1129 if self.isStopped():
1127 1130 break
1128 1131
1129 1132 print "Process reinitialized"
1130 1133
1131 1134 if self.isStopped():
1132 1135 print "Process stopped"
1133 1136 return 0
1134 1137
1135 1138 return 1
1136 1139
1137 1140 def setFilename(self, filename):
1138 1141
1139 1142 self.filename = filename
1140 1143
1141 1144 def setPlotterQueue(self, plotter_queue):
1142 1145
1143 1146 self.__plotterQueue = plotter_queue
1144 1147
1145 1148 def getPlotterQueue(self):
1146 1149
1147 1150 return self.__plotterQueue
1151
1152 def useExternalPlotManager(self):
1153
1154 plotterList = ['Scope',
1155 'SpectraPlot', 'RTIPlot',
1156 'CrossSpectraPlot', 'CoherenceMap',
1157 'PowerProfilePlot', 'Noise', 'BeaconPhase',
1158 'CorrelationPlot',
1159 'SpectraHeisScope','RTIfromSpectraHeis']
1148 1160
1161 for thisPUConfObj in self.procUnitConfObjDict.values():
1162
1163 inputId = thisPUConfObj.getInputId()
1164
1165 if int(inputId) == 0:
1166 continue
1167
1168 for thisOpObj in thisPUConfObj.getOperationObjList():
1169
1170 if thisOpObj.type == "self":
1171 continue
1172
1173 if thisOpObj.name in plotterList:
1174 thisOpObj.type = "plotter"
1175
1149 1176 def run(self):
1150 1177
1151 1178 print
1152 1179 print "*"*60
1153 1180 print " Starting SIGNAL CHAIN PROCESSING v%s " %schainpy.__version__
1154 1181 print "*"*60
1155 1182 print
1156 1183
1157 1184 keyList = self.procUnitConfObjDict.keys()
1158 1185 keyList.sort()
1159 1186
1160 1187 while(True):
1161 1188
1162 1189 is_ok = False
1163 1190
1164 1191 for procKey in keyList:
1165 1192 # print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id)
1166 1193
1167 1194 procUnitConfObj = self.procUnitConfObjDict[procKey]
1168 1195
1169 1196 try:
1170 1197 sts = procUnitConfObj.run()
1171 1198 is_ok = is_ok or sts
1172 1199 except ValueError, e:
1173 1200 print "***** Error occurred in %s *****" %(procUnitConfObj.name)
1174 1201 sleep(0.5)
1175 1202 print e
1176 1203 is_ok = False
1177 1204 break
1178 1205 except:
1179 1206 print "***** Error occurred in %s *****" %(procUnitConfObj.name)
1180 1207 sleep(0.5)
1181 1208 self.__handleError(procUnitConfObj)
1182 1209 is_ok = False
1183 1210 break
1184 1211
1185 1212 #If every process unit finished so end process
1186 1213 if not(is_ok):
1187 1214 print "Every process unit have finished"
1188 1215 break
1189 1216
1190 1217 if not self.runController():
1191 1218 break
1192 1219
1193 1220 #Closing every process
1194 1221 for procKey in keyList:
1195 1222 procUnitConfObj = self.procUnitConfObjDict[procKey]
1196 1223 procUnitConfObj.close()
1197 1224
1198 1225 print "Process finished"
1199 1226
1200 1227 def start(self):
1201 1228
1202 if not self.writeXml():
1203 return
1229 self.writeXml()
1204 1230
1205 1231 self.createObjects()
1206 1232 self.connectObjects()
1207 1233 self.run()
1208 1234
1209 1235 if __name__ == '__main__':
1210 1236
1211 1237 desc = "Segundo Test"
1212 1238 filename = "schain.xml"
1213 1239
1214 1240 controllerObj = Project()
1215 1241
1216 1242 controllerObj.setup(id = '191', name='test01', description=desc)
1217 1243
1218 1244 readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage',
1219 1245 path='data/rawdata/',
1220 1246 startDate='2011/01/01',
1221 1247 endDate='2012/12/31',
1222 1248 startTime='00:00:00',
1223 1249 endTime='23:59:59',
1224 1250 online=1,
1225 1251 walk=1)
1226 1252
1227 1253 procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId())
1228 1254
1229 1255 opObj10 = procUnitConfObj0.addOperation(name='selectChannels')
1230 1256 opObj10.addParameter(name='channelList', value='3,4,5', format='intlist')
1231 1257
1232 1258 opObj10 = procUnitConfObj0.addOperation(name='selectHeights')
1233 1259 opObj10.addParameter(name='minHei', value='90', format='float')
1234 1260 opObj10.addParameter(name='maxHei', value='180', format='float')
1235 1261
1236 1262 opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
1237 1263 opObj12.addParameter(name='n', value='10', format='int')
1238 1264
1239 1265 procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId())
1240 1266 procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int')
1241 1267 # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='')
1242 1268
1243 1269
1244 1270 opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
1245 1271 opObj11.addParameter(name='idfigure', value='1', format='int')
1246 1272 opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str')
1247 1273 opObj11.addParameter(name='zmin', value='40', format='int')
1248 1274 opObj11.addParameter(name='zmax', value='90', format='int')
1249 1275 opObj11.addParameter(name='showprofile', value='1', format='int')
1250 1276
1251 1277 print "Escribiendo el archivo XML"
1252 1278
1253 1279 controllerObj.writeXml(filename)
1254 1280
1255 1281 print "Leyendo el archivo XML"
1256 1282 controllerObj.readXml(filename)
1257 1283 #controllerObj.printattr()
1258 1284
1259 1285 controllerObj.createObjects()
1260 1286 controllerObj.connectObjects()
1261 1287 controllerObj.run()
1262 1288
1263 1289 No newline at end of file
@@ -1,141 +1,140
1 1 import threading
2 2
3 3 from schainpy.controller import Project
4 4
5 5 class ControllerThread(threading.Thread, Project):
6 6
7 def __init__(self, filename=None, plotter_queue=None):
7 def __init__(self, plotter_queue=None):
8 8
9 9 threading.Thread.__init__(self)
10 Project.__init__(self, filename, plotter_queue)
10 Project.__init__(self, plotter_queue)
11 11
12 12 self.setDaemon(True)
13 13
14 14 self.lock = threading.Lock()
15 15 self.control = {'stop':False, 'pause':False}
16 16
17 17 def __del__(self):
18 18
19 19 self.control['stop'] = True
20 20
21 21 def stop(self):
22 22
23 23 self.lock.acquire()
24 24
25 25 self.control['stop'] = True
26 26
27 27 self.lock.release()
28 28
29 29 def pause(self):
30 30
31 31 self.lock.acquire()
32 32
33 33 self.control['pause'] = not(self.control['pause'])
34 34 paused = self.control['pause']
35 35
36 36 self.lock.release()
37 37
38 38 return paused
39 39
40 40 def isPaused(self):
41 41
42 42 self.lock.acquire()
43 43 paused = self.control['pause']
44 44 self.lock.release()
45 45
46 46 return paused
47 47
48 48 def isStopped(self):
49 49
50 50 self.lock.acquire()
51 51 stopped = self.control['stop']
52 52 self.lock.release()
53 53
54 54 return stopped
55 55
56 56 def run(self):
57 57 self.control['stop'] = False
58 58 self.control['pause'] = False
59 59
60 if not self.writeXml(self.filename):
61 return
60 self.writeXml()
62 61
63 62 self.createObjects()
64 63 self.connectObjects()
65 64 Project.run(self)
66 65
67 66 def isRunning(self):
68 67
69 68 return self.is_alive()
70 69
71 70 def isFinished(self):
72 71
73 72 return not self.is_alive()
74 73
75 74 # from PyQt4 import QtCore
76 75 # from PyQt4.QtCore import SIGNAL
77 76 #
78 77 # class ControllerQThread(QtCore.QThread, Project):
79 78 #
80 79 # def __init__(self, filename):
81 80 #
82 81 # QtCore.QThread.__init__(self)
83 82 # Project.__init__(self)
84 83 #
85 84 # self.filename = filename
86 85 #
87 86 # self.lock = threading.Lock()
88 87 # self.control = {'stop':False, 'pause':False}
89 88 #
90 89 # def __del__(self):
91 90 #
92 91 # self.control['stop'] = True
93 92 # self.wait()
94 93 #
95 94 # def stop(self):
96 95 #
97 96 # self.lock.acquire()
98 97 #
99 98 # self.control['stop'] = True
100 99 #
101 100 # self.lock.release()
102 101 #
103 102 # def pause(self):
104 103 #
105 104 # self.lock.acquire()
106 105 #
107 106 # self.control['pause'] = not(self.control['pause'])
108 107 # paused = self.control['pause']
109 108 #
110 109 # self.lock.release()
111 110 #
112 111 # return paused
113 112 #
114 113 # def isPaused(self):
115 114 #
116 115 # self.lock.acquire()
117 116 # paused = self.control['pause']
118 117 # self.lock.release()
119 118 #
120 119 # return paused
121 120 #
122 121 # def isStopped(self):
123 122 #
124 123 # self.lock.acquire()
125 124 # stopped = self.control['stop']
126 125 # self.lock.release()
127 126 #
128 127 # return stopped
129 128 #
130 129 # def run(self):
131 130 #
132 131 # self.control['stop'] = False
133 132 # self.control['pause'] = False
134 133 #
135 134 # self.readXml(self.filename)
136 135 # self.createObjects()
137 136 # self.connectObjects()
138 137 # self.emit( SIGNAL( "jobStarted( PyQt_PyObject )" ), 1)
139 138 # Project.run(self)
140 139 # self.emit( SIGNAL( "jobFinished( PyQt_PyObject )" ), 1)
141 140 # No newline at end of file
@@ -1,5868 +1,5898
1 1 # -*- coding: utf-8 -*-
2 2 """
3 3 Module implementing MainWindow.
4 4 #+++++++++++++GUI V1++++++++++++++#
5 5 @author: AlexanderValdezPortocarrero
6 6
7 7 #+++++++++++++GUI V2++++++++++++++#
8 8 @author Miguel Urco
9 9 """
10 10 import os, sys
11 11 import datetime
12 12 import numpy
13 13 import ast
14 14
15 15 from Queue import Queue
16 16
17 17 from collections import OrderedDict
18 18 from os.path import expanduser
19 19 from time import sleep
20 20
21 21 from PyQt4.QtGui import QMainWindow
22 22 from PyQt4.QtCore import pyqtSignature
23 23 from PyQt4.QtCore import pyqtSignal
24 24 from PyQt4 import QtCore
25 25 from PyQt4 import QtGui
26 # from PyQt4.QtCore import QThread
27 # from PyQt4.QtCore import QObject, SIGNAL
26
27 from propertiesViewModel import TreeModel, PropertyBuffer
28 from parametersModel import ProjectParms
28 29
29 30 from schainpy.gui.viewer.ui_unitprocess import Ui_UnitProcess
30 31 from schainpy.gui.viewer.ui_ftp import Ui_Ftp
31 32 from schainpy.gui.viewer.ui_mainwindow import Ui_BasicWindow
32 33
33 34 from schainpy.controller_api import ControllerThread
34 35 from schainpy.controller import Project
35 36
36 from propertiesViewModel import TreeModel, PropertyBuffer
37 from parametersModel import ProjectParms
38
37 from schainpy.model.graphics.jroplotter import PlotManager
39 38 from schainpy.gui.figures import tools
40 39
41 40 FIGURES_PATH = tools.get_path()
42 41 TEMPORAL_FILE = ".temp.xml"
43 42
44 43 def isRadarFile(file):
45 44 try:
46 45 year = int(file[1:5])
47 46 doy = int(file[5:8])
48 47 set = int(file[8:11])
49 48 except:
50 49 return 0
51 50
52 51 return 1
53 52
54 53 def isRadarPath(path):
55 54 try:
56 55 year = int(path[1:5])
57 56 doy = int(path[5:8])
58 57 except:
59 58 return 0
60 59
61 60 return 1
62 61
63 62 def isInt(value):
64 63
65 64 try:
66 65 int(value)
67 66 except:
68 67 return 0
69 68
70 69 return 1
71 70
72 71 def isFloat(value):
73 72
74 73 try:
75 74 float(value)
76 75 except:
77 76 return 0
78 77
79 78 return 1
80 79
81 80 def isList(value):
82 81
83 82 x = ast.literal_eval(value)
84 83
85 84 if type(x) in (tuple, list):
86 85 return 1
87 86
88 87 return 0
89 88
90 89 class BasicWindow(QMainWindow, Ui_BasicWindow):
91 90 """
92 91 """
93 92 def __init__(self, parent=None):
94 93 """
95 94
96 95 """
97 96 QMainWindow.__init__(self, parent)
98 97 self.setupUi(self)
99 98 self.__puObjDict = {}
100 99 self.__itemTreeDict = {}
101 100 self.readUnitConfObjList = []
102 101 self.operObjList = []
103 102 self.projecObjView = None
104 103 self.idProject = 0
105 104 # self.idImag = 0
106 105
107 106 self.idImagscope = 0
108 107 self.idImagspectra = 0
109 108 self.idImagcross = 0
110 109 self.idImagrti = 0
111 110 self.idImagcoherence = 0
112 111 self.idImagpower = 0
113 112 self.idImagrtinoise = 0
114 113 self.idImagspectraHeis = 0
115 114 self.idImagrtiHeis = 0
116 115
117 116 self.dataPath = None
118 117 self.online = 0
119 118 self.walk = 0
120 119 self.create = False
121 120 self.selectedItemTree = None
122 121 self.controllerThread = None
123 122 # self.commCtrlPThread = None
124 123 # self.create_figure()
125 124 self.temporalFTP = ftpBuffer()
126 125 self.projectProperCaracteristica = []
127 126 self.projectProperPrincipal = []
128 127 self.projectProperDescripcion = []
129 128 self.volProperCaracteristica = []
130 129 self.volProperPrincipal = []
131 130 self.volProperDescripcion = []
132 131 self.specProperCaracteristica = []
133 132 self.specProperPrincipal = []
134 133 self.specProperDescripcion = []
135 134
136 135 self.specHeisProperCaracteristica = []
137 136 self.specHeisProperPrincipal = []
138 137 self.specHeisProperDescripcion = []
139 138
140 139 # self.pathWorkSpace = './'
141 140
142 141 self.__projectObjDict = {}
143 142 self.__operationObjDict = {}
144 143
145 144 self.__puLocalFolder2FTP = {}
146 145 self.threadStarted = False
147 146
147 self.plotManager = None
148
148 149 # self.create_comm()
149 150 self.create_updating_timer()
150 151 self.setGUIStatus()
151 152
152 153 @pyqtSignature("")
153 154 def on_actionOpen_triggered(self):
154 155 """
155 156 Slot documentation goes here.
156 157 """
157 158 self.openProject()
158 159
159 160 @pyqtSignature("")
160 161 def on_actionCreate_triggered(self):
161 162 """
162 163 Slot documentation goes here.
163 164 """
164 165 self.setInputsProject_View()
165 166 self.create = True
166 167
167 168 @pyqtSignature("")
168 169 def on_actionSave_triggered(self):
169 170 """
170 171 Slot documentation goes here.
171 172 """
172 173 self.saveProject()
173 174
174 175 @pyqtSignature("")
175 176 def on_actionClose_triggered(self):
176 177 """
177 178 Slot documentation goes here.
178 179 """
179 180 self.close()
180 181
181 182 @pyqtSignature("")
182 183 def on_actionStart_triggered(self):
183 184 """
184 185 """
185 186 self.playProject()
186 187
187 188 @pyqtSignature("")
188 189 def on_actionPause_triggered(self):
189 190 """
190 191 """
191 192 self.pauseProject()
192 193
193 194 @pyqtSignature("")
194 195 def on_actionStop_triggered(self):
195 196 """
196 197 """
197 198 self.stopProject()
198 199
199 200 @pyqtSignature("")
200 201 def on_actionAbout_triggered(self):
201 202 """
202 203 """
203 204 self.aboutEvent()
204 205
205 206 @pyqtSignature("")
206 207 def on_actionFTP_triggered(self):
207 208 """
208 209 """
209 210 self.configFTPWindowObj = Ftp(self)
210 211
211 212 if not self.temporalFTP.create:
212 213 self.temporalFTP.setwithoutconfiguration()
213 214
214 215 self.configFTPWindowObj.setParmsfromTemporal(self.temporalFTP.server,
215 216 self.temporalFTP.remotefolder,
216 217 self.temporalFTP.username,
217 218 self.temporalFTP.password,
218 219 self.temporalFTP.ftp_wei,
219 220 self.temporalFTP.exp_code,
220 221 self.temporalFTP.sub_exp_code,
221 222 self.temporalFTP.plot_pos)
222 223
223 224 self.configFTPWindowObj.show()
224 225 self.configFTPWindowObj.closed.connect(self.createFTPConfig)
225 226
226 227 def createFTPConfig(self):
227 228
228 229 if not self.configFTPWindowObj.create:
229 230 self.console.clear()
230 231 self.console.append("There is no FTP configuration")
231 232 return
232 233
233 234 self.console.append("Push Ok in Spectra view to Add FTP Configuration")
234 235
235 236 server, remotefolder, username, password, ftp_wei, exp_code, sub_exp_code, plot_pos = self.configFTPWindowObj.getParmsFromFtpWindow()
236 237 self.temporalFTP.save(server=server,
237 238 remotefolder=remotefolder,
238 239 username=username,
239 240 password=password,
240 241 ftp_wei=ftp_wei,
241 242 exp_code=exp_code,
242 243 sub_exp_code=sub_exp_code,
243 244 plot_pos=plot_pos)
244 245
245 246 @pyqtSignature("")
246 247 def on_actionOpenToolbar_triggered(self):
247 248 """
248 249 Slot documentation goes here.
249 250 """
250 251 self.openProject()
251 252
252 253 @pyqtSignature("")
253 254 def on_actionCreateToolbar_triggered(self):
254 255 """
255 256 Slot documentation goes here.
256 257 """
257 258 self.setInputsProject_View()
258 259 self.create = True
259 260
260 261 @pyqtSignature("")
261 262 def on_actionAddPU_triggered(self):
262 263
263 264 if len(self.__projectObjDict) == 0:
264 265 outputstr = "First create a Project before add any Processing Unit"
265 266 self.console.clear()
266 267 self.console.append(outputstr)
267 268 return
268 269 else:
269 270 self.addPUWindow()
270 271 self.console.clear()
271 272 self.console.append("Please, Choose the type of Processing Unit")
272 273 # self.console.append("If your Datatype is rawdata, you will start with processing unit Type Voltage")
273 274 # self.console.append("If your Datatype is pdata, you will choose between processing unit Type Spectra or Correlation")
274 275 # self.console.append("If your Datatype is fits, you will start with processing unit Type SpectraHeis")
275 276
276 277
277 278 @pyqtSignature("")
278 279 def on_actionSaveToolbar_triggered(self):
279 280 """
280 281 Slot documentation goes here.
281 282 """
282 283 self.saveProject()
283 284
284 285 @pyqtSignature("")
285 286 def on_actionStarToolbar_triggered(self):
286 287 """
287 288 Slot documentation goes here.
288 289 """
289 290 self.playProject()
290 291
291 292 @pyqtSignature("")
292 293 def on_actionPauseToolbar_triggered(self):
293 294
294 295 self.pauseProject()
295 296
296 297 @pyqtSignature("")
297 298 def on_actionStopToolbar_triggered(self):
298 299 """
299 300 Slot documentation goes here.
300 301 """
301 302 self.stopProject()
302 303
303 304 @pyqtSignature("int")
304 305 def on_proComReadMode_activated(self, index):
305 306 """
306 307 SELECCION DEL MODO DE LECTURA ON=1, OFF=0
307 308 """
308 309 if index == 0:
309 310 self.online = 0
310 311 self.proDelay.setText("0")
311 312 self.proSet.setText("")
312 313 self.proSet.setEnabled(False)
313 314 self.proDelay.setEnabled(False)
314 315 elif index == 1:
315 316 self.online = 1
316 317 self.proSet.setText("")
317 318 self.proDelay.setText("5")
318 319 self.proSet.setEnabled(True)
319 320 self.proDelay.setEnabled(True)
320 321
321 322 @pyqtSignature("int")
322 323 def on_proComDataType_activated(self, index):
323 324 """
324 325 Voltage or Spectra
325 326 """
326 327 self.labelSet.show()
327 328 self.proSet.show()
328 329
329 330 self.labExpLabel.show()
330 331 self.proExpLabel.show()
331 332
332 333 self.labelIPPKm.hide()
333 334 self.proIPPKm.hide()
334 335
335 336 if index == 0:
336 337 extension = '.r'
337 338 elif index == 1:
338 339 extension = '.pdata'
339 340 elif index == 2:
340 341 extension = '.fits'
341 342 elif index == 3:
342 343 extension = '.hdf5'
343 344
344 345 self.labelIPPKm.show()
345 346 self.proIPPKm.show()
346 347
347 348 self.labelSet.hide()
348 349 self.proSet.hide()
349 350
350 351 self.labExpLabel.hide()
351 352 self.proExpLabel.hide()
352 353
353 354 self.proDataType.setText(extension)
354 355
355 356 @pyqtSignature("int")
356 357 def on_proComWalk_activated(self, index):
357 358 """
358 359
359 360 """
360 361 if index == 0:
361 362 self.walk = 0
362 363 elif index == 1:
363 364 self.walk = 1
364 365
365 366 @pyqtSignature("")
366 367 def on_proToolPath_clicked(self):
367 368 """
368 369 Choose your path
369 370 """
370 371
371 372 current_dpath = './'
372 373 if self.dataPath:
373 374 current_dpath = self.dataPath
374 375
375 376 datapath = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', current_dpath, QtGui.QFileDialog.ShowDirsOnly))
376 377
377 378 #If it was canceled
378 379 if not datapath:
379 380 return
380 381
381 382 #If any change was done
382 383 if datapath == self.dataPath:
383 384 return
384 385
385 386 self.proDataPath.setText(datapath)
386 387
387 388 self._disable_play_button()
388 389 self._disable_save_button()
389 390 self.proOk.setEnabled(False)
390 391
391 392 self.proComStartDate.clear()
392 393 self.proComEndDate.clear()
393 394
394 395 if not os.path.exists(datapath):
395 396
396 397 self.console.clear()
397 398 self.console.append("Write a valid path")
398 399 return
399 400
400 401 self.dataPath = datapath
401 402
402 403 self.console.clear()
403 404 self.console.append("Select the read mode and press 'load button'")
404 405
405 406
406 407 @pyqtSignature("")
407 408 def on_proLoadButton_clicked(self):
408 409
409 410 self.console.clear()
410 411
411 412 parameter_list = self.checkInputsProject()
412 413
413 414 parms_ok, project_name, datatype, ext, data_path, read_mode, delay, walk, set, expLabel = parameter_list
414 415
415 416 if read_mode == "Offline":
416 417 self.proComStartDate.clear()
417 418 self.proComEndDate.clear()
418 419 self.proComStartDate.setEnabled(True)
419 420 self.proComEndDate.setEnabled(True)
420 421 self.proStartTime.setEnabled(True)
421 422 self.proEndTime.setEnabled(True)
422 423 self.frame_2.setEnabled(True)
423 424
424 425 if read_mode == "Online":
425 426 self.proComStartDate.addItem("1960/01/30")
426 427 self.proComEndDate.addItem("2018/12/31")
427 428 self.proComStartDate.setEnabled(False)
428 429 self.proComEndDate.setEnabled(False)
429 430 self.proStartTime.setEnabled(False)
430 431 self.proEndTime.setEnabled(False)
431 432 self.frame_2.setEnabled(True)
432 433
433 434 if self.loadDays(data_path, ext, walk, expLabel) == []:
434 435 self._disable_save_button()
435 436 self._disable_play_button()
436 437 self.proOk.setEnabled(False)
437 438 else:
438 439 self._enable_save_button()
439 440 self._enable_play_button()
440 441 self.proOk.setEnabled(True)
441 442
442 443 @pyqtSignature("int")
443 444 def on_proComStartDate_activated(self, index):
444 445 """
445 446 SELECCION DEL RANGO DE FECHAS -START DATE
446 447 """
447 448 stopIndex = self.proComEndDate.count() - self.proComEndDate.currentIndex() - 1
448 449
449 450 self.proComEndDate.clear()
450 451 for i in self.dateList[index:]:
451 452 self.proComEndDate.addItem(i)
452 453
453 454 if self.proComEndDate.count() - stopIndex - 1 >= 0:
454 455 self.proComEndDate.setCurrentIndex(self.proComEndDate.count() - stopIndex - 1)
455 456 else:
456 457 self.proComEndDate.setCurrentIndex(self.proComEndDate.count() - 1)
457 458
458 459 @pyqtSignature("int")
459 460 def on_proComEndDate_activated(self, index):
460 461 """
461 462 SELECCION DEL RANGO DE FECHAS-END DATE
462 463 """
463 464 pass
464 465
465 466 @pyqtSignature("")
466 467 def on_proOk_clicked(self):
467 468 """
468 469 AΓ±ade al Obj XML de Projecto, name,datatype,date,time,readmode,wait,etc, crea el readUnitProcess del archivo xml.
469 470 Prepara la configuraciΓ³n del diΓ‘grama del Arbol del treeView numero 2
470 471 """
471 472
472 473 self._disable_play_button()
473 474 self._disable_save_button()
474 475
475 476 self.console.clear()
476 477
477 478 if self.create:
478 479
479 480 projectId = self.__getNewProjectId()
480 481
481 482 if not projectId:
482 483 return 0
483 484
484 485 projectObjView = self.createProjectView(projectId)
485 486
486 487 if not projectObjView:
487 488 return 0
488 489
489 490 self.create = False
490 491
491 492 readUnitObj = self.createReadUnitView(projectObjView)
492 493
493 494 if not readUnitObj:
494 495 return 0
495 496
496 497 else:
497 498 projectObjView = self.updateProjectView()
498 499
499 500 if not projectObjView:
500 501 return 0
501 502
502 503 projectId = projectObjView.getId()
503 504 idReadUnit = projectObjView.getReadUnitId()
504 505 readUnitObj = self.updateReadUnitView(projectObjView, idReadUnit)
505 506
506 507 if not readUnitObj:
507 508 return 0
508 509
509 510 self.__itemTreeDict[projectId].setText(projectObjView.name)
510 511 # Project Properties
511 512 self.refreshProjectProperties(projectObjView)
512 513 # Disable tabProject after finish the creation
513 514
514 515 self._enable_play_button()
515 516 self._enable_save_button()
516 517
517 518 self.console.clear()
518 519 self.console.append("The project parameters were validated")
519 520
520 521 return 1
521 522
522 523 @pyqtSignature("")
523 524 def on_proClear_clicked(self):
524 525
525 526 self.console.clear()
526 527
527 528 @pyqtSignature("int")
528 529 def on_volOpCebChannels_stateChanged(self, p0):
529 530 """
530 531 Check Box habilita operaciones de SelecciοΏ½n de Canales
531 532 """
532 533 if p0 == 2:
533 534 self.volOpComChannels.setEnabled(True)
534 535 self.volOpChannel.setEnabled(True)
535 536
536 537 if p0 == 0:
537 538 self.volOpComChannels.setEnabled(False)
538 539 self.volOpChannel.setEnabled(False)
539 540 self.volOpChannel.clear()
540 541
541 542 @pyqtSignature("int")
542 543 def on_volOpCebHeights_stateChanged(self, p0):
543 544 """
544 545 Check Box habilita operaciones de SelecciοΏ½n de Alturas
545 546 """
546 547 if p0 == 2:
547 548 self.volOpHeights.setEnabled(True)
548 549 self.volOpComHeights.setEnabled(True)
549 550
550 551 if p0 == 0:
551 552 self.volOpHeights.setEnabled(False)
552 553 self.volOpHeights.clear()
553 554 self.volOpComHeights.setEnabled(False)
554 555
555 556 @pyqtSignature("int")
556 557 def on_volOpCebFilter_stateChanged(self, p0):
557 558 """
558 559 Name='Decoder', optype='other'
559 560 """
560 561 if p0 == 2:
561 562 self.volOpFilter.setEnabled(True)
562 563
563 564 if p0 == 0:
564 565 self.volOpFilter.setEnabled(False)
565 566 self.volOpFilter.clear()
566 567
567 568 @pyqtSignature("int")
568 569 def on_volOpCebProfile_stateChanged(self, p0):
569 570 """
570 571 Check Box habilita ingreso del rango de Perfiles
571 572 """
572 573 if p0 == 2:
573 574 self.volOpComProfile.setEnabled(True)
574 575 self.volOpProfile.setEnabled(True)
575 576
576 577 if p0 == 0:
577 578 self.volOpComProfile.setEnabled(False)
578 579 self.volOpProfile.setEnabled(False)
579 580 self.volOpProfile.clear()
580 581
581 582 @pyqtSignature("int")
582 583 def on_volOpComProfile_activated(self, index):
583 584 """
584 585 Check Box habilita ingreso del rango de Perfiles
585 586 """
586 587 #Profile List
587 588 if index == 0:
588 589 self.volOpProfile.setToolTip('List of selected profiles. Example: 0, 1, 2, 3, 4, 5, 6, 7')
589 590
590 591 #Profile Range
591 592 if index == 1:
592 593 self.volOpProfile.setToolTip('Minimum and maximum profile index. Example: 0, 7')
593 594
594 595 #Profile Range List
595 596 if index == 2:
596 597 self.volOpProfile.setToolTip('List of profile ranges. Example: (0, 7), (12, 19), (100, 200)')
597 598
598 599 @pyqtSignature("int")
599 600 def on_volOpCebDecodification_stateChanged(self, p0):
600 601 """
601 602 Check Box habilita
602 603 """
603 604 if p0 == 2:
604 605 self.volOpComCode.setEnabled(True)
605 606 self.volOpComMode.setEnabled(True)
606 607 if p0 == 0:
607 608 self.volOpComCode.setEnabled(False)
608 609 self.volOpComMode.setEnabled(False)
609 610
610 611 @pyqtSignature("int")
611 612 def on_volOpComCode_activated(self, index):
612 613 """
613 614 Check Box habilita ingreso
614 615 """
615 616 if index == 13:
616 617 self.volOpCode.setEnabled(True)
617 618 else:
618 619 self.volOpCode.setEnabled(False)
619 620
620 621 if index == 0:
621 622 code = ''
622 623 self.volOpCode.setText(str(code))
623 624 return
624 625
625 626 if index == 1:
626 627 code = '(1,1,-1)'
627 628 nCode = '1'
628 629 nBaud = '3'
629 630 if index == 2:
630 631 code = '(1,1,-1,1)'
631 632 nCode = '1'
632 633 nBaud = '4'
633 634 if index == 3:
634 635 code = '(1,1,1,-1,1)'
635 636 nCode = '1'
636 637 nBaud = '5'
637 638 if index == 4:
638 639 code = '(1,1,1,-1,-1,1,-1)'
639 640 nCode = '1'
640 641 nBaud = '7'
641 642 if index == 5:
642 643 code = '(1,1,1,-1,-1,-1,1,-1,-1,1,-1)'
643 644 nCode = '1'
644 645 nBaud = '11'
645 646 if index == 6:
646 647 code = '(1,1,1,1,1,-1,-1,1,1,-1,1,-1,1)'
647 648 nCode = '1'
648 649 nBaud = '13'
649 650 if index == 7:
650 651 code = '(1,1,-1,-1,-1,1)'
651 652 nCode = '2'
652 653 nBaud = '3'
653 654 if index == 8:
654 655 code = '(1,1,-1,1,-1,-1,1,-1)'
655 656 nCode = '2'
656 657 nBaud = '4'
657 658 if index == 9:
658 659 code = '(1,1,1,-1,1,-1,-1,-1,1,-1)'
659 660 nCode = '2'
660 661 nBaud = '5'
661 662 if index == 10:
662 663 code = '(1,1,1,-1,-1,1,-1,-1,-1,-1,1,1,-1,1)'
663 664 nCode = '2'
664 665 nBaud = '7'
665 666 if index == 11:
666 667 code = '(1,1,1,-1,-1,-1,1,-1,-1,1,-1,-1 ,-1 ,-1 ,1 ,1,1,-1 ,1 ,1 ,-1 ,1)'
667 668 nCode = '2'
668 669 nBaud = '11'
669 670 if index == 12:
670 671 code = '(1,1,1,1,1,-1,-1,1,1,-1,1,-1,1,-1,-1,-1,-1,-1,1,1,-1,-1,1,-1,1,-1)'
671 672 nCode = '2'
672 673 nBaud = '13'
673 674
674 675 code = ast.literal_eval(code)
675 676 nCode = int(nCode)
676 677 nBaud = int(nBaud)
677 678
678 679 code = numpy.asarray(code).reshape((nCode, nBaud)).tolist()
679 680
680 681 self.volOpCode.setText(str(code))
681 682
682 683 @pyqtSignature("int")
683 684 def on_volOpCebFlip_stateChanged(self, p0):
684 685 """
685 686 Check Box habilita ingresode del numero de Integraciones a realizar
686 687 """
687 688 if p0 == 2:
688 689 self.volOpFlip.setEnabled(True)
689 690 if p0 == 0:
690 691 self.volOpFlip.setEnabled(False)
691 692 self.volOpFlip.clear()
692 693
693 694 @pyqtSignature("int")
694 695 def on_volOpCebCohInt_stateChanged(self, p0):
695 696 """
696 697 Check Box habilita ingresode del numero de Integraciones a realizar
697 698 """
698 699 if p0 == 2:
699 700 self.volOpCohInt.setEnabled(True)
700 701 if p0 == 0:
701 702 self.volOpCohInt.setEnabled(False)
702 703 self.volOpCohInt.clear()
703 704
704 705 @pyqtSignature("int")
705 706 def on_volOpCebRadarfrequency_stateChanged(self, p0):
706 707 """
707 708 Check Box habilita ingresode del numero de Integraciones a realizar
708 709 """
709 710 if p0 == 2:
710 711 self.volOpRadarfrequency.setEnabled(True)
711 712 if p0 == 0:
712 713 self.volOpRadarfrequency.clear()
713 714 self.volOpRadarfrequency.setEnabled(False)
714 715
715 716 @pyqtSignature("")
716 717 def on_volOutputToolPath_clicked(self):
717 718 dirOutPath = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
718 719 self.volOutputPath.setText(dirOutPath)
719 720
720 721 @pyqtSignature("")
721 722 def on_specOutputToolPath_clicked(self):
722 723 dirOutPath = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
723 724 self.specOutputPath.setText(dirOutPath)
724 725
725 726 @pyqtSignature("")
726 727 def on_specHeisOutputToolPath_clicked(self):
727 728 dirOutPath = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
728 729 self.specHeisOutputPath.setText(dirOutPath)
729 730
730 731 @pyqtSignature("")
731 732 def on_specHeisOutputMetadaToolPath_clicked(self):
732 733
733 734 filename = str(QtGui.QFileDialog.getOpenFileName(self, "Open text file", self.pathWorkSpace, self.tr("Text Files (*.xml)")))
734 735 self.specHeisOutputMetada.setText(filename)
735 736
736 737 @pyqtSignature("")
737 738 def on_volOpOk_clicked(self):
738 739 """
739 740 BUSCA EN LA LISTA DE OPERACIONES DEL TIPO VOLTAJE Y LES AοΏ½ADE EL PARAMETRO ADECUADO ESPERANDO LA ACEPTACION DEL USUARIO
740 741 PARA AGREGARLO AL ARCHIVO DE CONFIGURACION XML
741 742 """
742 743
743 744 checkPath = False
744 745
745 746 self._disable_play_button()
746 747 self._disable_save_button()
747 748
748 749 self.console.clear()
749 750 self.console.append("Checking input parameters ...")
750 751
751 752 puObj = self.getSelectedItemObj()
752 753 puObj.removeOperations()
753 754
754 755 if self.volOpCebRadarfrequency.isChecked():
755 756 value = str(self.volOpRadarfrequency.text())
756 757 format = 'float'
757 758 name_operation = 'setRadarFrequency'
758 759 name_parameter = 'frequency'
759 760 if not value == "":
760 761 try:
761 762 radarfreq = float(self.volOpRadarfrequency.text())*1e6
762 763 except:
763 764 self.console.clear()
764 765 self.console.append("Invalid value '%s' for Radar Frequency" %value)
765 766 return 0
766 767
767 768 opObj = puObj.addOperation(name=name_operation)
768 769 if not opObj.addParameter(name=name_parameter, value=radarfreq, format=format):
769 770 self.console.append("Invalid value '%s' for %s" %(value,name_parameter))
770 771 return 0
771 772
772 773 if self.volOpCebChannels.isChecked():
773 774 value = str(self.volOpChannel.text())
774 775
775 776 if value == "":
776 777 print "Please fill channel list"
777 778 return 0
778 779
779 780 format = 'intlist'
780 781 if self.volOpComChannels.currentIndex() == 0:
781 782 name_operation = "selectChannels"
782 783 name_parameter = 'channelList'
783 784 else:
784 785 name_operation = "selectChannelsByIndex"
785 786 name_parameter = 'channelIndexList'
786 787
787 788 opObj = puObj.addOperation(name=name_operation)
788 789 if not opObj.addParameter(name=name_parameter, value=value, format=format):
789 790 self.console.append("Invalid value '%s' for %s" %(value,name_parameter))
790 791 return 0
791 792
792 793 if self.volOpCebHeights.isChecked():
793 794 value = str(self.volOpHeights.text())
794 795
795 796 if value == "":
796 797 print "Please fill height range"
797 798 return 0
798 799
799 800 valueList = value.split(',')
800 801
801 802 if self.volOpComHeights.currentIndex() == 0:
802 803 format = 'float'
803 804 name_operation = 'selectHeights'
804 805 name_parameter1 = 'minHei'
805 806 name_parameter2 = 'maxHei'
806 807 else:
807 808 format = 'int'
808 809 name_operation = 'selectHeightsByIndex'
809 810 name_parameter1 = 'minIndex'
810 811 name_parameter2 = 'maxIndex'
811 812
812 813 opObj = puObj.addOperation(name=name_operation)
813 814 opObj.addParameter(name=name_parameter1, value=valueList[0], format=format)
814 815 opObj.addParameter(name=name_parameter2, value=valueList[1], format=format)
815 816
816 817 if self.volOpCebFilter.isChecked():
817 818 value = str(self.volOpFilter.text())
818 819 if value == "":
819 820 print "Please fill filter value"
820 821 return 0
821 822
822 823 format = 'int'
823 824 name_operation = 'filterByHeights'
824 825 name_parameter = 'window'
825 826 opObj = puObj.addOperation(name=name_operation)
826 827 if not opObj.addParameter(name=name_parameter, value=value, format=format):
827 828 self.console.append("Invalid value '%s' for %s" %(value,name_parameter))
828 829 return 0
829 830
830 831 if self.volOpCebProfile.isChecked():
831 832 value = str(self.volOpProfile.text())
832 833
833 834 if value == "":
834 835 print "Please fill profile value"
835 836 return 0
836 837
837 838 format = 'intlist'
838 839 optype = 'other'
839 840 name_operation = 'ProfileSelector'
840 841 if self.volOpComProfile.currentIndex() == 0:
841 842 name_parameter = 'profileList'
842 843 if self.volOpComProfile.currentIndex() == 1:
843 844 name_parameter = 'profileRangeList'
844 845 if self.volOpComProfile.currentIndex() == 2:
845 846 name_parameter = 'rangeList'
846 847
847 848 opObj = puObj.addOperation(name='ProfileSelector', optype='other')
848 849 if not opObj.addParameter(name=name_parameter, value=value, format=format):
849 850 self.console.append("Invalid value '%s' for %s" %(value,name_parameter))
850 851 return 0
851 852
852 853 if self.volOpCebDecodification.isChecked():
853 854 name_operation = 'Decoder'
854 855 opObj = puObj.addOperation(name=name_operation, optype='other')
855 856
856 857 #User defined
857 858 nBaud = None
858 859 nCode = None
859 860
860 861 code = str(self.volOpCode.text())
861 862 try:
862 863 code_tmp = ast.literal_eval(code)
863 864 except:
864 865 code_tmp = []
865 866
866 867 if len(code_tmp) > 0:
867 868
868 869 if type(code_tmp) not in (tuple, list):
869 870 self.console.append("Please write a right value for Code (Exmaple: [1,1,-1], [1,-1,1])")
870 871 return 0
871 872
872 873 if len(code_tmp) > 1 and type(code_tmp[0]) in (tuple, list): #[ [1,-1,1], [1,1,-1] ]
873 874 nBaud = len(code_tmp[0])
874 875 nCode = len(code_tmp)
875 876 elif len(code_tmp) == 1 and type(code_tmp[0]) in (tuple, list): #[ [1,-1,1] ]
876 877 nBaud = len(code_tmp[0])
877 878 nCode = 1
878 879 elif type(code_tmp[0]) in (int, float): #[1,-1,1] or (1,-1,1)
879 880 nBaud = len(code_tmp)
880 881 nCode = 1
881 882 else:
882 883 self.console.append("Please write a right value for Code (Exmaple: [1,1,-1], [1,-1,1])")
883 884 return 0
884 885
885 886 if not nBaud or not nCode:
886 887 self.console.append("Please write a right value for Code")
887 888 return 0
888 889
889 890 code = code.replace("(", "")
890 891 code = code.replace(")", "")
891 892 code = code.replace("[", "")
892 893 code = code.replace("]", "")
893 894
894 895 if not opObj.addParameter(name='code', value=code, format='intlist'):
895 896 self.console.append("Please write a right value for Code")
896 897 return 0
897 898 if not opObj.addParameter(name='nCode', value=nCode, format='int'):
898 899 self.console.append("Please write a right value for Code")
899 900 return 0
900 901 if not opObj.addParameter(name='nBaud', value=nBaud, format='int'):
901 902 self.console.append("Please write a right value for Code")
902 903 return 0
903 904
904 905 name_parameter = 'mode'
905 906 format = 'int'
906 907
907 908 value = str(self.volOpComMode.currentIndex())
908 909
909 910 if not opObj.addParameter(name=name_parameter, value=value, format=format):
910 911 self.console.append("Invalid value '%s' for '%s'" %(value,name_parameter))
911 912 return 0
912 913
913 914
914 915 if self.volOpCebFlip.isChecked():
915 916 name_operation = 'deFlip'
916 917 optype = 'self'
917 918
918 919 opObj = puObj.addOperation(name=name_operation, optype=optype)
919 920
920 921 name_parameter = 'channelList'
921 922 format = 'intlist'
922 923 value = str(self.volOpFlip.text())
923 924
924 925 if value != "":
925 926 if not opObj.addParameter(name=name_parameter, value=value, format=format):
926 927 self.console.append("Invalid value '%s' for '%s'" %(value,name_parameter))
927 928 return 0
928 929
929 930 if self.volOpCebCohInt.isChecked():
930 931 name_operation = 'CohInt'
931 932 optype = 'other'
932 933 value = str(self.volOpCohInt.text())
933 934
934 935 if value == "":
935 936 print "Please fill number of coherent integrations"
936 937 return 0
937 938
938 939 name_parameter = 'n'
939 940 format = 'int'
940 941
941 942 opObj = puObj.addOperation(name=name_operation, optype=optype)
942 943
943 944 if not opObj.addParameter(name=name_parameter, value=value, format=format):
944 945 self.console.append("Invalid value '%s' for '%s'" %(value,name_parameter))
945 946 return 0
946 947
947 948 if self.volGraphCebshow.isChecked():
948 949 name_operation = 'Scope'
949 950 optype = 'other'
950 951 name_parameter = 'type'
951 952 value = 'Scope'
952 953 if self.idImagscope == 0:
953 954 self.idImagscope = 100
954 955 else:
955 956 self.idImagscope = self.idImagscope + 1
956 957
957 958 name_parameter1 = 'id'
958 959 value1 = int(self.idImagscope)
959 960 format1 = 'int'
960 961 format = 'str'
961 962
962 963 opObj = puObj.addOperation(name=name_operation, optype=optype)
963 964 # opObj.addParameter(name=name_parameter, value=value, format=format)
964 965 opObj.addParameter(name=name_parameter1, value=opObj.id, format=format1)
965 966
966 967 channelList = str(self.volGraphChannelList.text()).replace(" ","")
967 968 xvalue = str(self.volGraphfreqrange.text()).replace(" ","")
968 969 yvalue = str(self.volGraphHeightrange.text()).replace(" ","")
969 970
970 971 if channelList:
971 972 opObj.addParameter(name='channelList', value=channelList, format='intlist')
972 973
973 974 if xvalue:
974 975 xvalueList = xvalue.split(',')
975 976 try:
976 977 value0 = float(xvalueList[0])
977 978 value1 = float(xvalueList[1])
978 979 except:
979 980 return 0
980 981 opObj.addParameter(name='xmin', value=value0, format='float')
981 982 opObj.addParameter(name='xmax', value=value1, format='float')
982 983
983 984
984 985 if not yvalue == "":
985 986 yvalueList = yvalue.split(",")
986 987 try:
987 988 value0 = int(yvalueList[0])
988 989 value1 = int(yvalueList[1])
989 990 except:
990 991 return 0
991 992
992 993 opObj.addParameter(name='ymin', value=value0, format='int')
993 994 opObj.addParameter(name='ymax', value=value1, format='int')
994 995
995 996 if self.volGraphCebSave.isChecked():
996 997 checkPath = True
997 998 opObj.addParameter(name='save', value='1', format='int')
998 999 opObj.addParameter(name='figpath', value=str(self.volGraphPath.text()), format='str')
999 1000 value = str(self.volGraphPrefix.text()).replace(" ","")
1000 1001 if value:
1001 1002 opObj.addParameter(name='figfile', value=value, format='str')
1002 1003
1003 1004 localfolder = None
1004 1005 if checkPath:
1005 1006 localfolder = str(self.volGraphPath.text())
1006 1007 if localfolder == '':
1007 1008 self.console.clear()
1008 1009 self.console.append("Graphic path should be defined")
1009 1010 return 0
1010 1011
1011 1012 # if something happend
1012 1013 parms_ok, output_path, blocksperfile, profilesperblock = self.checkInputsPUSave(datatype='Voltage')
1013 1014 if parms_ok:
1014 1015 name_operation = 'VoltageWriter'
1015 1016 optype = 'other'
1016 1017 name_parameter1 = 'path'
1017 1018 name_parameter2 = 'blocksPerFile'
1018 1019 name_parameter3 = 'profilesPerBlock'
1019 1020 value1 = output_path
1020 1021 value2 = blocksperfile
1021 1022 value3 = profilesperblock
1022 1023 format = "int"
1023 1024 opObj = puObj.addOperation(name=name_operation, optype=optype)
1024 1025 opObj.addParameter(name=name_parameter1, value=value1)
1025 1026 opObj.addParameter(name=name_parameter2, value=value2, format=format)
1026 1027 opObj.addParameter(name=name_parameter3, value=value3, format=format)
1027 1028
1028 1029 self.console.clear()
1029 1030 try:
1030 1031 self.refreshPUProperties(puObj)
1031 1032 except:
1032 1033 self.console.append("An error reading input parameters was found ...Check them!")
1033 1034 return 0
1034 1035
1035 1036 self.console.append("Save your project and press Play button to start signal processing")
1036 1037
1037 1038 self._enable_play_button()
1038 1039 self._enable_save_button()
1039 1040
1040 1041 return 1
1041 1042
1042 1043 """
1043 1044 Voltage Graph
1044 1045 """
1045 1046 @pyqtSignature("int")
1046 1047 def on_volGraphCebSave_stateChanged(self, p0):
1047 1048 """
1048 1049 Check Box habilita ingresode del numero de Integraciones a realizar
1049 1050 """
1050 1051 if p0 == 2:
1051 1052 self.volGraphPath.setEnabled(True)
1052 1053 self.volGraphPrefix.setEnabled(True)
1053 1054 self.volGraphToolPath.setEnabled(True)
1054 1055
1055 1056 if p0 == 0:
1056 1057 self.volGraphPath.setEnabled(False)
1057 1058 self.volGraphPrefix.setEnabled(False)
1058 1059 self.volGraphToolPath.setEnabled(False)
1059 1060
1060 1061 @pyqtSignature("")
1061 1062 def on_volGraphToolPath_clicked(self):
1062 1063 """
1063 1064 Donde se guardan los DATOS
1064 1065 """
1065 1066 save_path = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
1066 1067 self.volGraphPath.setText(save_path)
1067 1068
1068 1069 if not os.path.exists(save_path):
1069 1070 self.console.clear()
1070 1071 self.console.append("Set a valid path")
1071 1072 self.volGraphOk.setEnabled(False)
1072 1073 return
1073 1074
1074 1075 @pyqtSignature("int")
1075 1076 def on_volGraphCebshow_stateChanged(self, p0):
1076 1077 """
1077 1078 Check Box habilita ingresode del numero de Integraciones a realizar
1078 1079 """
1079 1080 if p0 == 0:
1080 1081
1081 1082 self.volGraphChannelList.setEnabled(False)
1082 1083 self.volGraphfreqrange.setEnabled(False)
1083 1084 self.volGraphHeightrange.setEnabled(False)
1084 1085 if p0 == 2:
1085 1086
1086 1087 self.volGraphChannelList.setEnabled(True)
1087 1088 self.volGraphfreqrange.setEnabled(True)
1088 1089 self.volGraphHeightrange.setEnabled(True)
1089 1090
1090 1091 """
1091 1092 Spectra operation
1092 1093 """
1093 1094 @pyqtSignature("int")
1094 1095 def on_specOpCebRadarfrequency_stateChanged(self, p0):
1095 1096 """
1096 1097 Check Box habilita ingresode del numero de Integraciones a realizar
1097 1098 """
1098 1099 if p0 == 2:
1099 1100 self.specOpRadarfrequency.setEnabled(True)
1100 1101 if p0 == 0:
1101 1102 self.specOpRadarfrequency.clear()
1102 1103 self.specOpRadarfrequency.setEnabled(False)
1103 1104
1104 1105
1105 1106 @pyqtSignature("int")
1106 1107 def on_specOpCebCrossSpectra_stateChanged(self, p0):
1107 1108 """
1108 1109 Habilita la opcion de aοΏ½adir el parοΏ½metro CrossSpectra a la Unidad de Procesamiento .
1109 1110 """
1110 1111 if p0 == 2:
1111 1112 # self.specOpnFFTpoints.setEnabled(True)
1112 1113 self.specOppairsList.setEnabled(True)
1113 1114 if p0 == 0:
1114 1115 # self.specOpnFFTpoints.setEnabled(False)
1115 1116 self.specOppairsList.setEnabled(False)
1116 1117
1117 1118 @pyqtSignature("int")
1118 1119 def on_specOpCebChannel_stateChanged(self, p0):
1119 1120 """
1120 1121 Habilita la opcion de aοΏ½adir el parοΏ½metro numero de Canales a la Unidad de Procesamiento .
1121 1122 """
1122 1123 if p0 == 2:
1123 1124 self.specOpChannel.setEnabled(True)
1124 1125 self.specOpComChannel.setEnabled(True)
1125 1126 if p0 == 0:
1126 1127 self.specOpChannel.setEnabled(False)
1127 1128 self.specOpComChannel.setEnabled(False)
1128 1129
1129 1130 @pyqtSignature("int")
1130 1131 def on_specOpCebHeights_stateChanged(self, p0):
1131 1132 """
1132 1133 Habilita la opcion de aοΏ½adir el parοΏ½metro de alturas a la Unidad de Procesamiento .
1133 1134 """
1134 1135 if p0 == 2:
1135 1136 self.specOpComHeights.setEnabled(True)
1136 1137 self.specOpHeights.setEnabled(True)
1137 1138 if p0 == 0:
1138 1139 self.specOpComHeights.setEnabled(False)
1139 1140 self.specOpHeights.setEnabled(False)
1140 1141
1141 1142
1142 1143 @pyqtSignature("int")
1143 1144 def on_specOpCebIncoherent_stateChanged(self, p0):
1144 1145 """
1145 1146 Habilita la opcion de aοΏ½adir el parοΏ½metro integraciones incoherentes a la Unidad de Procesamiento .
1146 1147 """
1147 1148 if p0 == 2:
1148 1149 self.specOpIncoherent.setEnabled(True)
1149 1150 if p0 == 0:
1150 1151 self.specOpIncoherent.setEnabled(False)
1151 1152
1152 1153 @pyqtSignature("int")
1153 1154 def on_specOpCebRemoveDC_stateChanged(self, p0):
1154 1155 """
1155 1156 Habilita la opcion de aοΏ½adir el parοΏ½metro remover DC a la Unidad de Procesamiento .
1156 1157 """
1157 1158 if p0 == 2:
1158 1159 self.specOpComRemoveDC.setEnabled(True)
1159 1160 if p0 == 0:
1160 1161 self.specOpComRemoveDC.setEnabled(False)
1161 1162
1162 1163 @pyqtSignature("int")
1163 1164 def on_specOpCebgetNoise_stateChanged(self, p0):
1164 1165 """
1165 1166 Habilita la opcion de aοΏ½adir la estimacion de ruido a la Unidad de Procesamiento .
1166 1167 """
1167 1168 if p0 == 2:
1168 1169 self.specOpgetNoise.setEnabled(True)
1169 1170
1170 1171 if p0 == 0:
1171 1172 self.specOpgetNoise.setEnabled(False)
1172 1173
1173 1174 @pyqtSignature("")
1174 1175 def on_specOpOk_clicked(self):
1175 1176 """
1176 1177 AΓ‘ADE OPERACION SPECTRA
1177 1178 """
1178 1179
1179 1180 addFTP = False
1180 1181 checkPath = False
1181 1182
1182 1183 self._disable_play_button()
1183 1184 self._disable_save_button()
1184 1185
1185 1186 self.console.clear()
1186 1187 self.console.append("Checking input parameters ...")
1187 1188
1188 1189 projectObj = self.getSelectedProjectObj()
1189 1190
1190 1191 if not projectObj:
1191 1192 self.console.append("Please select a project before update it")
1192 1193 return
1193 1194
1194 1195 puObj = self.getSelectedItemObj()
1195 1196
1196 1197 puObj.removeOperations()
1197 1198
1198 1199 if self.specOpCebRadarfrequency.isChecked():
1199 1200 value = str(self.specOpRadarfrequency.text())
1200 1201 format = 'float'
1201 1202 name_operation = 'setRadarFrequency'
1202 1203 name_parameter = 'frequency'
1203 1204
1204 1205 if not isFloat(value):
1205 1206 self.console.clear()
1206 1207 self.console.append("Invalid value '%s' for '%s'" %(value, name_parameter))
1207 1208 return 0
1208 1209
1209 1210 radarfreq = float(value)*1e6
1210 1211 opObj = puObj.addOperation(name=name_operation)
1211 1212 opObj.addParameter(name=name_parameter, value=radarfreq, format=format)
1212 1213
1213 1214 inputId = puObj.getInputId()
1214 1215 inputPuObj = projectObj.getProcUnitObj(inputId)
1215 1216
1216 1217 if inputPuObj.datatype == 'Voltage' or inputPuObj.datatype == 'USRP':
1217 1218
1218 1219 value = str(self.specOpnFFTpoints.text())
1219 1220
1220 1221 if not isInt(value):
1221 1222 self.console.append("Invalid value '%s' for '%s'" %(value, 'nFFTPoints'))
1222 1223 return 0
1223 1224
1224 1225 puObj.addParameter(name='nFFTPoints', value=value, format='int')
1225 1226
1226 1227 value = str(self.specOpProfiles.text())
1227 1228 if not isInt(value):
1228 1229 self.console.append("Please write a value on Profiles field")
1229 1230 else:
1230 1231 puObj.addParameter(name='nProfiles', value=value, format='int')
1231 1232
1232 1233 value = str(self.specOpippFactor.text())
1233 1234 if not isInt(value):
1234 1235 self.console.append("Please write a value on IppFactor field")
1235 1236 else:
1236 1237 puObj.addParameter(name='ippFactor' , value=value , format='int')
1237 1238
1238 1239 if self.specOpCebCrossSpectra.isChecked():
1239 1240 name_parameter = 'pairsList'
1240 1241 format = 'pairslist'
1241 1242 value = str(self.specOppairsList.text())
1242 1243
1243 1244 if value == "":
1244 1245 print "Please fill the pairs list field"
1245 1246 return 0
1246 1247
1247 1248 if not opObj.addParameter(name=name_parameter, value=value, format=format):
1248 1249 self.console.append("Invalid value '%s' for '%s'" %(value,name_parameter))
1249 1250 return 0
1250 1251
1251 1252 if self.specOpCebHeights.isChecked():
1252 1253 value = str(self.specOpHeights.text())
1253 1254
1254 1255 if value == "":
1255 1256 self.console.append("Empty value for '%s'" %(value, "Height range"))
1256 1257 return 0
1257 1258
1258 1259 valueList = value.split(',')
1259 1260 format = 'float'
1260 1261 value0 = valueList[0]
1261 1262 value1 = valueList[1]
1262 1263
1263 1264 if not isFloat(value0) or not isFloat(value1):
1264 1265 self.console.append("Invalid value '%s' for '%s'" %(value, "Height range"))
1265 1266 return 0
1266 1267
1267 1268 if self.specOpComHeights.currentIndex() == 0:
1268 1269 name_operation = 'selectHeights'
1269 1270 name_parameter1 = 'minHei'
1270 1271 name_parameter2 = 'maxHei'
1271 1272 else:
1272 1273 name_operation = 'selectHeightsByIndex'
1273 1274 name_parameter1 = 'minIndex'
1274 1275 name_parameter2 = 'maxIndex'
1275 1276
1276 1277 opObj = puObj.addOperation(name=name_operation)
1277 1278 opObj.addParameter(name=name_parameter1, value=value0, format=format)
1278 1279 opObj.addParameter(name=name_parameter2, value=value1, format=format)
1279 1280
1280 1281 if self.specOpCebChannel.isChecked():
1281 1282
1282 1283 if self.specOpComChannel.currentIndex() == 0:
1283 1284 name_operation = "selectChannels"
1284 1285 name_parameter = 'channelList'
1285 1286 else:
1286 1287 name_operation = "selectChannelsByIndex"
1287 1288 name_parameter = 'channelIndexList'
1288 1289
1289 1290 format = 'intlist'
1290 1291 value = str(self.specOpChannel.text())
1291 1292
1292 1293 if value == "":
1293 1294 print "Please fill channel list"
1294 1295 return 0
1295 1296
1296 1297 if not isList(value):
1297 1298 self.console.append("Invalid value '%s' for '%s'" %(value, name_parameter))
1298 1299 return 0
1299 1300
1300 1301 opObj = puObj.addOperation(name=name_operation)
1301 1302 opObj.addParameter(name=name_parameter, value=value, format=format)
1302 1303
1303 1304 if self.specOpCebIncoherent.isChecked():
1304 1305
1305 1306 name_operation = 'IncohInt'
1306 1307 optype = 'other'
1307 1308
1308 1309 if self.specOpCobIncInt.currentIndex() == 0:
1309 1310 name_parameter = 'timeInterval'
1310 1311 format = 'float'
1311 1312 else:
1312 1313 name_parameter = 'n'
1313 1314 format = 'int'
1314 1315
1315 1316 value = str(self.specOpIncoherent.text())
1316 1317
1317 1318 if value == "":
1318 1319 print "Please fill Incoherent integration value"
1319 1320 return 0
1320 1321
1321 1322 if not isFloat(value):
1322 1323 self.console.append("Invalid value '%s' for '%s'" %(value, name_parameter))
1323 1324 return 0
1324 1325
1325 1326 opObj = puObj.addOperation(name=name_operation, optype=optype)
1326 1327 opObj.addParameter(name=name_parameter, value=value, format=format)
1327 1328
1328 1329 if self.specOpCebRemoveDC.isChecked():
1329 1330 name_operation = 'removeDC'
1330 1331 name_parameter = 'mode'
1331 1332 format = 'int'
1332 1333 if self.specOpComRemoveDC.currentIndex() == 0:
1333 1334 value = 1
1334 1335 else:
1335 1336 value = 2
1336 1337 opObj = puObj.addOperation(name=name_operation)
1337 1338 opObj.addParameter(name=name_parameter, value=value, format=format)
1338 1339
1339 1340 if self.specOpCebRemoveInt.isChecked():
1340 1341 name_operation = 'removeInterference'
1341 1342 opObj = puObj.addOperation(name=name_operation)
1342 1343
1343 1344
1344 1345 if self.specOpCebgetNoise.isChecked():
1345 1346 value = str(self.specOpgetNoise.text())
1346 1347 valueList = value.split(',')
1347 1348 format = 'float'
1348 1349 name_operation = "getNoise"
1349 1350 opObj = puObj.addOperation(name=name_operation)
1350 1351
1351 1352 if not value == '':
1352 1353 valueList = value.split(',')
1353 1354 length = len(valueList)
1354 1355 if length == 1:
1355 1356 try:
1356 1357 value1 = float(valueList[0])
1357 1358 except:
1358 1359 self.console.clear()
1359 1360 self.console.append("Please Write correct parameter Get Noise")
1360 1361 return 0
1361 1362 name1 = 'minHei'
1362 1363 opObj.addParameter(name=name1, value=value1, format=format)
1363 1364 elif length == 2:
1364 1365 try:
1365 1366 value1 = float(valueList[0])
1366 1367 value2 = float(valueList[1])
1367 1368 except:
1368 1369 self.console.clear()
1369 1370 self.console.append("Please Write corrects parameter Get Noise")
1370 1371 return 0
1371 1372 name1 = 'minHei'
1372 1373 name2 = 'maxHei'
1373 1374 opObj.addParameter(name=name1, value=value1, format=format)
1374 1375 opObj.addParameter(name=name2, value=value2, format=format)
1375 1376
1376 1377 elif length == 3:
1377 1378 try:
1378 1379 value1 = float(valueList[0])
1379 1380 value2 = float(valueList[1])
1380 1381 value3 = float(valueList[2])
1381 1382 except:
1382 1383 self.console.clear()
1383 1384 self.console.append("Please Write corrects parameter Get Noise")
1384 1385 return 0
1385 1386 name1 = 'minHei'
1386 1387 name2 = 'maxHei'
1387 1388 name3 = 'minVel'
1388 1389 opObj.addParameter(name=name1, value=value1, format=format)
1389 1390 opObj.addParameter(name=name2, value=value2, format=format)
1390 1391 opObj.addParameter(name=name3, value=value3, format=format)
1391 1392
1392 1393 elif length == 4:
1393 1394 try:
1394 1395 value1 = float(valueList[0])
1395 1396 value2 = float(valueList[1])
1396 1397 value3 = float(valueList[2])
1397 1398 value4 = float(valueList[3])
1398 1399 except:
1399 1400 self.console.clear()
1400 1401 self.console.append("Please Write corrects parameter Get Noise")
1401 1402 return 0
1402 1403 name1 = 'minHei'
1403 1404 name2 = 'maxHei'
1404 1405 name3 = 'minVel'
1405 1406 name4 = 'maxVel'
1406 1407 opObj.addParameter(name=name1, value=value1, format=format)
1407 1408 opObj.addParameter(name=name2, value=value2, format=format)
1408 1409 opObj.addParameter(name=name3, value=value3, format=format)
1409 1410 opObj.addParameter(name=name4, value=value4, format=format)
1410 1411
1411 1412 elif length > 4:
1412 1413 self.console.clear()
1413 1414 self.console.append("Get Noise Operation only accepts 4 parameters")
1414 1415 return 0
1415 1416
1416 1417 channelList = str(self.specGgraphChannelList.text()).replace(" ","")
1417 1418 vel_range = str(self.specGgraphFreq.text()).replace(" ","")
1418 1419 hei_range = str(self.specGgraphHeight.text()).replace(" ","")
1419 1420 db_range = str(self.specGgraphDbsrange.text()).replace(" ","")
1420 1421
1421 1422 trange = str(self.specGgraphTminTmax.text()).replace(" ","")
1422 1423 magrange = str(self.specGgraphmagnitud.text()).replace(" ","")
1423 1424 phaserange = str(self.specGgraphPhase.text()).replace(" ","")
1424 1425 # timerange = str(self.specGgraphTimeRange.text()).replace(" ","")
1425 1426
1426 1427 figpath = str(self.specGraphPath.text())
1427 1428 figfile = str(self.specGraphPrefix.text()).replace(" ","")
1428 1429 try:
1429 1430 wrperiod = int(str(self.specGgraphftpratio.text()).replace(" ",""))
1430 1431 except:
1431 1432 wrperiod = None
1432 1433
1433 1434 #-----Spectra Plot-----
1434 1435 if self.specGraphCebSpectraplot.isChecked():
1435 1436
1436 1437 opObj = puObj.addOperation(name='SpectraPlot', optype='other')
1437 1438 opObj.addParameter(name='id', value=opObj.id, format='int')
1438 1439
1439 1440 if not channelList == '':
1440 1441
1441 1442 if not isList(channelList):
1442 1443 self.console.append("Invalid channelList")
1443 1444 return 0
1444 1445
1445 1446 opObj.addParameter(name='channelList', value=channelList, format='intlist')
1446 1447
1447 1448 if not vel_range == '':
1448 1449 xvalueList = vel_range.split(',')
1449 1450 try:
1450 1451 value1 = float(xvalueList[0])
1451 1452 value2 = float(xvalueList[1])
1452 1453 except:
1453 1454 self.console.clear()
1454 1455 self.console.append("Invalid velocity/frequency range")
1455 1456 return 0
1456 1457
1457 1458 opObj.addParameter(name='xmin', value=value1, format='float')
1458 1459 opObj.addParameter(name='xmax', value=value2, format='float')
1459 1460
1460 1461 if not hei_range == '':
1461 1462 yvalueList = hei_range.split(",")
1462 1463 try:
1463 1464 value1 = float(yvalueList[0])
1464 1465 value2 = float(yvalueList[1])
1465 1466 except:
1466 1467 self.console.clear()
1467 1468 self.console.append("Invalid height range")
1468 1469 return 0
1469 1470
1470 1471 opObj.addParameter(name='ymin', value=value1, format='float')
1471 1472 opObj.addParameter(name='ymax', value=value2, format='float')
1472 1473
1473 1474 if not db_range == '':
1474 1475 zvalueList = db_range.split(",")
1475 1476 try:
1476 1477 value1 = float(zvalueList[0])
1477 1478 value2 = float(zvalueList[1])
1478 1479 except:
1479 1480 self.console.clear()
1480 1481 self.console.append("Invalid db range")
1481 1482 return 0
1482 1483
1483 1484 opObj.addParameter(name='zmin', value=value1, format='float')
1484 1485 opObj.addParameter(name='zmax', value=value2, format='float')
1485 1486
1486 1487 if self.specGraphSaveSpectra.isChecked():
1487 1488 checkPath = True
1488 1489 opObj.addParameter(name='save', value=1 , format='bool')
1489 1490 opObj.addParameter(name='figpath', value=figpath, format='str')
1490 1491 if figfile:
1491 1492 opObj.addParameter(name='figfile', value=figfile, format='str')
1492 1493 if wrperiod:
1493 1494 opObj.addParameter(name='wr_period', value=wrperiod,format='int')
1494 1495
1495 1496 if self.specGraphftpSpectra.isChecked():
1496 1497 opObj.addParameter(name='ftp', value='1', format='int')
1497 1498 self.addFTPConf2Operation(puObj, opObj)
1498 1499 addFTP = True
1499 1500
1500 1501 if self.specGraphCebCrossSpectraplot.isChecked():
1501 1502
1502 1503 opObj = puObj.addOperation(name='CrossSpectraPlot', optype='other')
1503 1504 # opObj.addParameter(name='power_cmap', value='jet', format='str')
1504 1505 # opObj.addParameter(name='coherence_cmap', value='jet', format='str')
1505 1506 # opObj.addParameter(name='phase_cmap', value='RdBu_r', format='str')
1506 1507 opObj.addParameter(name='id', value=opObj.id, format='int')
1507 1508
1508 1509 if not vel_range == '':
1509 1510 xvalueList = vel_range.split(',')
1510 1511 try:
1511 1512 value1 = float(xvalueList[0])
1512 1513 value2 = float(xvalueList[1])
1513 1514 except:
1514 1515 self.console.clear()
1515 1516 self.console.append("Invalid velocity/frequency range")
1516 1517 return 0
1517 1518
1518 1519 opObj.addParameter(name='xmin', value=value1, format='float')
1519 1520 opObj.addParameter(name='xmax', value=value2, format='float')
1520 1521
1521 1522 if not hei_range == '':
1522 1523 yvalueList = hei_range.split(",")
1523 1524 try:
1524 1525 value1 = float(yvalueList[0])
1525 1526 value2 = float(yvalueList[1])
1526 1527 except:
1527 1528 self.console.clear()
1528 1529 self.console.append("Invalid height range")
1529 1530 return 0
1530 1531
1531 1532 opObj.addParameter(name='ymin', value=value1, format='float')
1532 1533 opObj.addParameter(name='ymax', value=value2, format='float')
1533 1534
1534 1535 if not db_range == '':
1535 1536 zvalueList = db_range.split(",")
1536 1537 try:
1537 1538 value1 = float(zvalueList[0])
1538 1539 value2 = float(zvalueList[1])
1539 1540 except:
1540 1541 self.console.clear()
1541 1542 self.console.append("Invalid db range")
1542 1543 return 0
1543 1544
1544 1545 opObj.addParameter(name='zmin', value=value1, format='float')
1545 1546 opObj.addParameter(name='zmax', value=value2, format='float')
1546 1547
1547 1548 if not magrange == '':
1548 1549 zvalueList = magrange.split(",")
1549 1550 try:
1550 1551 value1 = float(zvalueList[0])
1551 1552 value2 = float(zvalueList[1])
1552 1553 except:
1553 1554 self.console.clear()
1554 1555 self.console.append("Invalid magnitude range")
1555 1556 return 0
1556 1557
1557 1558 opObj.addParameter(name='coh_min', value=value1, format='float')
1558 1559 opObj.addParameter(name='coh_max', value=value2, format='float')
1559 1560
1560 1561 if not phaserange == '':
1561 1562 zvalueList = phaserange.split(",")
1562 1563 try:
1563 1564 value1 = float(zvalueList[0])
1564 1565 value2 = float(zvalueList[1])
1565 1566 except:
1566 1567 self.console.clear()
1567 1568 self.console.append("Invalid phase range")
1568 1569 return 0
1569 1570
1570 1571 opObj.addParameter(name='phase_min', value=value1, format='float')
1571 1572 opObj.addParameter(name='phase_max', value=value2, format='float')
1572 1573
1573 1574 if self.specGraphSaveCross.isChecked():
1574 1575 checkPath = True
1575 1576 opObj.addParameter(name='save', value='1', format='bool')
1576 1577 opObj.addParameter(name='figpath', value=figpath, format='str')
1577 1578 if figfile:
1578 1579 opObj.addParameter(name='figfile', value=figfile, format='str')
1579 1580 if wrperiod:
1580 1581 opObj.addParameter(name='wr_period', value=wrperiod,format='int')
1581 1582
1582 1583 if self.specGraphftpCross.isChecked():
1583 1584 opObj.addParameter(name='ftp', value='1', format='int')
1584 1585 self.addFTPConf2Operation(puObj, opObj)
1585 1586 addFTP = True
1586 1587
1587 1588 if self.specGraphCebRTIplot.isChecked():
1588 1589
1589 1590 opObj = puObj.addOperation(name='RTIPlot', optype='other')
1590 1591 opObj.addParameter(name='id', value=opObj.id, format='int')
1591 1592
1592 1593 if not channelList == '':
1593 1594 if not isList(channelList):
1594 1595 self.console.append("Invalid channelList")
1595 1596 return 0
1596 1597 opObj.addParameter(name='channelList', value=channelList, format='intlist')
1597 1598
1598 1599 if not trange == '':
1599 1600 xvalueList = trange.split(',')
1600 1601 try:
1601 1602 value1 = float(xvalueList[0])
1602 1603 value2 = float(xvalueList[1])
1603 1604 except:
1604 1605 self.console.clear()
1605 1606 self.console.append("Invalid time range")
1606 1607 return 0
1607 1608
1608 1609 opObj.addParameter(name='xmin', value=value1, format='float')
1609 1610 opObj.addParameter(name='xmax', value=value2, format='float')
1610 1611
1611 1612 # if not timerange == '':
1612 1613 # try:
1613 1614 # timerange = float(timerange)
1614 1615 # except:
1615 1616 # self.console.clear()
1616 1617 # self.console.append("Invalid time range")
1617 1618 # return 0
1618 1619 #
1619 1620 # opObj.addParameter(name='timerange', value=timerange, format='float')
1620 1621
1621 1622 if not hei_range == '':
1622 1623 yvalueList = hei_range.split(",")
1623 1624 try:
1624 1625 value1 = float(yvalueList[0])
1625 1626 value2 = float(yvalueList[1])
1626 1627 except:
1627 1628 self.console.clear()
1628 1629 self.console.append("Invalid height range")
1629 1630 return 0
1630 1631
1631 1632 opObj.addParameter(name='ymin', value=value1, format='float')
1632 1633 opObj.addParameter(name='ymax', value=value2, format='float')
1633 1634
1634 1635 if not db_range == '':
1635 1636 zvalueList = db_range.split(",")
1636 1637 try:
1637 1638 value1 = float(zvalueList[0])
1638 1639 value2 = float(zvalueList[1])
1639 1640 except:
1640 1641 self.console.clear()
1641 1642 self.console.append("Invalid db range")
1642 1643 return 0
1643 1644
1644 1645 opObj.addParameter(name='zmin', value=value1, format='float')
1645 1646 opObj.addParameter(name='zmax', value=value2, format='float')
1646 1647
1647 1648 if self.specGraphSaveRTIplot.isChecked():
1648 1649 checkPath = True
1649 1650 opObj.addParameter(name='save', value='1', format='bool')
1650 1651 opObj.addParameter(name='figpath', value=figpath, format='str')
1651 1652 if figfile:
1652 1653 opObj.addParameter(name='figfile', value=value, format='str')
1653 1654 if wrperiod:
1654 1655 opObj.addParameter(name='wr_period', value=wrperiod,format='int')
1655 1656
1656 1657 if self.specGraphftpRTIplot.isChecked():
1657 1658 opObj.addParameter(name='ftp', value='1', format='int')
1658 1659 self.addFTPConf2Operation(puObj, opObj)
1659 1660 addFTP = True
1660 1661
1661 1662 if self.specGraphCebCoherencmap.isChecked():
1662 1663
1663 1664 opObj = puObj.addOperation(name='CoherenceMap', optype='other')
1664 1665 # opObj.addParameter(name=name_parameter, value=value, format=format)
1665 1666 # opObj.addParameter(name='coherence_cmap', value='jet', format='str')
1666 1667 # opObj.addParameter(name='phase_cmap', value='RdBu_r', format='str')
1667 1668 opObj.addParameter(name='id', value=opObj.id, format='int')
1668 1669
1669 1670 # if not timerange == '':
1670 1671 # try:
1671 1672 # timerange = int(timerange)
1672 1673 # except:
1673 1674 # self.console.clear()
1674 1675 # self.console.append("Invalid time range")
1675 1676 # return 0
1676 1677 #
1677 1678 # opObj.addParameter(name='timerange', value=timerange, format='int')
1678 1679
1679 1680 if not trange == '':
1680 1681 xvalueList = trange.split(',')
1681 1682 try:
1682 1683 value1 = float(xvalueList[0])
1683 1684 value2 = float(xvalueList[1])
1684 1685 except:
1685 1686 self.console.clear()
1686 1687 self.console.append("Invalid time range")
1687 1688 return 0
1688 1689
1689 1690 opObj.addParameter(name='xmin', value=value1, format='float')
1690 1691 opObj.addParameter(name='xmax', value=value2, format='float')
1691 1692
1692 1693 if not hei_range == '':
1693 1694 yvalueList = hei_range.split(",")
1694 1695 try:
1695 1696 value1 = float(yvalueList[0])
1696 1697 value2 = float(yvalueList[1])
1697 1698 except:
1698 1699 self.console.clear()
1699 1700 self.console.append("Invalid height range")
1700 1701 return 0
1701 1702
1702 1703 opObj.addParameter(name='ymin', value=value1, format='float')
1703 1704 opObj.addParameter(name='ymax', value=value2, format='float')
1704 1705
1705 1706 if not magrange == '':
1706 1707 zvalueList = magrange.split(",")
1707 1708 try:
1708 1709 value1 = float(zvalueList[0])
1709 1710 value2 = float(zvalueList[1])
1710 1711 except:
1711 1712 self.console.clear()
1712 1713 self.console.append("Invalid magnitude range")
1713 1714 return 0
1714 1715
1715 1716 opObj.addParameter(name='zmin', value=value1, format='float')
1716 1717 opObj.addParameter(name='zmax', value=value2, format='float')
1717 1718
1718 1719 if not phaserange == '':
1719 1720 zvalueList = phaserange.split(",")
1720 1721 try:
1721 1722 value1 = float(zvalueList[0])
1722 1723 value2 = float(zvalueList[1])
1723 1724 except:
1724 1725 self.console.clear()
1725 1726 self.console.append("Invalid phase range")
1726 1727 return 0
1727 1728
1728 1729 opObj.addParameter(name='phase_min', value=value1, format='float')
1729 1730 opObj.addParameter(name='phase_max', value=value2, format='float')
1730 1731
1731 1732 if self.specGraphSaveCoherencemap.isChecked():
1732 1733 checkPath = True
1733 1734 opObj.addParameter(name='save', value='1', format='bool')
1734 1735 opObj.addParameter(name='figpath', value=figpath, format='str')
1735 1736 if figfile:
1736 1737 opObj.addParameter(name='figfile', value=value, format='str')
1737 1738 if wrperiod:
1738 1739 opObj.addParameter(name='wr_period', value=wrperiod,format='int')
1739 1740
1740 1741 if self.specGraphftpCoherencemap.isChecked():
1741 1742 opObj.addParameter(name='ftp', value='1', format='int')
1742 1743 self.addFTPConf2Operation(puObj, opObj)
1743 1744 addFTP = True
1744 1745
1745 1746 if self.specGraphPowerprofile.isChecked():
1746 1747
1747 1748 opObj = puObj.addOperation(name='PowerProfilePlot', optype='other')
1748 1749 opObj.addParameter(name='id', value=opObj.id, format='int')
1749 1750
1750 1751 if not channelList == '':
1751 1752 if not isList(channelList):
1752 1753 self.console.append("Invalid channelList")
1753 1754 return 0
1754 1755
1755 1756 opObj.addParameter(name='channelList', value=channelList, format='intlist')
1756 1757
1757 1758 if not db_range == '':
1758 1759 xvalueList = db_range.split(',')
1759 1760 try:
1760 1761 value1 = float(xvalueList[0])
1761 1762 value2 = float(xvalueList[1])
1762 1763 except:
1763 1764 self.console.clear()
1764 1765 self.console.append("Invalid db range")
1765 1766 return 0
1766 1767
1767 1768 opObj.addParameter(name='xmin', value=value1, format='float')
1768 1769 opObj.addParameter(name='xmax', value=value2, format='float')
1769 1770
1770 1771 if not hei_range == '':
1771 1772 yvalueList = hei_range.split(",")
1772 1773 try:
1773 1774 value1 = float(yvalueList[0])
1774 1775 value2 = float(yvalueList[1])
1775 1776 except:
1776 1777 self.console.clear()
1777 1778 self.console.append("Invalid height range")
1778 1779 return 0
1779 1780
1780 1781 opObj.addParameter(name='ymin', value=value1, format='float')
1781 1782 opObj.addParameter(name='ymax', value=value2, format='float')
1782 1783
1783 1784 if self.specGraphSavePowerprofile.isChecked():
1784 1785 checkPath = True
1785 1786 opObj.addParameter(name='save', value='1', format='bool')
1786 1787 opObj.addParameter(name='figpath', value=figpath, format='str')
1787 1788 if figfile:
1788 1789 opObj.addParameter(name='figfile', value=value, format='str')
1789 1790 if wrperiod:
1790 1791 opObj.addParameter(name='wr_period', value=wrperiod,format='int')
1791 1792
1792 1793 if self.specGraphftpPowerprofile.isChecked():
1793 1794 opObj.addParameter(name='ftp', value='1', format='int')
1794 1795 self.addFTPConf2Operation(puObj, opObj)
1795 1796 addFTP = True
1796 1797 # rti noise
1797 1798
1798 1799 if self.specGraphCebRTInoise.isChecked():
1799 1800
1800 1801 opObj = puObj.addOperation(name='Noise', optype='other')
1801 1802 opObj.addParameter(name='id', value=opObj.id, format='int')
1802 1803
1803 1804 if not channelList == '':
1804 1805 if not isList(channelList):
1805 1806 self.console.append("Invalid channelList")
1806 1807 return 0
1807 1808 opObj.addParameter(name='channelList', value=channelList, format='intlist')
1808 1809
1809 1810 # if not timerange == '':
1810 1811 # try:
1811 1812 # timerange = float(timerange)
1812 1813 # except:
1813 1814 # self.console.clear()
1814 1815 # self.console.append("Invalid time range")
1815 1816 # return 0
1816 1817 #
1817 1818 # opObj.addParameter(name='timerange', value=timerange, format='float')
1818 1819
1819 1820 if not trange == '':
1820 1821 xvalueList = trange.split(',')
1821 1822 try:
1822 1823 value1 = float(xvalueList[0])
1823 1824 value2 = float(xvalueList[1])
1824 1825 except:
1825 1826 self.console.clear()
1826 1827 self.console.append("Invalid time range")
1827 1828 return 0
1828 1829
1829 1830 opObj.addParameter(name='xmin', value=value1, format='float')
1830 1831 opObj.addParameter(name='xmax', value=value2, format='float')
1831 1832
1832 1833 if not db_range == '':
1833 1834 yvalueList = db_range.split(",")
1834 1835 try:
1835 1836 value1 = float(yvalueList[0])
1836 1837 value2 = float(yvalueList[1])
1837 1838 except:
1838 1839 self.console.clear()
1839 1840 self.console.append("Invalid db range")
1840 1841 return 0
1841 1842
1842 1843 opObj.addParameter(name='ymin', value=value1, format='float')
1843 1844 opObj.addParameter(name='ymax', value=value2, format='float')
1844 1845
1845 1846 if self.specGraphSaveRTInoise.isChecked():
1846 1847 checkPath = True
1847 1848 opObj.addParameter(name='save', value='1', format='bool')
1848 1849 opObj.addParameter(name='figpath', value=figpath, format='str')
1849 1850 if figfile:
1850 1851 opObj.addParameter(name='figfile', value=value, format='str')
1851 1852 if wrperiod:
1852 1853 opObj.addParameter(name='wr_period', value=wrperiod,format='int')
1853 1854
1854 1855 # test_ftp
1855 1856 if self.specGraphftpRTInoise.isChecked():
1856 1857 opObj.addParameter(name='ftp', value='1', format='int')
1857 1858 self.addFTPConf2Operation(puObj, opObj)
1858 1859 addFTP = True
1859 1860
1860 1861 if checkPath:
1861 1862 if not figpath:
1862 1863 self.console.clear()
1863 1864 self.console.append("Graphic path should be defined")
1864 1865 return 0
1865 1866
1866 1867 if addFTP and not figpath:
1867 1868 self.console.clear()
1868 1869 self.console.append("You have to save the plots before sending them to FTP Server")
1869 1870 return 0
1870 1871
1871 1872 # if something happend
1872 1873 parms_ok, output_path, blocksperfile, profilesperblock = self.checkInputsPUSave(datatype='Spectra')
1873 1874 if parms_ok:
1874 1875 opObj = puObj.addOperation(name='SpectraWriter', optype='other')
1875 1876 opObj.addParameter(name='path', value=output_path)
1876 1877 opObj.addParameter(name='blocksPerFile', value=blocksperfile, format='int')
1877 1878
1878 1879 self.console.clear()
1879 1880 try:
1880 1881 self.refreshPUProperties(puObj)
1881 1882 except:
1882 1883 self.console.append("An error reading input parameters was found ... Check them!")
1883 1884 return 0
1884 1885
1885 1886 self.console.append("Save your project and press Play button to start signal processing")
1886 1887
1887 1888 self._enable_play_button()
1888 1889 self._enable_save_button()
1889 1890
1890 1891 return 1
1891 1892
1892 1893 """
1893 1894 Spectra Graph
1894 1895 """
1895 1896 @pyqtSignature("int")
1896 1897 def on_specGraphCebSpectraplot_stateChanged(self, p0):
1897 1898
1898 1899 self.__checkSpecGraphFilters()
1899 1900
1900 1901
1901 1902 @pyqtSignature("int")
1902 1903 def on_specGraphCebCrossSpectraplot_stateChanged(self, p0):
1903 1904
1904 1905 self.__checkSpecGraphFilters()
1905 1906
1906 1907 @pyqtSignature("int")
1907 1908 def on_specGraphCebRTIplot_stateChanged(self, p0):
1908 1909
1909 1910 self.__checkSpecGraphFilters()
1910 1911
1911 1912
1912 1913 @pyqtSignature("int")
1913 1914 def on_specGraphCebRTInoise_stateChanged(self, p0):
1914 1915
1915 1916 self.__checkSpecGraphFilters()
1916 1917
1917 1918
1918 1919 @pyqtSignature("int")
1919 1920 def on_specGraphCebCoherencmap_stateChanged(self, p0):
1920 1921
1921 1922 self.__checkSpecGraphFilters()
1922 1923
1923 1924 @pyqtSignature("int")
1924 1925 def on_specGraphPowerprofile_stateChanged(self, p0):
1925 1926
1926 1927 self.__checkSpecGraphFilters()
1927 1928
1928 1929 @pyqtSignature("int")
1929 1930 def on_specGraphPhase_stateChanged(self, p0):
1930 1931
1931 1932 self.__checkSpecGraphFilters()
1932 1933
1933 1934 @pyqtSignature("int")
1934 1935 def on_specGraphSaveSpectra_stateChanged(self, p0):
1935 1936 """
1936 1937 """
1937 1938 self.__checkSpecGraphSaving()
1938 1939
1939 1940 @pyqtSignature("int")
1940 1941 def on_specGraphSaveCross_stateChanged(self, p0):
1941 1942
1942 1943 self.__checkSpecGraphSaving()
1943 1944
1944 1945 @pyqtSignature("int")
1945 1946 def on_specGraphSaveRTIplot_stateChanged(self, p0):
1946 1947
1947 1948 self.__checkSpecGraphSaving()
1948 1949
1949 1950 @pyqtSignature("int")
1950 1951 def on_specGraphSaveRTInoise_stateChanged(self, p0):
1951 1952
1952 1953 self.__checkSpecGraphSaving()
1953 1954
1954 1955 @pyqtSignature("int")
1955 1956 def on_specGraphSaveCoherencemap_stateChanged(self, p0):
1956 1957
1957 1958 self.__checkSpecGraphSaving()
1958 1959
1959 1960 @pyqtSignature("int")
1960 1961 def on_specGraphSavePowerprofile_stateChanged(self, p0):
1961 1962
1962 1963 self.__checkSpecGraphSaving()
1963 1964
1964 1965 @pyqtSignature("int")
1965 1966 def on_specGraphftpSpectra_stateChanged(self, p0):
1966 1967 """
1967 1968 """
1968 1969 self.__checkSpecGraphFTP()
1969 1970
1970 1971
1971 1972 @pyqtSignature("int")
1972 1973 def on_specGraphftpCross_stateChanged(self, p0):
1973 1974
1974 1975 self.__checkSpecGraphFTP()
1975 1976
1976 1977 @pyqtSignature("int")
1977 1978 def on_specGraphftpRTIplot_stateChanged(self, p0):
1978 1979
1979 1980 self.__checkSpecGraphFTP()
1980 1981
1981 1982 @pyqtSignature("int")
1982 1983 def on_specGraphftpRTInoise_stateChanged(self, p0):
1983 1984
1984 1985 self.__checkSpecGraphFTP()
1985 1986
1986 1987 @pyqtSignature("int")
1987 1988 def on_specGraphftpCoherencemap_stateChanged(self, p0):
1988 1989
1989 1990 self.__checkSpecGraphFTP()
1990 1991
1991 1992 @pyqtSignature("int")
1992 1993 def on_specGraphftpPowerprofile_stateChanged(self, p0):
1993 1994
1994 1995 self.__checkSpecGraphFTP()
1995 1996
1996 1997 @pyqtSignature("")
1997 1998 def on_specGraphToolPath_clicked(self):
1998 1999 """
1999 2000 """
2000 2001 save_path = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
2001 2002 self.specGraphPath.setText(save_path)
2002 2003 if not os.path.exists(save_path):
2003 2004 self.console.clear()
2004 2005 self.console.append("Write a valid path")
2005 2006 return
2006 2007
2007 2008 @pyqtSignature("")
2008 2009 def on_specGraphClear_clicked(self):
2009 2010 return
2010 2011
2011 2012 @pyqtSignature("")
2012 2013 def on_specHeisGraphToolPath_clicked(self):
2013 2014 """
2014 2015 """
2015 2016 save_path = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
2016 2017 self.specHeisGraphPath.setText(save_path)
2017 2018 if not os.path.exists(save_path):
2018 2019 self.console.clear()
2019 2020 self.console.append("Write a valid path")
2020 2021 return
2021 2022
2022 2023 @pyqtSignature("int")
2023 2024 def on_specHeisOpCebIncoherent_stateChanged(self, p0):
2024 2025 """
2025 2026 Habilita la opcion de aοΏ½adir el parοΏ½metro integraciones incoherentes a la Unidad de Procesamiento .
2026 2027 """
2027 2028 if p0 == 2:
2028 2029 self.specHeisOpIncoherent.setEnabled(True)
2029 2030 self.specHeisOpCobIncInt.setEnabled(True)
2030 2031 if p0 == 0:
2031 2032 self.specHeisOpIncoherent.setEnabled(False)
2032 2033 self.specHeisOpCobIncInt.setEnabled(False)
2033 2034
2034 2035 @pyqtSignature("")
2035 2036 def on_specHeisOpOk_clicked(self):
2036 2037 """
2037 2038 AΓ‘ADE OPERACION SPECTRAHEIS
2038 2039 """
2039 2040 addFTP = False
2040 2041 checkPath = False
2041 2042
2042 2043 self._disable_play_button()
2043 2044 self._disable_save_button()
2044 2045
2045 2046 self.console.clear()
2046 2047 self.console.append("Checking input parameters ...")
2047 2048
2048 2049 puObj = self.getSelectedItemObj()
2049 2050 puObj.removeOperations()
2050 2051
2051 2052 if self.specHeisOpCebIncoherent.isChecked():
2052 2053 value = str(self.specHeisOpIncoherent.text())
2053 2054 name_operation = 'IncohInt4SpectraHeis'
2054 2055 optype = 'other'
2055 2056
2056 2057 name_parameter = 'timeInterval'
2057 2058 format = 'float'
2058 2059
2059 2060 if self.specOpCobIncInt.currentIndex() == 0:
2060 2061 name_parameter = 'timeInterval'
2061 2062 format = 'float'
2062 2063
2063 2064 if not isFloat(value):
2064 2065 self.console.append("Invalid value '%s' for '%s'" %(value, name_parameter))
2065 2066 return 0
2066 2067
2067 2068 opObj = puObj.addOperation(name=name_operation, optype=optype)
2068 2069
2069 2070 if not opObj.addParameter(name=name_parameter, value=value, format=format):
2070 2071 self.console.append("Invalid value '%s' for '%s'" %(value, name_parameter))
2071 2072 return 0
2072 2073
2073 2074 channelList = str(self.specHeisGgraphChannelList.text())
2074 2075 freq_range = str(self.specHeisGgraphXminXmax.text())
2075 2076 power_range = str(self.specHeisGgraphYminYmax.text())
2076 2077 time_range = str(self.specHeisGgraphTminTmax.text())
2077 2078 timerange = str(self.specHeisGgraphTimeRange.text())
2078 2079
2079 2080 # ---- Spectra Plot-----
2080 2081 if self.specHeisGraphCebSpectraplot.isChecked():
2081 2082
2082 2083 name_operation = 'SpectraHeisScope'
2083 2084 optype = 'other'
2084 2085 opObj = puObj.addOperation(name=name_operation, optype=optype)
2085 2086
2086 2087 name_parameter = 'id'
2087 2088 format = 'int'
2088 2089 value = opObj.id
2089 2090
2090 2091 if not opObj.addParameter(name=name_parameter, value=value, format=format):
2091 2092 self.console.append("Invalid value '%s' for '%s'" %(value, name_parameter))
2092 2093 return 0
2093 2094
2094 2095 if not (channelList == ''):
2095 2096 name_parameter = 'channelList'
2096 2097 format = 'intlist'
2097 2098
2098 2099 if not isList(channelList):
2099 2100 self.console.append("Invalid value '%s' for '%s'" %(channelList, name_parameter))
2100 2101 return 0
2101 2102
2102 2103 opObj.addParameter(name=name_parameter, value=channelList, format=format)
2103 2104
2104 2105 if not freq_range == '':
2105 2106 xvalueList = freq_range.split(',')
2106 2107
2107 2108 if len(xvalueList) != 2:
2108 2109 self.console.append("Invalid value '%s' for '%s'" %(freq_range, "xrange"))
2109 2110 return 0
2110 2111
2111 2112 value1 = xvalueList[0]
2112 2113 value2 = xvalueList[1]
2113 2114
2114 2115 if not isFloat(value1) or not isFloat(value2):
2115 2116 self.console.append("Invalid value '%s' for '%s'" %(freq_range, "xrange"))
2116 2117 return 0
2117 2118
2118 2119 name1 = 'xmin'
2119 2120 name2 = 'xmax'
2120 2121 format = 'float'
2121 2122
2122 2123 opObj.addParameter(name=name1, value=value1, format=format)
2123 2124 opObj.addParameter(name=name2, value=value2, format=format)
2124 2125
2125 2126 #------specHeisGgraphYmin-Ymax---
2126 2127 if not power_range == '':
2127 2128 yvalueList = power_range.split(",")
2128 2129
2129 2130 if len(yvalueList) != 2:
2130 2131 self.console.append("Invalid value '%s' for '%s'" %(power_range, "xrange"))
2131 2132 return 0
2132 2133
2133 2134 value1 = yvalueList[0]
2134 2135 value2 = yvalueList[1]
2135 2136
2136 2137 if not isFloat(value1) or not isFloat(value2):
2137 2138 self.console.append("Invalid value '%s' for '%s'" %(power_range, "yrange"))
2138 2139 return 0
2139 2140
2140 2141 name1 = 'ymin'
2141 2142 name2 = 'ymax'
2142 2143 format = 'float'
2143 2144 opObj.addParameter(name=name1, value=value1, format=format)
2144 2145 opObj.addParameter(name=name2, value=value2, format=format)
2145 2146
2146 2147 if self.specHeisGraphSaveSpectra.isChecked():
2147 2148 checkPath = True
2148 2149 name_parameter1 = 'save'
2149 2150 name_parameter2 = 'figpath'
2150 2151 name_parameter3 = 'figfile'
2151 2152 value1 = '1'
2152 2153 value2 = str(self.specHeisGraphPath.text())
2153 2154 value3 = str(self.specHeisGraphPrefix.text())
2154 2155 format1 = 'bool'
2155 2156 format2 = 'str'
2156 2157 opObj.addParameter(name=name_parameter1, value=value1 , format=format1)
2157 2158 opObj.addParameter(name=name_parameter2, value=value2, format=format2)
2158 2159 if not value3 == "":
2159 2160 try:
2160 2161 value3 = str(self.specHeisGraphPrefix.text())
2161 2162 except:
2162 2163 self.console.clear()
2163 2164 self.console.append("Please Write prefix")
2164 2165 return 0
2165 2166 opObj.addParameter(name='figfile', value=str(self.specHeisGraphPrefix.text()), format='str')
2166 2167
2167 2168 # opObj.addParameter(name=name_parameter3, value=value3, format=format2)
2168 2169 # opObj.addParameter(name='wr_period', value='5',format='int')
2169 2170
2170 2171 if self.specHeisGraphftpSpectra.isChecked():
2171 2172 opObj.addParameter(name='ftp', value='1', format='int')
2172 2173 self.addFTPConf2Operation(puObj, opObj)
2173 2174 addFTP = True
2174 2175
2175 2176 if self.specHeisGraphCebRTIplot.isChecked():
2176 2177 name_operation = 'RTIfromSpectraHeis'
2177 2178 optype = 'other'
2178 2179
2179 2180 name_parameter = 'id'
2180 2181 format = 'int'
2181 2182
2182 2183 opObj = puObj.addOperation(name=name_operation, optype=optype)
2183 2184 value = opObj.id
2184 2185 opObj.addParameter(name=name_parameter, value=value, format=format)
2185 2186
2186 2187 if not channelList == '':
2187 2188 opObj.addParameter(name='channelList', value=channelList, format='intlist')
2188 2189
2189 2190 if not time_range == '':
2190 2191 xvalueList = time_range.split(',')
2191 2192 try:
2192 2193 value = float(xvalueList[0])
2193 2194 value = float(xvalueList[1])
2194 2195 except:
2195 2196 return 0
2196 2197 format = 'float'
2197 2198 opObj.addParameter(name='xmin', value=xvalueList[0], format=format)
2198 2199 opObj.addParameter(name='xmax', value=xvalueList[1], format=format)
2199 2200
2200 2201 if not timerange == '':
2201 2202 format = 'int'
2202 2203 try:
2203 2204 timerange = int(timerange)
2204 2205 except:
2205 2206 return 0
2206 2207 opObj.addParameter(name='timerange', value=timerange, format=format)
2207 2208
2208 2209
2209 2210 if not power_range == '':
2210 2211 yvalueList = power_range.split(",")
2211 2212 try:
2212 2213 value = float(yvalueList[0])
2213 2214 value = float(yvalueList[1])
2214 2215 except:
2215 2216 return 0
2216 2217
2217 2218 format = 'float'
2218 2219 opObj.addParameter(name='ymin', value=yvalueList[0], format=format)
2219 2220 opObj.addParameter(name='ymax', value=yvalueList[1], format=format)
2220 2221
2221 2222 if self.specHeisGraphSaveRTIplot.isChecked():
2222 2223 checkPath = True
2223 2224 opObj.addParameter(name='save', value='1', format='bool')
2224 2225 opObj.addParameter(name='figpath', value=str(self.specHeisGraphPath.text()), format='str')
2225 2226 value = str(self.specHeisGraphPrefix.text())
2226 2227 if not value == "":
2227 2228 try:
2228 2229 value = str(self.specHeisGraphPrefix.text())
2229 2230 except:
2230 2231 self.console.clear()
2231 2232 self.console.append("Please Write prefix")
2232 2233 return 0
2233 2234 opObj.addParameter(name='figfile', value=value, format='str')
2234 2235
2235 2236 # test_ftp
2236 2237 if self.specHeisGraphftpRTIplot.isChecked():
2237 2238 opObj.addParameter(name='ftp', value='1', format='int')
2238 2239 self.addFTPConf2Operation(puObj, opObj)
2239 2240 addFTP = True
2240 2241
2241 2242 localfolder = None
2242 2243 if checkPath:
2243 2244 localfolder = str(self.specHeisGraphPath.text())
2244 2245 if localfolder == '':
2245 2246 self.console.clear()
2246 2247 self.console.append("Graphic path should be defined")
2247 2248 return 0
2248 2249
2249 2250 if addFTP and not localfolder:
2250 2251 self.console.clear()
2251 2252 self.console.append("You should save plots before send them to FTP Server")
2252 2253 return 0
2253 2254
2254 2255 # if something happened
2255 2256 parms_ok, output_path, blocksperfile, metadata_file = self.checkInputsPUSave(datatype='SpectraHeis')
2256 2257 if parms_ok:
2257 2258 name_operation = 'FitsWriter'
2258 2259 optype = 'other'
2259 2260 name_parameter1 = 'path'
2260 2261 name_parameter2 = 'dataBlocksPerFile'
2261 2262 name_parameter3 = 'metadatafile'
2262 2263 value1 = output_path
2263 2264 value2 = blocksperfile
2264 2265 value3 = metadata_file
2265 2266 format2 = "int"
2266 2267 format3 = "str"
2267 2268 opObj = puObj.addOperation(name=name_operation, optype=optype)
2268 2269
2269 2270 opObj.addParameter(name=name_parameter1, value=value1)
2270 2271
2271 2272 if blocksperfile:
2272 2273 opObj.addParameter(name=name_parameter2, value=value2, format=format2)
2273 2274
2274 2275 if metadata_file:
2275 2276 opObj.addParameter(name=name_parameter3, value=value3, format=format3)
2276 2277
2277 2278 self.console.clear()
2278 2279 try:
2279 2280 self.refreshPUProperties(puObj)
2280 2281 except:
2281 2282 self.console.append("An error reading input parameters was found ... Check them!")
2282 2283 return 0
2283 2284
2284 2285 self.console.append("Save your project and press Play button to start signal processing")
2285 2286
2286 2287 self._enable_save_button()
2287 2288 self._enable_play_button()
2288 2289
2289 2290 return 1
2290 2291 @pyqtSignature("int")
2291 2292 def on_specHeisGraphCebSpectraplot_stateChanged(self, p0):
2292 2293
2293 2294 if p0 == 2:
2294 2295 self.specHeisGgraphChannelList.setEnabled(True)
2295 2296 self.specHeisGgraphXminXmax.setEnabled(True)
2296 2297 self.specHeisGgraphYminYmax.setEnabled(True)
2297 2298 if p0 == 0:
2298 2299 self.specHeisGgraphXminXmax.setEnabled(False)
2299 2300 self.specHeisGgraphYminYmax.setEnabled(False)
2300 2301
2301 2302 @pyqtSignature("int")
2302 2303 def on_specHeisGraphCebRTIplot_stateChanged(self, p0):
2303 2304
2304 2305 if p0 == 2:
2305 2306 self.specHeisGgraphChannelList.setEnabled(True)
2306 2307 self.specHeisGgraphTminTmax.setEnabled(True)
2307 2308 self.specHeisGgraphYminYmax.setEnabled(True)
2308 2309 self.specHeisGgraphTimeRange.setEnabled(True)
2309 2310
2310 2311 if p0 == 0:
2311 2312 self.specHeisGgraphTminTmax.setEnabled(False)
2312 2313 self.specHeisGgraphYminYmax.setEnabled(False)
2313 2314 self.specHeisGgraphTimeRange.setEnabled(False)
2314 2315
2315 2316 @pyqtSignature("int")
2316 2317 def on_specHeisGraphSaveSpectra_stateChanged(self, p0):
2317 2318 """
2318 2319 """
2319 2320 if p0 == 2:
2320 2321 self.specHeisGraphPath.setEnabled(True)
2321 2322 self.specHeisGraphPrefix.setEnabled(True)
2322 2323 self.specHeisGraphToolPath.setEnabled(True)
2323 2324 if p0 == 0:
2324 2325 self.specHeisGraphPath.setEnabled(False)
2325 2326 self.specHeisGraphPrefix.setEnabled(False)
2326 2327 self.specHeisGraphToolPath.setEnabled(False)
2327 2328
2328 2329 @pyqtSignature("int")
2329 2330 def on_specHeisGraphSaveRTIplot_stateChanged(self, p0):
2330 2331 if p0 == 2:
2331 2332 self.specHeisGraphPath.setEnabled(True)
2332 2333 self.specHeisGraphPrefix.setEnabled(True)
2333 2334 self.specHeisGraphToolPath.setEnabled(True)
2334 2335
2335 2336 @pyqtSignature("int")
2336 2337 def on_specHeisGraphftpSpectra_stateChanged(self, p0):
2337 2338 """
2338 2339 """
2339 2340 if p0 == 2:
2340 2341 self.specHeisGgraphftpratio.setEnabled(True)
2341 2342
2342 2343 if p0 == 0:
2343 2344 self.specHeisGgraphftpratio.setEnabled(False)
2344 2345
2345 2346 @pyqtSignature("int")
2346 2347 def on_specHeisGraphftpRTIplot_stateChanged(self, p0):
2347 2348 if p0 == 2:
2348 2349 self.specHeisGgraphftpratio.setEnabled(True)
2349 2350
2350 2351 @pyqtSignature("")
2351 2352 def on_specHeisGraphClear_clicked(self):
2352 2353 pass
2353 2354
2354 2355 def __checkSpecGraphSaving(self):
2355 2356
2356 2357 enable = False
2357 2358
2358 2359 if self.specGraphSaveSpectra.checkState():
2359 2360 enable = True
2360 2361
2361 2362 if self.specGraphSaveCross.checkState():
2362 2363 enable = True
2363 2364
2364 2365 if self.specGraphSaveRTIplot.checkState():
2365 2366 enable = True
2366 2367
2367 2368 if self.specGraphSaveCoherencemap.checkState():
2368 2369 enable = True
2369 2370
2370 2371 if self.specGraphSavePowerprofile.checkState():
2371 2372 enable = True
2372 2373
2373 2374 if self.specGraphSaveRTInoise.checkState():
2374 2375 enable = True
2375 2376
2376 2377 self.specGraphPath.setEnabled(enable)
2377 2378 self.specGraphPrefix.setEnabled(enable)
2378 2379 self.specGraphToolPath.setEnabled(enable)
2379 2380
2380 2381 self.specGgraphftpratio.setEnabled(enable)
2381 2382
2382 2383 def __checkSpecGraphFTP(self):
2383 2384
2384 2385 enable = False
2385 2386
2386 2387 if self.specGraphftpSpectra.checkState():
2387 2388 enable = True
2388 2389
2389 2390 if self.specGraphftpCross.checkState():
2390 2391 enable = True
2391 2392
2392 2393 if self.specGraphftpRTIplot.checkState():
2393 2394 enable = True
2394 2395
2395 2396 if self.specGraphftpCoherencemap.checkState():
2396 2397 enable = True
2397 2398
2398 2399 if self.specGraphftpPowerprofile.checkState():
2399 2400 enable = True
2400 2401
2401 2402 if self.specGraphftpRTInoise.checkState():
2402 2403 enable = True
2403 2404
2404 2405 # self.specGgraphftpratio.setEnabled(enable)
2405 2406
2406 2407 def __checkSpecGraphFilters(self):
2407 2408
2408 2409 freq = False
2409 2410 height = False
2410 2411 db = False
2411 2412 timerange = False
2412 2413 magnitud = False
2413 2414 phase = False
2414 2415 channelList = False
2415 2416
2416 2417 if self.specGraphCebSpectraplot.checkState():
2417 2418 freq = True
2418 2419 height = True
2419 2420 db = True
2420 2421 channelList = True
2421 2422
2422 2423 if self.specGraphCebCrossSpectraplot.checkState():
2423 2424 freq = True
2424 2425 height = True
2425 2426 db = True
2426 2427 magnitud = True
2427 2428 phase = True
2428 2429
2429 2430 if self.specGraphCebRTIplot.checkState():
2430 2431 height = True
2431 2432 db = True
2432 2433 timerange = True
2433 2434 channelList = True
2434 2435
2435 2436 if self.specGraphCebCoherencmap.checkState():
2436 2437 height = True
2437 2438 timerange = True
2438 2439 magnitud = True
2439 2440 phase = True
2440 2441
2441 2442 if self.specGraphPowerprofile.checkState():
2442 2443 height = True
2443 2444 db = True
2444 2445 channelList = True
2445 2446
2446 2447 if self.specGraphCebRTInoise.checkState():
2447 2448 db = True
2448 2449 timerange = True
2449 2450 channelList = True
2450 2451
2451 2452
2452 2453 self.specGgraphFreq.setEnabled(freq)
2453 2454 self.specGgraphHeight.setEnabled(height)
2454 2455 self.specGgraphDbsrange.setEnabled(db)
2455 2456 self.specGgraphTminTmax.setEnabled(timerange)
2456 2457
2457 2458 self.specGgraphmagnitud.setEnabled(magnitud)
2458 2459 self.specGgraphPhase.setEnabled(phase)
2459 2460 self.specGgraphChannelList.setEnabled(channelList)
2460 2461
2461 2462 def __getParmsFromProjectWindow(self):
2462 2463 """
2463 2464 Check Inputs Project:
2464 2465 - project_name
2465 2466 - datatype
2466 2467 - ext
2467 2468 - data_path
2468 2469 - readmode
2469 2470 - delay
2470 2471 - set
2471 2472 - walk
2472 2473 """
2473 2474 parms_ok = True
2474 2475
2475 2476 project_name = str(self.proName.text())
2476 2477
2477 2478 if project_name == '' or project_name == None:
2478 2479 outputstr = "Enter a project Name"
2479 2480 self.console.append(outputstr)
2480 2481 parms_ok = False
2481 2482 project_name = None
2482 2483
2483 2484 description = str(self.proDescription.toPlainText())
2484 2485
2485 2486 datatype = str(self.proComDataType.currentText())
2486 2487
2487 2488 ext = str(self.proDataType.text())
2488 2489
2489 2490 dpath = str(self.proDataPath.text())
2490 2491
2491 2492 if dpath == '':
2492 2493 outputstr = 'Datapath is empty'
2493 2494 self.console.append(outputstr)
2494 2495 parms_ok = False
2495 2496 dpath = None
2496 2497
2497 2498 if dpath != None:
2498 2499 if not os.path.isdir(dpath):
2499 2500 outputstr = 'Datapath (%s) does not exist' % dpath
2500 2501 self.console.append(outputstr)
2501 2502 parms_ok = False
2502 2503 dpath = None
2503 2504
2504 2505 online = int(self.proComReadMode.currentIndex())
2505 2506
2506 2507 delay = None
2507 2508 if online==1:
2508 2509 try:
2509 2510 delay = int(str(self.proDelay.text()))
2510 2511 except:
2511 2512 outputstr = 'Delay value (%s) must be a integer number' %str(self.proDelay.text())
2512 2513 self.console.append(outputstr)
2513 2514 parms_ok = False
2514 2515
2515 2516
2516 2517 set = None
2517 2518 value = str(self.proSet.text())
2518 2519 try:
2519 2520 set = int(value)
2520 2521 except:
2521 2522 pass
2522 2523
2523 2524 ippKm = None
2524 2525
2525 2526 value = str(self.proIPPKm.text())
2526 2527
2527 2528 try:
2528 2529 ippKm = float(value)
2529 2530 except:
2530 2531 if datatype=="USRP":
2531 2532 outputstr = 'IPP value "%s" must be a float number' % str(self.proIPPKm.text())
2532 2533 self.console.append(outputstr)
2533 2534 parms_ok = False
2534 2535
2535 2536 walk = int(self.proComWalk.currentIndex())
2536 2537 expLabel = str(self.proExpLabel.text())
2537 2538
2538 2539 startDate = str(self.proComStartDate.currentText())
2539 2540 endDate = str(self.proComEndDate.currentText())
2540 2541
2541 2542 # startDateList = startDate.split("/")
2542 2543 # endDateList = endDate.split("/")
2543 2544 #
2544 2545 # startDate = datetime.date(int(startDateList[0]), int(startDateList[1]), int(startDateList[2]))
2545 2546 # endDate = datetime.date(int(endDateList[0]), int(endDateList[1]), int(endDateList[2]))
2546 2547
2547 2548 startTime = self.proStartTime.time()
2548 2549 endTime = self.proEndTime.time()
2549 2550
2550 2551 startTime = str(startTime.toString("H:m:s"))
2551 2552 endTime = str(endTime.toString("H:m:s"))
2552 2553
2553 2554 projectParms = ProjectParms()
2554 2555
2555 2556 projectParms.name = project_name
2556 2557 projectParms.description = description
2557 2558 projectParms.datatype = datatype
2558 2559 projectParms.ext = ext
2559 2560 projectParms.dpath = dpath
2560 2561 projectParms.online = online
2561 2562 projectParms.startDate = startDate
2562 2563 projectParms.endDate = endDate
2563 2564 projectParms.startTime = startTime
2564 2565 projectParms.endTime = endTime
2565 2566 projectParms.delay = delay
2566 2567 projectParms.walk = walk
2567 2568 projectParms.expLabel = expLabel
2568 2569 projectParms.set = set
2569 2570 projectParms.ippKm = ippKm
2570 2571 projectParms.parmsOk = parms_ok
2571 2572
2572 2573 return projectParms
2573 2574
2574 2575
2575 2576 def __getParmsFromProjectObj(self, projectObjView):
2576 2577
2577 2578 parms_ok = True
2578 2579
2579 2580 project_name, description = projectObjView.name, projectObjView.description
2580 2581
2581 2582 readUnitObj = projectObjView.getReadUnitObj()
2582 2583 datatype = readUnitObj.datatype
2583 2584
2584 2585 operationObj = readUnitObj.getOperationObj(name='run')
2585 2586
2586 2587 dpath = operationObj.getParameterValue(parameterName='path')
2587 2588 startDate = operationObj.getParameterValue(parameterName='startDate')
2588 2589 endDate = operationObj.getParameterValue(parameterName='endDate')
2589 2590
2590 2591 startDate = startDate.strftime("%Y/%m/%d")
2591 2592 endDate = endDate.strftime("%Y/%m/%d")
2592 2593
2593 2594 startTime = operationObj.getParameterValue(parameterName='startTime')
2594 2595 endTime = operationObj.getParameterValue(parameterName='endTime')
2595 2596
2596 2597 startTime = startTime.strftime("%H:%M:%S")
2597 2598 endTime = endTime.strftime("%H:%M:%S")
2598 2599
2599 2600 online = 0
2600 2601 try:
2601 2602 online = operationObj.getParameterValue(parameterName='online')
2602 2603 except:
2603 2604 pass
2604 2605
2605 2606 delay = ''
2606 2607 try:
2607 2608 delay = operationObj.getParameterValue(parameterName='delay')
2608 2609 except:
2609 2610 pass
2610 2611
2611 2612 walk = 0
2612 2613 try:
2613 2614 walk = operationObj.getParameterValue(parameterName='walk')
2614 2615 except:
2615 2616 pass
2616 2617
2617 2618 set = ''
2618 2619 try:
2619 2620 set = operationObj.getParameterValue(parameterName='set')
2620 2621 except:
2621 2622 pass
2622 2623
2623 2624 expLabel = ''
2624 2625 try:
2625 2626 expLabel = operationObj.getParameterValue(parameterName='expLabel')
2626 2627 except:
2627 2628 pass
2628 2629
2629 2630 ippKm = ''
2630 2631 if datatype.lower() == 'usrp':
2631 2632 try:
2632 2633 ippKm = operationObj.getParameterValue(parameterName='ippKm')
2633 2634 except:
2634 2635 pass
2635 2636
2636 2637 projectParms = ProjectParms()
2637 2638
2638 2639 projectParms.name = project_name
2639 2640 projectParms.description = description
2640 2641 projectParms.datatype = datatype
2641 2642 projectParms.ext = None
2642 2643 projectParms.dpath = dpath
2643 2644 projectParms.online = online
2644 2645 projectParms.startDate = startDate
2645 2646 projectParms.endDate = endDate
2646 2647 projectParms.startTime = startTime
2647 2648 projectParms.endTime = endTime
2648 2649 projectParms.delay=delay
2649 2650 projectParms.walk=walk
2650 2651 projectParms.set=set
2651 2652 projectParms.ippKm=ippKm
2652 2653 projectParms.expLabel = expLabel
2653 2654 projectParms.parmsOk=parms_ok
2654 2655
2655 2656 return projectParms
2656 2657
2657 2658 def refreshProjectWindow(self, projectObjView):
2658 2659
2659 2660 self.proOk.setEnabled(False)
2660 2661
2661 2662 projectParms = self.__getParmsFromProjectObj(projectObjView)
2662 2663
2663 2664 index = projectParms.getDatatypeIndex()
2664 2665
2665 2666 self.proName.setText(projectParms.name)
2666 2667 self.proDescription.clear()
2667 2668 self.proDescription.append(projectParms.description)
2668 2669
2669 2670 self.on_proComDataType_activated(index=index)
2670 2671 self.proDataPath.setText(projectParms.dpath)
2671 2672 self.proComDataType.setCurrentIndex(index)
2672 2673 self.proComReadMode.setCurrentIndex(projectParms.online)
2673 2674 self.proDelay.setText(str(projectParms.delay))
2674 2675 self.proSet.setText(str(projectParms.set))
2675 2676 self.proIPPKm.setText(str(projectParms.ippKm))
2676 2677 self.proComWalk.setCurrentIndex(projectParms.walk)
2677 2678 self.proExpLabel.setText(str(projectParms.expLabel).strip())
2678 2679
2679 2680 dateList = self.loadDays(data_path = projectParms.dpath,
2680 2681 ext = projectParms.getExt(),
2681 2682 walk = projectParms.walk,
2682 2683 expLabel = projectParms.expLabel)
2683 2684
2684 2685 if not dateList:
2685 2686 return
2686 2687
2687 2688 try:
2688 2689 startDateIndex = dateList.index(projectParms.startDate)
2689 2690 except:
2690 2691 startDateIndex = 0
2691 2692
2692 2693 try:
2693 2694 endDateIndex = dateList.index(projectParms.endDate)
2694 2695 except:
2695 2696 endDateIndex = int(self.proComEndDate.count()-1)
2696 2697
2697 2698 self.proComStartDate.setCurrentIndex(startDateIndex)
2698 2699 self.proComEndDate.setCurrentIndex(endDateIndex)
2699 2700
2700 2701 startlist = projectParms.startTime.split(":")
2701 2702 endlist = projectParms.endTime.split(":")
2702 2703
2703 2704 self.time.setHMS(int(startlist[0]), int(startlist[1]), int(startlist[2]))
2704 2705 self.proStartTime.setTime(self.time)
2705 2706
2706 2707 self.time.setHMS(int(endlist[0]), int(endlist[1]), int(endlist[2]))
2707 2708 self.proEndTime.setTime(self.time)
2708 2709
2709 2710 self.proOk.setEnabled(True)
2710 2711
2711 2712 def __refreshVoltageWindow(self, puObj):
2712 2713
2713 2714 opObj = puObj.getOperationObj(name='setRadarFrequency')
2714 2715 if opObj == None:
2715 2716 self.volOpRadarfrequency.clear()
2716 2717 self.volOpCebRadarfrequency.setCheckState(0)
2717 2718 else:
2718 2719 value = opObj.getParameterValue(parameterName='frequency')
2719 2720 value = str(float(value)/1e6)
2720 2721 self.volOpRadarfrequency.setText(value)
2721 2722 self.volOpRadarfrequency.setEnabled(True)
2722 2723 self.volOpCebRadarfrequency.setCheckState(QtCore.Qt.Checked)
2723 2724
2724 2725 opObj = puObj.getOperationObj(name="selectChannels")
2725 2726
2726 2727 if opObj == None:
2727 2728 opObj = puObj.getOperationObj(name="selectChannelsByIndex")
2728 2729
2729 2730 if opObj == None:
2730 2731 self.volOpChannel.clear()
2731 2732 self.volOpCebChannels.setCheckState(0)
2732 2733 else:
2733 2734 channelEnabled = False
2734 2735 try:
2735 2736 value = opObj.getParameterValue(parameterName='channelList')
2736 2737 value = str(value)[1:-1]
2737 2738 channelEnabled = True
2738 2739 channelMode = 0
2739 2740 except:
2740 2741 pass
2741 2742 try:
2742 2743 value = opObj.getParameterValue(parameterName='channelIndexList')
2743 2744 value = str(value)[1:-1]
2744 2745 channelEnabled = True
2745 2746 channelMode = 1
2746 2747 except:
2747 2748 pass
2748 2749
2749 2750 if channelEnabled:
2750 2751 self.volOpChannel.setText(value)
2751 2752 self.volOpChannel.setEnabled(True)
2752 2753 self.volOpCebChannels.setCheckState(QtCore.Qt.Checked)
2753 2754 self.volOpComChannels.setCurrentIndex(channelMode)
2754 2755
2755 2756 opObj = puObj.getOperationObj(name="selectHeights")
2756 2757 if opObj == None:
2757 2758 self.volOpHeights.clear()
2758 2759 self.volOpCebHeights.setCheckState(0)
2759 2760 else:
2760 2761 value1 = str(opObj.getParameterValue(parameterName='minHei'))
2761 2762 value2 = str(opObj.getParameterValue(parameterName='maxHei'))
2762 2763 value = value1 + "," + value2
2763 2764 self.volOpHeights.setText(value)
2764 2765 self.volOpHeights.setEnabled(True)
2765 2766 self.volOpCebHeights.setCheckState(QtCore.Qt.Checked)
2766 2767
2767 2768 opObj = puObj.getOperationObj(name="filterByHeights")
2768 2769 if opObj == None:
2769 2770 self.volOpFilter.clear()
2770 2771 self.volOpCebFilter.setCheckState(0)
2771 2772 else:
2772 2773 value = opObj.getParameterValue(parameterName='window')
2773 2774 value = str(value)
2774 2775 self.volOpFilter.setText(value)
2775 2776 self.volOpFilter.setEnabled(True)
2776 2777 self.volOpCebFilter.setCheckState(QtCore.Qt.Checked)
2777 2778
2778 2779 opObj = puObj.getOperationObj(name="ProfileSelector")
2779 2780 if opObj == None:
2780 2781 self.volOpProfile.clear()
2781 2782 self.volOpCebProfile.setCheckState(0)
2782 2783 else:
2783 2784 for parmObj in opObj.getParameterObjList():
2784 2785
2785 2786 if parmObj.name == "profileList":
2786 2787 value = parmObj.getValue()
2787 2788 value = str(value)[1:-1]
2788 2789 self.volOpProfile.setText(value)
2789 2790 self.volOpProfile.setEnabled(True)
2790 2791 self.volOpCebProfile.setCheckState(QtCore.Qt.Checked)
2791 2792 self.volOpComProfile.setCurrentIndex(0)
2792 2793
2793 2794 if parmObj.name == "profileRangeList":
2794 2795 value = parmObj.getValue()
2795 2796 value = str(value)[1:-1]
2796 2797 self.volOpProfile.setText(value)
2797 2798 self.volOpProfile.setEnabled(True)
2798 2799 self.volOpCebProfile.setCheckState(QtCore.Qt.Checked)
2799 2800 self.volOpComProfile.setCurrentIndex(1)
2800 2801
2801 2802 if parmObj.name == "rangeList":
2802 2803 value = parmObj.getValue()
2803 2804 value = str(value)[1:-1]
2804 2805 self.volOpProfile.setText(value)
2805 2806 self.volOpProfile.setEnabled(True)
2806 2807 self.volOpCebProfile.setCheckState(QtCore.Qt.Checked)
2807 2808 self.volOpComProfile.setCurrentIndex(2)
2808 2809
2809 2810 opObj = puObj.getOperationObj(name="Decoder")
2810 2811 self.volOpCode.setText("")
2811 2812 if opObj == None:
2812 2813 self.volOpCebDecodification.setCheckState(0)
2813 2814 else:
2814 2815 self.volOpCebDecodification.setCheckState(QtCore.Qt.Checked)
2815 2816
2816 2817 parmObj = opObj.getParameterObj('code')
2817 2818
2818 2819 if parmObj == None:
2819 2820 self.volOpComCode.setCurrentIndex(0)
2820 2821 else:
2821 2822
2822 2823 parmObj1 = opObj.getParameterObj('nCode')
2823 2824 parmObj2 = opObj.getParameterObj('nBaud')
2824 2825
2825 2826 if parmObj1 == None or parmObj2 == None:
2826 2827 self.volOpComCode.setCurrentIndex(0)
2827 2828 else:
2828 2829 code = ast.literal_eval(str(parmObj.getValue()))
2829 2830 nCode = parmObj1.getValue()
2830 2831 nBaud = parmObj2.getValue()
2831 2832
2832 2833 code = numpy.asarray(code).reshape((nCode, nBaud)).tolist()
2833 2834
2834 2835 #User defined by default
2835 2836 self.volOpComCode.setCurrentIndex(13)
2836 2837 self.volOpCode.setText(str(code))
2837 2838
2838 2839 if nCode == 1:
2839 2840 if nBaud == 3:
2840 2841 self.volOpComCode.setCurrentIndex(1)
2841 2842 if nBaud == 4:
2842 2843 self.volOpComCode.setCurrentIndex(2)
2843 2844 if nBaud == 5:
2844 2845 self.volOpComCode.setCurrentIndex(3)
2845 2846 if nBaud == 7:
2846 2847 self.volOpComCode.setCurrentIndex(4)
2847 2848 if nBaud == 11:
2848 2849 self.volOpComCode.setCurrentIndex(5)
2849 2850 if nBaud == 13:
2850 2851 self.volOpComCode.setCurrentIndex(6)
2851 2852
2852 2853 if nCode == 2:
2853 2854 if nBaud == 3:
2854 2855 self.volOpComCode.setCurrentIndex(7)
2855 2856 if nBaud == 4:
2856 2857 self.volOpComCode.setCurrentIndex(8)
2857 2858 if nBaud == 5:
2858 2859 self.volOpComCode.setCurrentIndex(9)
2859 2860 if nBaud == 7:
2860 2861 self.volOpComCode.setCurrentIndex(10)
2861 2862 if nBaud == 11:
2862 2863 self.volOpComCode.setCurrentIndex(11)
2863 2864 if nBaud == 13:
2864 2865 self.volOpComCode.setCurrentIndex(12)
2865 2866
2866 2867
2867 2868 opObj = puObj.getOperationObj(name="deFlip")
2868 2869 if opObj == None:
2869 2870 self.volOpFlip.clear()
2870 2871 self.volOpFlip.setEnabled(False)
2871 2872 self.volOpCebFlip.setCheckState(0)
2872 2873 else:
2873 2874 try:
2874 2875 value = opObj.getParameterValue(parameterName='channelList')
2875 2876 value = str(value)[1:-1]
2876 2877 except:
2877 2878 value = ""
2878 2879
2879 2880 self.volOpFlip.setText(value)
2880 2881 self.volOpFlip.setEnabled(True)
2881 2882 self.volOpCebFlip.setCheckState(QtCore.Qt.Checked)
2882 2883
2883 2884 opObj = puObj.getOperationObj(name="CohInt")
2884 2885 if opObj == None:
2885 2886 self.volOpCohInt.clear()
2886 2887 self.volOpCebCohInt.setCheckState(0)
2887 2888 else:
2888 2889 value = opObj.getParameterValue(parameterName='n')
2889 2890 self.volOpCohInt.setText(str(value))
2890 2891 self.volOpCohInt.setEnabled(True)
2891 2892 self.volOpCebCohInt.setCheckState(QtCore.Qt.Checked)
2892 2893
2893 2894 opObj = puObj.getOperationObj(name='Scope')
2894 2895 if opObj == None:
2895 2896 self.volGraphCebshow.setCheckState(0)
2896 2897 else:
2897 2898 self.volGraphCebshow.setCheckState(QtCore.Qt.Checked)
2898 2899
2899 2900 parmObj = opObj.getParameterObj(parameterName='channelList')
2900 2901
2901 2902 if parmObj == None:
2902 2903 self.volGraphChannelList.clear()
2903 2904 else:
2904 2905 value = parmObj.getValue()
2905 2906 value = str(value)
2906 2907 self.volGraphChannelList.setText(value)
2907 2908 self.volOpProfile.setEnabled(True)
2908 2909
2909 2910 parmObj1 = opObj.getParameterObj(parameterName='xmin')
2910 2911 parmObj2 = opObj.getParameterObj(parameterName='xmax')
2911 2912
2912 2913 if parmObj1 == None or parmObj2 ==None:
2913 2914 self.volGraphfreqrange.clear()
2914 2915 else:
2915 2916 value1 = parmObj1.getValue()
2916 2917 value1 = str(value1)
2917 2918 value2 = parmObj2.getValue()
2918 2919 value2 = str(value2)
2919 2920 value = value1 + "," + value2
2920 2921 self.volGraphfreqrange.setText(value)
2921 2922
2922 2923 parmObj1 = opObj.getParameterObj(parameterName='ymin')
2923 2924 parmObj2 = opObj.getParameterObj(parameterName='ymax')
2924 2925
2925 2926 if parmObj1 == None or parmObj2 ==None:
2926 2927 self.volGraphHeightrange.clear()
2927 2928 else:
2928 2929 value1 = parmObj1.getValue()
2929 2930 value1 = str(value1)
2930 2931 value2 = parmObj2.getValue()
2931 2932 value2 = str(value2)
2932 2933 value = value1 + "," + value2
2933 2934 value2 = str(value2)
2934 2935 self.volGraphHeightrange.setText(value)
2935 2936
2936 2937 parmObj = opObj.getParameterObj(parameterName='save')
2937 2938
2938 2939 if parmObj == None:
2939 2940 self.volGraphCebSave.setCheckState(QtCore.Qt.Unchecked)
2940 2941 else:
2941 2942 value = parmObj.getValue()
2942 2943 if value:
2943 2944 self.volGraphCebSave.setCheckState(QtCore.Qt.Checked)
2944 2945 else:
2945 2946 self.volGraphCebSave.setCheckState(QtCore.Qt.Unchecked)
2946 2947
2947 2948 parmObj = opObj.getParameterObj(parameterName='figpath')
2948 2949 if parmObj == None:
2949 2950 self.volGraphPath.clear()
2950 2951 else:
2951 2952 value = parmObj.getValue()
2952 2953 path = str(value)
2953 2954 self.volGraphPath.setText(path)
2954 2955
2955 2956 parmObj = opObj.getParameterObj(parameterName='figfile')
2956 2957 if parmObj == None:
2957 2958 self.volGraphPrefix.clear()
2958 2959 else:
2959 2960 value = parmObj.getValue()
2960 2961 figfile = str(value)
2961 2962 self.volGraphPrefix.setText(figfile)
2962 2963
2963 2964 # outputVoltageWrite
2964 2965 opObj = puObj.getOperationObj(name='VoltageWriter')
2965 2966
2966 2967 if opObj == None:
2967 2968 self.volOutputPath.clear()
2968 2969 self.volOutputblocksperfile.clear()
2969 2970 self.volOutputprofilesperblock.clear()
2970 2971 else:
2971 2972 parmObj = opObj.getParameterObj(parameterName='path')
2972 2973 if parmObj == None:
2973 2974 self.volOutputPath.clear()
2974 2975 else:
2975 2976 value = parmObj.getValue()
2976 2977 path = str(value)
2977 2978 self.volOutputPath.setText(path)
2978 2979
2979 2980 parmObj = opObj.getParameterObj(parameterName='blocksPerFile')
2980 2981 if parmObj == None:
2981 2982 self.volOutputblocksperfile.clear()
2982 2983 else:
2983 2984 value = parmObj.getValue()
2984 2985 blocksperfile = str(value)
2985 2986 self.volOutputblocksperfile.setText(blocksperfile)
2986 2987
2987 2988 parmObj = opObj.getParameterObj(parameterName='profilesPerBlock')
2988 2989 if parmObj == None:
2989 2990 self.volOutputprofilesperblock.clear()
2990 2991 else:
2991 2992 value = parmObj.getValue()
2992 2993 profilesPerBlock = str(value)
2993 2994 self.volOutputprofilesperblock.setText(profilesPerBlock)
2994 2995
2995 2996 return
2996 2997
2997 2998 def __refreshSpectraWindow(self, puObj):
2998 2999
2999 3000 inputId = puObj.getInputId()
3000 3001 inputPUObj = self.__puObjDict[inputId]
3001 3002
3002 3003 if inputPUObj.datatype == 'Voltage':
3003 3004 self.specOpnFFTpoints.setEnabled(True)
3004 3005 self.specOpProfiles.setEnabled(True)
3005 3006 self.specOpippFactor.setEnabled(True)
3006 3007 else:
3007 3008 self.specOpnFFTpoints.setEnabled(False)
3008 3009 self.specOpProfiles.setEnabled(False)
3009 3010 self.specOpippFactor.setEnabled(False)
3010 3011
3011 3012 opObj = puObj.getOperationObj(name='setRadarFrequency')
3012 3013 if opObj == None:
3013 3014 self.specOpRadarfrequency.clear()
3014 3015 self.specOpCebRadarfrequency.setCheckState(0)
3015 3016 else:
3016 3017 value = opObj.getParameterValue(parameterName='frequency')
3017 3018 value = str(float(value)/1e6)
3018 3019 self.specOpRadarfrequency.setText(value)
3019 3020 self.specOpRadarfrequency.setEnabled(True)
3020 3021 self.specOpCebRadarfrequency.setCheckState(QtCore.Qt.Checked)
3021 3022
3022 3023 opObj = puObj.getOperationObj(name="run")
3023 3024 if opObj == None:
3024 3025 self.specOpnFFTpoints.clear()
3025 3026 self.specOpProfiles.clear()
3026 3027 self.specOpippFactor.clear()
3027 3028 else:
3028 3029 parmObj = opObj.getParameterObj(parameterName='nFFTPoints')
3029 3030 if parmObj == None:
3030 3031 self.specOpnFFTpoints.clear()
3031 3032 else:
3032 3033 self.specOpnFFTpoints.setEnabled(True)
3033 3034 value = opObj.getParameterValue(parameterName='nFFTPoints')
3034 3035 self.specOpnFFTpoints.setText(str(value))
3035 3036
3036 3037 parmObj = opObj.getParameterObj(parameterName='nProfiles')
3037 3038 if parmObj == None:
3038 3039 self.specOpProfiles.clear()
3039 3040 else:
3040 3041 self.specOpProfiles.setEnabled(True)
3041 3042 value = opObj.getParameterValue(parameterName='nProfiles')
3042 3043 self.specOpProfiles.setText(str(value))
3043 3044
3044 3045 parmObj = opObj.getParameterObj(parameterName='ippFactor')
3045 3046 if parmObj == None:
3046 3047 self.specOpippFactor.clear()
3047 3048 else:
3048 3049 self.specOpippFactor.setEnabled(True)
3049 3050 value = opObj.getParameterValue(parameterName='ippFactor')
3050 3051 self.specOpippFactor.setText(str(value))
3051 3052
3052 3053 opObj = puObj.getOperationObj(name="run")
3053 3054 if opObj == None:
3054 3055 self.specOppairsList.clear()
3055 3056 self.specOpCebCrossSpectra.setCheckState(0)
3056 3057 else:
3057 3058 parmObj = opObj.getParameterObj(parameterName='pairsList')
3058 3059 if parmObj == None:
3059 3060 self.specOppairsList.clear()
3060 3061 self.specOpCebCrossSpectra.setCheckState(0)
3061 3062 else:
3062 3063 value = opObj.getParameterValue(parameterName='pairsList')
3063 3064 value = str(value)[1:-1]
3064 3065 self.specOppairsList.setText(str(value))
3065 3066 self.specOppairsList.setEnabled(True)
3066 3067 self.specOpCebCrossSpectra.setCheckState(QtCore.Qt.Checked)
3067 3068
3068 3069 opObj = puObj.getOperationObj(name="selectChannels")
3069 3070
3070 3071 if opObj == None:
3071 3072 opObj = puObj.getOperationObj(name="selectChannelsByIndex")
3072 3073
3073 3074 if opObj == None:
3074 3075 self.specOpChannel.clear()
3075 3076 self.specOpCebChannel.setCheckState(0)
3076 3077 else:
3077 3078 channelEnabled = False
3078 3079 try:
3079 3080 value = opObj.getParameterValue(parameterName='channelList')
3080 3081 value = str(value)[1:-1]
3081 3082 channelEnabled = True
3082 3083 channelMode = 0
3083 3084 except:
3084 3085 pass
3085 3086 try:
3086 3087 value = opObj.getParameterValue(parameterName='channelIndexList')
3087 3088 value = str(value)[1:-1]
3088 3089 channelEnabled = True
3089 3090 channelMode = 1
3090 3091 except:
3091 3092 pass
3092 3093
3093 3094 if channelEnabled:
3094 3095 self.specOpChannel.setText(value)
3095 3096 self.specOpChannel.setEnabled(True)
3096 3097 self.specOpCebChannel.setCheckState(QtCore.Qt.Checked)
3097 3098 self.specOpComChannel.setCurrentIndex(channelMode)
3098 3099
3099 3100 opObj = puObj.getOperationObj(name="selectHeights")
3100 3101 if opObj == None:
3101 3102 self.specOpHeights.clear()
3102 3103 self.specOpCebHeights.setCheckState(0)
3103 3104 else:
3104 3105 value1 = int(opObj.getParameterValue(parameterName='minHei'))
3105 3106 value1 = str(value1)
3106 3107 value2 = int(opObj.getParameterValue(parameterName='maxHei'))
3107 3108 value2 = str(value2)
3108 3109 value = value1 + "," + value2
3109 3110 self.specOpHeights.setText(value)
3110 3111 self.specOpHeights.setEnabled(True)
3111 3112 self.specOpCebHeights.setCheckState(QtCore.Qt.Checked)
3112 3113
3113 3114 opObj = puObj.getOperationObj(name="IncohInt")
3114 3115 if opObj == None:
3115 3116 self.specOpIncoherent.clear()
3116 3117 self.specOpCebIncoherent.setCheckState(0)
3117 3118 else:
3118 3119 for parmObj in opObj.getParameterObjList():
3119 3120 if parmObj.name == 'timeInterval':
3120 3121 value = opObj.getParameterValue(parameterName='timeInterval')
3121 3122 self.specOpIncoherent.setText(str(value))
3122 3123 self.specOpIncoherent.setEnabled(True)
3123 3124 self.specOpCebIncoherent.setCheckState(QtCore.Qt.Checked)
3124 3125 self.specOpCobIncInt.setCurrentIndex(0)
3125 3126
3126 3127 if parmObj.name == 'n':
3127 3128 value = opObj.getParameterValue(parameterName='n')
3128 3129 self.specOpIncoherent.setText(str(value))
3129 3130 self.specOpIncoherent.setEnabled(True)
3130 3131 self.specOpCebIncoherent.setCheckState(QtCore.Qt.Checked)
3131 3132 self.specOpCobIncInt.setCurrentIndex(1)
3132 3133
3133 3134 opObj = puObj.getOperationObj(name="removeDC")
3134 3135 if opObj == None:
3135 3136 self.specOpCebRemoveDC.setCheckState(0)
3136 3137 else:
3137 3138 self.specOpCebRemoveDC.setCheckState(QtCore.Qt.Checked)
3138 3139 value = opObj.getParameterValue(parameterName='mode')
3139 3140 if value == 1:
3140 3141 self.specOpComRemoveDC.setCurrentIndex(0)
3141 3142 elif value == 2:
3142 3143 self.specOpComRemoveDC.setCurrentIndex(1)
3143 3144
3144 3145 opObj = puObj.getOperationObj(name="removeInterference")
3145 3146 if opObj == None:
3146 3147 self.specOpCebRemoveInt.setCheckState(0)
3147 3148 else:
3148 3149 self.specOpCebRemoveInt.setCheckState(QtCore.Qt.Checked)
3149 3150
3150 3151 opObj = puObj.getOperationObj(name='getNoise')
3151 3152 if opObj == None:
3152 3153 self.specOpCebgetNoise.setCheckState(0)
3153 3154 self.specOpgetNoise.clear()
3154 3155 else:
3155 3156 self.specOpCebgetNoise.setCheckState(QtCore.Qt.Checked)
3156 3157 parmObj = opObj.getParameterObj(parameterName='minHei')
3157 3158 if parmObj == None:
3158 3159 self.specOpgetNoise.clear()
3159 3160 value1 = None
3160 3161 else:
3161 3162 value1 = opObj.getParameterValue(parameterName='minHei')
3162 3163 value1 = str(value1)
3163 3164 parmObj = opObj.getParameterObj(parameterName='maxHei')
3164 3165 if parmObj == None:
3165 3166 value2 = None
3166 3167 value = value1
3167 3168 self.specOpgetNoise.setText(value)
3168 3169 self.specOpgetNoise.setEnabled(True)
3169 3170 else:
3170 3171 value2 = opObj.getParameterValue(parameterName='maxHei')
3171 3172 value2 = str(value2)
3172 3173 parmObj = opObj.getParameterObj(parameterName='minVel')
3173 3174 if parmObj == None:
3174 3175 value3 = None
3175 3176 value = value1 + "," + value2
3176 3177 self.specOpgetNoise.setText(value)
3177 3178 self.specOpgetNoise.setEnabled(True)
3178 3179 else:
3179 3180 value3 = opObj.getParameterValue(parameterName='minVel')
3180 3181 value3 = str(value3)
3181 3182 parmObj = opObj.getParameterObj(parameterName='maxVel')
3182 3183 if parmObj == None:
3183 3184 value4 = None
3184 3185 value = value1 + "," + value2 + "," + value3
3185 3186 self.specOpgetNoise.setText(value)
3186 3187 self.specOpgetNoise.setEnabled(True)
3187 3188 else:
3188 3189 value4 = opObj.getParameterValue(parameterName='maxVel')
3189 3190 value4 = str(value4)
3190 3191 value = value1 + "," + value2 + "," + value3 + ',' + value4
3191 3192 self.specOpgetNoise.setText(value)
3192 3193 self.specOpgetNoise.setEnabled(True)
3193 3194
3194 3195 self.specGraphPath.clear()
3195 3196 self.specGraphPrefix.clear()
3196 3197 self.specGgraphFreq.clear()
3197 3198 self.specGgraphHeight.clear()
3198 3199 self.specGgraphDbsrange.clear()
3199 3200 self.specGgraphmagnitud.clear()
3200 3201 self.specGgraphPhase.clear()
3201 3202 self.specGgraphChannelList.clear()
3202 3203 self.specGgraphTminTmax.clear()
3203 3204 self.specGgraphTimeRange.clear()
3204 3205 self.specGgraphftpratio.clear()
3205 3206
3206 3207 opObj = puObj.getOperationObj(name='SpectraPlot')
3207 3208
3208 3209 if opObj == None:
3209 3210 self.specGraphCebSpectraplot.setCheckState(0)
3210 3211 self.specGraphSaveSpectra.setCheckState(0)
3211 3212 self.specGraphftpSpectra.setCheckState(0)
3212 3213 else:
3213 3214 operationSpectraPlot = "Enable"
3214 3215 self.specGraphCebSpectraplot.setCheckState(QtCore.Qt.Checked)
3215 3216 parmObj = opObj.getParameterObj(parameterName='channelList')
3216 3217 if parmObj == None:
3217 3218 self.specGgraphChannelList.clear()
3218 3219 else:
3219 3220 value = opObj.getParameterValue(parameterName='channelList')
3220 3221 channelListSpectraPlot = str(value)[1:-1]
3221 3222 self.specGgraphChannelList.setText(channelListSpectraPlot)
3222 3223 self.specGgraphChannelList.setEnabled(True)
3223 3224
3224 3225 parmObj = opObj.getParameterObj(parameterName='xmin')
3225 3226 if parmObj == None:
3226 3227 self.specGgraphFreq.clear()
3227 3228 else:
3228 3229 value1 = opObj.getParameterValue(parameterName='xmin')
3229 3230 value1 = str(value1)
3230 3231 value2 = opObj.getParameterValue(parameterName='xmax')
3231 3232 value2 = str(value2)
3232 3233 value = value1 + "," + value2
3233 3234 self.specGgraphFreq.setText(value)
3234 3235 self.specGgraphFreq.setEnabled(True)
3235 3236
3236 3237 parmObj = opObj.getParameterObj(parameterName='ymin')
3237 3238 if parmObj == None:
3238 3239 self.specGgraphHeight.clear()
3239 3240 else:
3240 3241 value1 = opObj.getParameterValue(parameterName='ymin')
3241 3242 value1 = str(value1)
3242 3243 value2 = opObj.getParameterValue(parameterName='ymax')
3243 3244 value2 = str(value2)
3244 3245 value = value1 + "," + value2
3245 3246 self.specGgraphHeight.setText(value)
3246 3247 self.specGgraphHeight.setEnabled(True)
3247 3248
3248 3249 parmObj = opObj.getParameterObj(parameterName='zmin')
3249 3250 if parmObj == None:
3250 3251 self.specGgraphDbsrange.clear()
3251 3252 else:
3252 3253 value1 = opObj.getParameterValue(parameterName='zmin')
3253 3254 value1 = str(value1)
3254 3255 value2 = opObj.getParameterValue(parameterName='zmax')
3255 3256 value2 = str(value2)
3256 3257 value = value1 + "," + value2
3257 3258 self.specGgraphDbsrange.setText(value)
3258 3259 self.specGgraphDbsrange.setEnabled(True)
3259 3260
3260 3261 parmObj = opObj.getParameterObj(parameterName="save")
3261 3262 if parmObj == None:
3262 3263 self.specGraphSaveSpectra.setCheckState(0)
3263 3264 else:
3264 3265 self.specGraphSaveSpectra.setCheckState(QtCore.Qt.Checked)
3265 3266
3266 3267 parmObj = opObj.getParameterObj(parameterName="ftp")
3267 3268 if parmObj == None:
3268 3269 self.specGraphftpSpectra.setCheckState(0)
3269 3270 else:
3270 3271 self.specGraphftpSpectra.setCheckState(QtCore.Qt.Checked)
3271 3272
3272 3273 parmObj = opObj.getParameterObj(parameterName="figpath")
3273 3274 if parmObj:
3274 3275 value = parmObj.getValue()
3275 3276 self.specGraphPath.setText(value)
3276 3277
3277 3278 parmObj = opObj.getParameterObj(parameterName="wr_period")
3278 3279 if parmObj:
3279 3280 value = parmObj.getValue()
3280 3281 self.specGgraphftpratio.setText(str(value))
3281 3282
3282 3283 opObj = puObj.getOperationObj(name='CrossSpectraPlot')
3283 3284
3284 3285 if opObj == None:
3285 3286 self.specGraphCebCrossSpectraplot.setCheckState(0)
3286 3287 self.specGraphSaveCross.setCheckState(0)
3287 3288 self.specGraphftpCross.setCheckState(0)
3288 3289 else:
3289 3290 operationCrossSpectraPlot = "Enable"
3290 3291 self.specGraphCebCrossSpectraplot.setCheckState(QtCore.Qt.Checked)
3291 3292 parmObj = opObj.getParameterObj(parameterName='xmin')
3292 3293 if parmObj == None:
3293 3294 self.specGgraphFreq.clear()
3294 3295 else:
3295 3296 value1 = opObj.getParameterValue(parameterName='xmin')
3296 3297 value1 = str(value1)
3297 3298 value2 = opObj.getParameterValue(parameterName='xmax')
3298 3299 value2 = str(value2)
3299 3300 value = value1 + "," + value2
3300 3301 self.specGgraphFreq.setText(value)
3301 3302 self.specGgraphFreq.setEnabled(True)
3302 3303
3303 3304 parmObj = opObj.getParameterObj(parameterName='ymin')
3304 3305 if parmObj == None:
3305 3306 self.specGgraphHeight.clear()
3306 3307 else:
3307 3308 value1 = opObj.getParameterValue(parameterName='ymin')
3308 3309 value1 = str(value1)
3309 3310 value2 = opObj.getParameterValue(parameterName='ymax')
3310 3311 value2 = str(value2)
3311 3312 value = value1 + "," + value2
3312 3313 self.specGgraphHeight.setText(value)
3313 3314 self.specGgraphHeight.setEnabled(True)
3314 3315
3315 3316 parmObj = opObj.getParameterObj(parameterName='zmin')
3316 3317 if parmObj == None:
3317 3318 self.specGgraphDbsrange.clear()
3318 3319 else:
3319 3320 value1 = opObj.getParameterValue(parameterName='zmin')
3320 3321 value1 = str(value1)
3321 3322 value2 = opObj.getParameterValue(parameterName='zmax')
3322 3323 value2 = str(value2)
3323 3324 value = value1 + "," + value2
3324 3325 self.specGgraphDbsrange.setText(value)
3325 3326 self.specGgraphDbsrange.setEnabled(True)
3326 3327
3327 3328 parmObj = opObj.getParameterObj(parameterName='coh_min')
3328 3329 if parmObj == None:
3329 3330 self.specGgraphmagnitud.clear()
3330 3331 else:
3331 3332 value1 = opObj.getParameterValue(parameterName='coh_min')
3332 3333 value1 = str(value1)
3333 3334 value2 = opObj.getParameterValue(parameterName='coh_max')
3334 3335 value2 = str(value2)
3335 3336 value = value1 + "," + value2
3336 3337 self.specGgraphmagnitud.setText(value)
3337 3338 self.specGgraphmagnitud.setEnabled(True)
3338 3339
3339 3340 parmObj = opObj.getParameterObj(parameterName='phase_min')
3340 3341 if parmObj == None:
3341 3342 self.specGgraphPhase.clear()
3342 3343 else:
3343 3344 value1 = opObj.getParameterValue(parameterName='phase_min')
3344 3345 value1 = str(value1)
3345 3346 value2 = opObj.getParameterValue(parameterName='phase_max')
3346 3347 value2 = str(value2)
3347 3348 value = value1 + "," + value2
3348 3349 self.specGgraphPhase.setText(value)
3349 3350 self.specGgraphPhase.setEnabled(True)
3350 3351
3351 3352 parmObj = opObj.getParameterObj(parameterName="save")
3352 3353 if parmObj == None:
3353 3354 self.specGraphSaveCross.setCheckState(0)
3354 3355 else:
3355 3356 self.specGraphSaveCross.setCheckState(QtCore.Qt.Checked)
3356 3357
3357 3358 parmObj = opObj.getParameterObj(parameterName="ftp")
3358 3359 if parmObj == None:
3359 3360 self.specGraphftpCross.setCheckState(0)
3360 3361 else:
3361 3362 self.specGraphftpCross.setCheckState(QtCore.Qt.Checked)
3362 3363
3363 3364 parmObj = opObj.getParameterObj(parameterName="figpath")
3364 3365 if parmObj:
3365 3366 value = parmObj.getValue()
3366 3367 self.specGraphPath.setText(value)
3367 3368
3368 3369 parmObj = opObj.getParameterObj(parameterName="wr_period")
3369 3370 if parmObj:
3370 3371 value = parmObj.getValue()
3371 3372 self.specGgraphftpratio.setText(str(value))
3372 3373
3373 3374 opObj = puObj.getOperationObj(name='RTIPlot')
3374 3375
3375 3376 if opObj == None:
3376 3377 self.specGraphCebRTIplot.setCheckState(0)
3377 3378 self.specGraphSaveRTIplot.setCheckState(0)
3378 3379 self.specGraphftpRTIplot.setCheckState(0)
3379 3380 else:
3380 3381 self.specGraphCebRTIplot.setCheckState(QtCore.Qt.Checked)
3381 3382 parmObj = opObj.getParameterObj(parameterName='channelList')
3382 3383 if parmObj == None:
3383 3384 self.specGgraphChannelList.clear()
3384 3385 else:
3385 3386 value = opObj.getParameterValue(parameterName='channelList')
3386 3387 channelListRTIPlot = str(value)[1:-1]
3387 3388 self.specGgraphChannelList.setText(channelListRTIPlot)
3388 3389 self.specGgraphChannelList.setEnabled(True)
3389 3390
3390 3391 parmObj = opObj.getParameterObj(parameterName='xmin')
3391 3392 if parmObj == None:
3392 3393 self.specGgraphTminTmax.clear()
3393 3394 else:
3394 3395 value1 = opObj.getParameterValue(parameterName='xmin')
3395 3396 value1 = str(value1)
3396 3397 value2 = opObj.getParameterValue(parameterName='xmax')
3397 3398 value2 = str(value2)
3398 3399 value = value1 + "," + value2
3399 3400 self.specGgraphTminTmax.setText(value)
3400 3401 self.specGgraphTminTmax.setEnabled(True)
3401 3402
3402 3403 parmObj = opObj.getParameterObj(parameterName='timerange')
3403 3404 if parmObj == None:
3404 3405 self.specGgraphTimeRange.clear()
3405 3406 else:
3406 3407 value1 = opObj.getParameterValue(parameterName='timerange')
3407 3408 value1 = str(value1)
3408 3409 self.specGgraphTimeRange.setText(value1)
3409 3410 self.specGgraphTimeRange.setEnabled(True)
3410 3411
3411 3412 parmObj = opObj.getParameterObj(parameterName='ymin')
3412 3413 if parmObj == None:
3413 3414 self.specGgraphHeight.clear()
3414 3415 else:
3415 3416 value1 = opObj.getParameterValue(parameterName='ymin')
3416 3417 value1 = str(value1)
3417 3418 value2 = opObj.getParameterValue(parameterName='ymax')
3418 3419 value2 = str(value2)
3419 3420 value = value1 + "," + value2
3420 3421 self.specGgraphHeight.setText(value)
3421 3422 self.specGgraphHeight.setEnabled(True)
3422 3423
3423 3424 parmObj = opObj.getParameterObj(parameterName='zmin')
3424 3425 if parmObj == None:
3425 3426 self.specGgraphDbsrange.clear()
3426 3427 else:
3427 3428 value1 = opObj.getParameterValue(parameterName='zmin')
3428 3429 value1 = str(value1)
3429 3430 value2 = opObj.getParameterValue(parameterName='zmax')
3430 3431 value2 = str(value2)
3431 3432 value = value1 + "," + value2
3432 3433 self.specGgraphDbsrange.setText(value)
3433 3434 self.specGgraphDbsrange.setEnabled(True)
3434 3435
3435 3436 parmObj = opObj.getParameterObj(parameterName="save")
3436 3437 if parmObj == None:
3437 3438 self.specGraphSaveRTIplot.setCheckState(0)
3438 3439 else:
3439 3440 self.specGraphSaveRTIplot.setCheckState(QtCore.Qt.Checked)
3440 3441
3441 3442 parmObj = opObj.getParameterObj(parameterName="ftp")
3442 3443 if parmObj == None:
3443 3444 self.specGraphftpRTIplot.setCheckState(0)
3444 3445 else:
3445 3446 self.specGraphftpRTIplot.setCheckState(QtCore.Qt.Checked)
3446 3447
3447 3448 parmObj = opObj.getParameterObj(parameterName="figpath")
3448 3449 if parmObj:
3449 3450 value = parmObj.getValue()
3450 3451 self.specGraphPath.setText(value)
3451 3452
3452 3453 parmObj = opObj.getParameterObj(parameterName="wr_period")
3453 3454 if parmObj:
3454 3455 value = parmObj.getValue()
3455 3456 self.specGgraphftpratio.setText(str(value))
3456 3457
3457 3458 opObj = puObj.getOperationObj(name='CoherenceMap')
3458 3459
3459 3460 if opObj == None:
3460 3461 self.specGraphCebCoherencmap.setCheckState(0)
3461 3462 self.specGraphSaveCoherencemap.setCheckState(0)
3462 3463 self.specGraphftpCoherencemap.setCheckState(0)
3463 3464 else:
3464 3465 operationCoherenceMap = "Enable"
3465 3466 self.specGraphCebCoherencmap.setCheckState(QtCore.Qt.Checked)
3466 3467 parmObj = opObj.getParameterObj(parameterName='xmin')
3467 3468 if parmObj == None:
3468 3469 self.specGgraphTminTmax.clear()
3469 3470 else:
3470 3471 value1 = opObj.getParameterValue(parameterName='xmin')
3471 3472 value1 = str(value1)
3472 3473 value2 = opObj.getParameterValue(parameterName='xmax')
3473 3474 value2 = str(value2)
3474 3475 value = value1 + "," + value2
3475 3476 self.specGgraphTminTmax.setText(value)
3476 3477 self.specGgraphTminTmax.setEnabled(True)
3477 3478
3478 3479 parmObj = opObj.getParameterObj(parameterName='timerange')
3479 3480 if parmObj == None:
3480 3481 self.specGgraphTimeRange.clear()
3481 3482 else:
3482 3483 value1 = opObj.getParameterValue(parameterName='timerange')
3483 3484 value1 = str(value1)
3484 3485 self.specGgraphTimeRange.setText(value1)
3485 3486 self.specGgraphTimeRange.setEnabled(True)
3486 3487
3487 3488 parmObj = opObj.getParameterObj(parameterName='ymin')
3488 3489 if parmObj == None:
3489 3490 self.specGgraphHeight.clear()
3490 3491 else:
3491 3492 value1 = opObj.getParameterValue(parameterName='ymin')
3492 3493 value1 = str(value1)
3493 3494 value2 = opObj.getParameterValue(parameterName='ymax')
3494 3495 value2 = str(value2)
3495 3496 value = value1 + "," + value2
3496 3497 self.specGgraphHeight.setText(value)
3497 3498 self.specGgraphHeight.setEnabled(True)
3498 3499
3499 3500 parmObj = opObj.getParameterObj(parameterName='zmin')
3500 3501 if parmObj == None:
3501 3502 self.specGgraphmagnitud.clear()
3502 3503 else:
3503 3504 value1 = opObj.getParameterValue(parameterName='zmin')
3504 3505 value1 = str(value1)
3505 3506 value2 = opObj.getParameterValue(parameterName='zmax')
3506 3507 value2 = str(value2)
3507 3508 value = value1 + "," + value2
3508 3509 self.specGgraphmagnitud.setText(value)
3509 3510 self.specGgraphmagnitud.setEnabled(True)
3510 3511
3511 3512 parmObj = opObj.getParameterObj(parameterName='coh_min')
3512 3513 if parmObj == None:
3513 3514 self.specGgraphmagnitud.clear()
3514 3515 else:
3515 3516 value1 = opObj.getParameterValue(parameterName='coh_min')
3516 3517 value1 = str(value1)
3517 3518 value2 = opObj.getParameterValue(parameterName='coh_max')
3518 3519 value2 = str(value2)
3519 3520 value = value1 + "," + value2
3520 3521 self.specGgraphmagnitud.setText(value)
3521 3522 self.specGgraphmagnitud.setEnabled(True)
3522 3523
3523 3524 parmObj = opObj.getParameterObj(parameterName='phase_min')
3524 3525 if parmObj == None:
3525 3526 self.specGgraphPhase.clear()
3526 3527 else:
3527 3528 value1 = opObj.getParameterValue(parameterName='phase_min')
3528 3529 value1 = str(value1)
3529 3530 value2 = opObj.getParameterValue(parameterName='phase_max')
3530 3531 value2 = str(value2)
3531 3532 value = value1 + "," + value2
3532 3533 self.specGgraphPhase.setText(value)
3533 3534 self.specGgraphPhase.setEnabled(True)
3534 3535
3535 3536 parmObj = opObj.getParameterObj(parameterName="save")
3536 3537 if parmObj == None:
3537 3538 self.specGraphSaveCoherencemap.setCheckState(0)
3538 3539 else:
3539 3540 self.specGraphSaveCoherencemap.setCheckState(QtCore.Qt.Checked)
3540 3541
3541 3542 parmObj = opObj.getParameterObj(parameterName="ftp")
3542 3543 if parmObj == None:
3543 3544 self.specGraphftpCoherencemap.setCheckState(0)
3544 3545 else:
3545 3546 self.specGraphftpCoherencemap.setCheckState(QtCore.Qt.Checked)
3546 3547
3547 3548 parmObj = opObj.getParameterObj(parameterName="figpath")
3548 3549 if parmObj:
3549 3550 value = parmObj.getValue()
3550 3551 self.specGraphPath.setText(value)
3551 3552
3552 3553 parmObj = opObj.getParameterObj(parameterName="wr_period")
3553 3554 if parmObj:
3554 3555 value = parmObj.getValue()
3555 3556 self.specGgraphftpratio.setText(str(value))
3556 3557
3557 3558 opObj = puObj.getOperationObj(name='PowerProfilePlot')
3558 3559
3559 3560 if opObj == None:
3560 3561 self.specGraphPowerprofile.setCheckState(0)
3561 3562 self.specGraphSavePowerprofile.setCheckState(0)
3562 3563 self.specGraphftpPowerprofile.setCheckState(0)
3563 3564 operationPowerProfilePlot = "Disabled"
3564 3565 channelList = None
3565 3566 freq_vel = None
3566 3567 heightsrange = None
3567 3568 else:
3568 3569 operationPowerProfilePlot = "Enable"
3569 3570 self.specGraphPowerprofile.setCheckState(QtCore.Qt.Checked)
3570 3571 parmObj = opObj.getParameterObj(parameterName='xmin')
3571 3572 if parmObj == None:
3572 3573 self.specGgraphDbsrange.clear()
3573 3574 else:
3574 3575 value1 = opObj.getParameterValue(parameterName='xmin')
3575 3576 value1 = str(value1)
3576 3577 value2 = opObj.getParameterValue(parameterName='xmax')
3577 3578 value2 = str(value2)
3578 3579 value = value1 + "," + value2
3579 3580 self.specGgraphDbsrange.setText(value)
3580 3581 self.specGgraphDbsrange.setEnabled(True)
3581 3582
3582 3583 parmObj = opObj.getParameterObj(parameterName='ymin')
3583 3584 if parmObj == None:
3584 3585 self.specGgraphHeight.clear()
3585 3586 else:
3586 3587 value1 = opObj.getParameterValue(parameterName='ymin')
3587 3588 value1 = str(value1)
3588 3589 value2 = opObj.getParameterValue(parameterName='ymax')
3589 3590 value2 = str(value2)
3590 3591 value = value1 + "," + value2
3591 3592 self.specGgraphHeight.setText(value)
3592 3593 self.specGgraphHeight.setEnabled(True)
3593 3594
3594 3595 parmObj = opObj.getParameterObj(parameterName="save")
3595 3596 if parmObj == None:
3596 3597 self.specGraphSavePowerprofile.setCheckState(0)
3597 3598 else:
3598 3599 self.specGraphSavePowerprofile.setCheckState(QtCore.Qt.Checked)
3599 3600
3600 3601 parmObj = opObj.getParameterObj(parameterName="ftp")
3601 3602 if parmObj == None:
3602 3603 self.specGraphftpPowerprofile.setCheckState(0)
3603 3604 else:
3604 3605 self.specGraphftpPowerprofile.setCheckState(QtCore.Qt.Checked)
3605 3606
3606 3607 parmObj = opObj.getParameterObj(parameterName="figpath")
3607 3608 if parmObj:
3608 3609 value = parmObj.getValue()
3609 3610 self.specGraphPath.setText(value)
3610 3611
3611 3612 parmObj = opObj.getParameterObj(parameterName="wr_period")
3612 3613 if parmObj:
3613 3614 value = parmObj.getValue()
3614 3615 self.specGgraphftpratio.setText(str(value))
3615 3616
3616 3617 opObj = puObj.getOperationObj(name='Noise')
3617 3618
3618 3619 if opObj == None:
3619 3620 self.specGraphCebRTInoise.setCheckState(0)
3620 3621 self.specGraphSaveRTInoise.setCheckState(0)
3621 3622 self.specGraphftpRTInoise.setCheckState(0)
3622 3623 else:
3623 3624 self.specGraphCebRTInoise.setCheckState(QtCore.Qt.Checked)
3624 3625 parmObj = opObj.getParameterObj(parameterName='channelList')
3625 3626 if parmObj == None:
3626 3627 self.specGgraphChannelList.clear()
3627 3628 else:
3628 3629 value = opObj.getParameterValue(parameterName='channelList')
3629 3630 channelListRTINoise = str(value)[1:-1]
3630 3631 self.specGgraphChannelList.setText(channelListRTINoise)
3631 3632 self.specGgraphChannelList.setEnabled(True)
3632 3633
3633 3634 parmObj = opObj.getParameterObj(parameterName='xmin')
3634 3635 if parmObj == None:
3635 3636 self.specGgraphTminTmax.clear()
3636 3637 else:
3637 3638 value1 = opObj.getParameterValue(parameterName='xmin')
3638 3639 value1 = str(value1)
3639 3640 value2 = opObj.getParameterValue(parameterName='xmax')
3640 3641 value2 = str(value2)
3641 3642 value = value1 + "," + value2
3642 3643 self.specGgraphTminTmax.setText(value)
3643 3644 self.specGgraphTminTmax.setEnabled(True)
3644 3645
3645 3646 parmObj = opObj.getParameterObj(parameterName='timerange')
3646 3647 if parmObj == None:
3647 3648 self.specGgraphTimeRange.clear()
3648 3649 else:
3649 3650 value1 = opObj.getParameterValue(parameterName='timerange')
3650 3651 value1 = str(value1)
3651 3652 self.specGgraphTimeRange.setText(value1)
3652 3653 self.specGgraphTimeRange.setEnabled(True)
3653 3654
3654 3655
3655 3656 parmObj = opObj.getParameterObj(parameterName='ymin')
3656 3657 if parmObj == None:
3657 3658 self.specGgraphDbsrange.clear()
3658 3659 else:
3659 3660 value1 = opObj.getParameterValue(parameterName='ymin')
3660 3661 value1 = str(value1)
3661 3662 value2 = opObj.getParameterValue(parameterName='ymax')
3662 3663 value2 = str(value2)
3663 3664 value = value1 + "," + value2
3664 3665 self.specGgraphDbsrange.setText(value)
3665 3666 self.specGgraphDbsrange.setEnabled(True)
3666 3667
3667 3668 parmObj = opObj.getParameterObj(parameterName="save")
3668 3669 if parmObj == None:
3669 3670 self.specGraphSaveRTInoise.setCheckState(0)
3670 3671 else:
3671 3672 self.specGraphSaveRTInoise.setCheckState(QtCore.Qt.Checked)
3672 3673
3673 3674 parmObj = opObj.getParameterObj(parameterName="ftp")
3674 3675 if parmObj == None:
3675 3676 self.specGraphftpRTInoise.setCheckState(0)
3676 3677 else:
3677 3678 self.specGraphftpRTInoise.setCheckState(QtCore.Qt.Checked)
3678 3679
3679 3680 parmObj = opObj.getParameterObj(parameterName="figpath")
3680 3681 if parmObj:
3681 3682 value = parmObj.getValue()
3682 3683 self.specGraphPath.setText(value)
3683 3684
3684 3685 parmObj = opObj.getParameterObj(parameterName="wr_period")
3685 3686 if parmObj:
3686 3687 value = parmObj.getValue()
3687 3688 self.specGgraphftpratio.setText(str(value))
3688 3689
3689 3690 opObj = puObj.getOperationObj(name='SpectraWriter')
3690 3691 if opObj == None:
3691 3692 self.specOutputPath.clear()
3692 3693 self.specOutputblocksperfile.clear()
3693 3694 else:
3694 3695 value = opObj.getParameterObj(parameterName='path')
3695 3696 if value == None:
3696 3697 self.specOutputPath.clear()
3697 3698 else:
3698 3699 value = opObj.getParameterValue(parameterName='path')
3699 3700 path = str(value)
3700 3701 self.specOutputPath.setText(path)
3701 3702 value = opObj.getParameterObj(parameterName='blocksPerFile')
3702 3703 if value == None:
3703 3704 self.specOutputblocksperfile.clear()
3704 3705 else:
3705 3706 value = opObj.getParameterValue(parameterName='blocksPerFile')
3706 3707 blocksperfile = str(value)
3707 3708 self.specOutputblocksperfile.setText(blocksperfile)
3708 3709
3709 3710 return
3710 3711
3711 3712 def __refreshSpectraHeisWindow(self, puObj):
3712 3713
3713 3714 opObj = puObj.getOperationObj(name="IncohInt4SpectraHeis")
3714 3715 if opObj == None:
3715 3716 self.specHeisOpIncoherent.clear()
3716 3717 self.specHeisOpCebIncoherent.setCheckState(0)
3717 3718 else:
3718 3719 for parmObj in opObj.getParameterObjList():
3719 3720 if parmObj.name == 'timeInterval':
3720 3721 value = opObj.getParameterValue(parameterName='timeInterval')
3721 3722 self.specHeisOpIncoherent.setText(str(value))
3722 3723 self.specHeisOpIncoherent.setEnabled(True)
3723 3724 self.specHeisOpCebIncoherent.setCheckState(QtCore.Qt.Checked)
3724 3725 self.specHeisOpCobIncInt.setCurrentIndex(0)
3725 3726
3726 3727 # SpectraHeis Graph
3727 3728
3728 3729 self.specHeisGgraphXminXmax.clear()
3729 3730 self.specHeisGgraphYminYmax.clear()
3730 3731
3731 3732 self.specHeisGgraphChannelList.clear()
3732 3733 self.specHeisGgraphTminTmax.clear()
3733 3734 self.specHeisGgraphTimeRange.clear()
3734 3735 self.specHeisGgraphftpratio.clear()
3735 3736
3736 3737 opObj = puObj.getOperationObj(name='SpectraHeisScope')
3737 3738 if opObj == None:
3738 3739 self.specHeisGraphCebSpectraplot.setCheckState(0)
3739 3740 self.specHeisGraphSaveSpectra.setCheckState(0)
3740 3741 self.specHeisGraphftpSpectra.setCheckState(0)
3741 3742 else:
3742 3743 operationSpectraHeisScope = "Enable"
3743 3744 self.specHeisGraphCebSpectraplot.setCheckState(QtCore.Qt.Checked)
3744 3745
3745 3746 parmObj = opObj.getParameterObj(parameterName='channelList')
3746 3747 if parmObj == None:
3747 3748 self.specHeisGgraphChannelList.clear()
3748 3749 else:
3749 3750 value = opObj.getParameterValue(parameterName='channelList')
3750 3751 channelListSpectraHeisScope = str(value)[1:-1]
3751 3752 self.specHeisGgraphChannelList.setText(channelListSpectraHeisScope)
3752 3753 self.specHeisGgraphChannelList.setEnabled(True)
3753 3754
3754 3755 parmObj = opObj.getParameterObj(parameterName='xmin')
3755 3756 if parmObj == None:
3756 3757 self.specHeisGgraphXminXmax.clear()
3757 3758 else:
3758 3759 value1 = opObj.getParameterValue(parameterName='xmin')
3759 3760 value1 = str(value1)
3760 3761 value2 = opObj.getParameterValue(parameterName='xmax')
3761 3762 value2 = str(value2)
3762 3763 value = value1 + "," + value2
3763 3764 self.specHeisGgraphXminXmax.setText(value)
3764 3765 self.specHeisGgraphXminXmax.setEnabled(True)
3765 3766
3766 3767 parmObj = opObj.getParameterObj(parameterName='ymin')
3767 3768 if parmObj == None:
3768 3769 self.specHeisGgraphYminYmax.clear()
3769 3770 else:
3770 3771 value1 = opObj.getParameterValue(parameterName='ymin')
3771 3772 value1 = str(value1)
3772 3773 value2 = opObj.getParameterValue(parameterName='ymax')
3773 3774 value2 = str(value2)
3774 3775 value = value1 + "," + value2
3775 3776 self.specHeisGgraphYminYmax.setText(value)
3776 3777 self.specHeisGgraphYminYmax.setEnabled(True)
3777 3778
3778 3779 parmObj = opObj.getParameterObj(parameterName="save")
3779 3780 if parmObj == None:
3780 3781 self.specHeisGraphSaveSpectra.setCheckState(0)
3781 3782 else:
3782 3783 self.specHeisGraphSaveSpectra.setCheckState(QtCore.Qt.Checked)
3783 3784
3784 3785 parmObj = opObj.getParameterObj(parameterName="ftp")
3785 3786 if parmObj == None:
3786 3787 self.specHeisGraphftpSpectra.setCheckState(0)
3787 3788 else:
3788 3789 self.specHeisGraphftpSpectra.setCheckState(QtCore.Qt.Checked)
3789 3790
3790 3791 parmObj = opObj.getParameterObj(parameterName="figpath")
3791 3792 if parmObj:
3792 3793 value = parmObj.getValue()
3793 3794 self.specHeisGraphPath.setText(value)
3794 3795
3795 3796 parmObj = opObj.getParameterObj(parameterName="wr_period")
3796 3797 if parmObj:
3797 3798 value = parmObj.getValue()
3798 3799 self.specHeisGgraphftpratio.setText(str(value))
3799 3800
3800 3801 opObj = puObj.getOperationObj(name='RTIfromSpectraHeis')
3801 3802
3802 3803 if opObj == None:
3803 3804 self.specHeisGraphCebRTIplot.setCheckState(0)
3804 3805 self.specHeisGraphSaveRTIplot.setCheckState(0)
3805 3806 self.specHeisGraphftpRTIplot.setCheckState(0)
3806 3807 else:
3807 3808 self.specHeisGraphCebRTIplot.setCheckState(QtCore.Qt.Checked)
3808 3809 parmObj = opObj.getParameterObj(parameterName='channelList')
3809 3810 if parmObj == None:
3810 3811 self.specHeisGgraphChannelList.clear()
3811 3812 else:
3812 3813 value = opObj.getParameterValue(parameterName='channelList')
3813 3814 channelListRTIPlot = str(value)[1:-1]
3814 3815 self.specGgraphChannelList.setText(channelListRTIPlot)
3815 3816 self.specGgraphChannelList.setEnabled(True)
3816 3817
3817 3818 parmObj = opObj.getParameterObj(parameterName='xmin')
3818 3819 if parmObj == None:
3819 3820 self.specHeisGgraphTminTmax.clear()
3820 3821 else:
3821 3822 value1 = opObj.getParameterValue(parameterName='xmin')
3822 3823 value1 = str(value1)
3823 3824 value2 = opObj.getParameterValue(parameterName='xmax')
3824 3825 value2 = str(value2)
3825 3826 value = value1 + "," + value2
3826 3827 self.specHeisGgraphTminTmax.setText(value)
3827 3828 self.specHeisGgraphTminTmax.setEnabled(True)
3828 3829
3829 3830 parmObj = opObj.getParameterObj(parameterName='timerange')
3830 3831 if parmObj == None:
3831 3832 self.specGgraphTimeRange.clear()
3832 3833 else:
3833 3834 value1 = opObj.getParameterValue(parameterName='timerange')
3834 3835 value1 = str(value1)
3835 3836 self.specHeisGgraphTimeRange.setText(value1)
3836 3837 self.specHeisGgraphTimeRange.setEnabled(True)
3837 3838
3838 3839 parmObj = opObj.getParameterObj(parameterName='ymin')
3839 3840 if parmObj == None:
3840 3841 self.specHeisGgraphYminYmax.clear()
3841 3842 else:
3842 3843 value1 = opObj.getParameterValue(parameterName='ymin')
3843 3844 value1 = str(value1)
3844 3845 value2 = opObj.getParameterValue(parameterName='ymax')
3845 3846 value2 = str(value2)
3846 3847 value = value1 + "," + value2
3847 3848 self.specHeisGgraphYminYmax.setText(value)
3848 3849 self.specHeisGgraphYminYmax.setEnabled(True)
3849 3850
3850 3851 parmObj = opObj.getParameterObj(parameterName="save")
3851 3852 if parmObj == None:
3852 3853 self.specHeisGraphSaveRTIplot.setCheckState(0)
3853 3854 else:
3854 3855 self.specHeisGraphSaveRTIplot.setCheckState(QtCore.Qt.Checked)
3855 3856
3856 3857 parmObj = opObj.getParameterObj(parameterName="ftp")
3857 3858 if parmObj == None:
3858 3859 self.specHeisGraphftpRTIplot.setCheckState(0)
3859 3860 else:
3860 3861 self.specHeisGraphftpRTIplot.setCheckState(QtCore.Qt.Checked)
3861 3862
3862 3863 parmObj = opObj.getParameterObj(parameterName="figpath")
3863 3864 if parmObj:
3864 3865 value = parmObj.getValue()
3865 3866 self.specHeisGraphPath.setText(value)
3866 3867
3867 3868 parmObj = opObj.getParameterObj(parameterName="wr_period")
3868 3869 if parmObj:
3869 3870 value = parmObj.getValue()
3870 3871 self.specHeisGgraphftpratio.setText(str(value))
3871 3872
3872 3873 # outputSpectraHeisWrite
3873 3874 opObj = puObj.getOperationObj(name='FitsWriter')
3874 3875 if opObj == None:
3875 3876 self.specHeisOutputPath.clear()
3876 3877 self.specHeisOutputblocksperfile.clear()
3877 3878 self.specHeisOutputMetada.clear()
3878 3879 else:
3879 3880 value = opObj.getParameterObj(parameterName='path')
3880 3881 if value == None:
3881 3882 self.specHeisOutputPath.clear()
3882 3883 else:
3883 3884 value = opObj.getParameterValue(parameterName='path')
3884 3885 path = str(value)
3885 3886 self.specHeisOutputPath.setText(path)
3886 3887 value = opObj.getParameterObj(parameterName='dataBlocksPerFile')
3887 3888 if value == None:
3888 3889 self.specHeisOutputblocksperfile.clear()
3889 3890 else:
3890 3891 value = opObj.getParameterValue(parameterName='dataBlocksPerFile')
3891 3892 blocksperfile = str(value)
3892 3893 self.specHeisOutputblocksperfile.setText(blocksperfile)
3893 3894 value = opObj.getParameterObj(parameterName='metadatafile')
3894 3895 if value == None:
3895 3896 self.specHeisOutputMetada.clear()
3896 3897 else:
3897 3898 value = opObj.getParameterValue(parameterName='metadatafile')
3898 3899 metadata_file = str(value)
3899 3900 self.specHeisOutputMetada.setText(metadata_file)
3900 3901
3901 3902 return
3902 3903
3903 3904 def __refreshCorrelationWindow(self, puObj):
3904 3905 pass
3905 3906
3906 3907 def refreshPUWindow(self, puObj):
3907 3908
3908 3909 if puObj.datatype == 'Voltage':
3909 3910 self.__refreshVoltageWindow(puObj)
3910 3911
3911 3912 if puObj.datatype == 'Spectra':
3912 3913 self.__refreshSpectraWindow(puObj)
3913 3914
3914 3915 if puObj.datatype == 'SpectraHeis':
3915 3916 self.__refreshSpectraHeisWindow(puObj)
3916 3917
3917 3918 def refreshProjectProperties(self, projectObjView):
3918 3919
3919 3920 propertyBuffObj = PropertyBuffer()
3920 3921 name = projectObjView.name
3921 3922
3922 3923 propertyBuffObj.append("Properties", "Name", projectObjView.name),
3923 3924 propertyBuffObj.append("Properties", "Description", projectObjView.description)
3924 3925 propertyBuffObj.append("Properties", "Workspace", self.pathWorkSpace)
3925 3926
3926 3927 readUnitObj = projectObjView.getReadUnitObj()
3927 3928 runOperationObj = readUnitObj.getOperationObj(name='run')
3928 3929
3929 3930 for thisParmObj in runOperationObj.getParameterObjList():
3930 3931 propertyBuffObj.append("Reading parms", thisParmObj.name, str(thisParmObj.getValue()))
3931 3932
3932 3933 propertiesModel = propertyBuffObj.getPropertyModel()
3933 3934
3934 3935 self.treeProjectProperties.setModel(propertiesModel)
3935 3936 self.treeProjectProperties.expandAll()
3936 3937 self.treeProjectProperties.resizeColumnToContents(0)
3937 3938 self.treeProjectProperties.resizeColumnToContents(1)
3938 3939
3939 3940 def refreshPUProperties(self, puObjView):
3940 3941
3941 3942 ############ FTP CONFIG ################################
3942 3943 #Deleting FTP Conf. This processing unit have not got any
3943 3944 #FTP configuration by default
3944 3945 if puObjView.id in self.__puLocalFolder2FTP.keys():
3945 3946 self.__puLocalFolder2FTP.pop(puObjView.id)
3946 3947 ########################################################
3947 3948
3948 3949 propertyBuffObj = PropertyBuffer()
3949 3950
3950 3951 for thisOp in puObjView.getOperationObjList():
3951 3952
3952 3953 operationName = thisOp.name
3953 3954
3954 3955 if operationName == 'run':
3955 3956 operationName = 'Properties'
3956 3957
3957 3958 else:
3958 3959 if not thisOp.getParameterObjList():
3959 3960 propertyBuffObj.append(operationName, '--', '--')
3960 3961 continue
3961 3962
3962 3963 for thisParmObj in thisOp.getParameterObjList():
3963 3964 propertyBuffObj.append(operationName, thisParmObj.name, str(thisParmObj.getValue()))
3964 3965
3965 3966 ############ FTP CONFIG ################################
3966 3967 if thisParmObj.name == "ftp_wei" and thisParmObj.getValue():
3967 3968 value = thisParmObj.getValue()
3968 3969 self.temporalFTP.ftp_wei = value
3969 3970
3970 3971 if thisParmObj.name == "exp_code" and thisParmObj.getValue():
3971 3972 value = thisParmObj.getValue()
3972 3973 self.temporalFTP.exp_code = value
3973 3974
3974 3975 if thisParmObj.name == "sub_exp_code" and thisParmObj.getValue():
3975 3976 value = thisParmObj.getValue()
3976 3977 self.temporalFTP.sub_exp_code = value
3977 3978
3978 3979 if thisParmObj.name == "plot_pos" and thisParmObj.getValue():
3979 3980 value = thisParmObj.getValue()
3980 3981 self.temporalFTP.plot_pos = value
3981 3982
3982 3983 if thisParmObj.name == 'ftp' and thisParmObj.getValue():
3983 3984 figpathObj = thisOp.getParameterObj('figpath')
3984 3985 if figpathObj:
3985 3986 self.__puLocalFolder2FTP[puObjView.id] = figpathObj.getValue()
3986 3987
3987 3988 ########################################################
3988 3989
3989 3990 propertiesModel = propertyBuffObj.getPropertyModel()
3990 3991
3991 3992 self.treeProjectProperties.setModel(propertiesModel)
3992 3993 self.treeProjectProperties.expandAll()
3993 3994 self.treeProjectProperties.resizeColumnToContents(0)
3994 3995 self.treeProjectProperties.resizeColumnToContents(1)
3995 3996
3996 3997 def refreshGraphicsId(self):
3997 3998
3998 3999 projectObj = self.getSelectedProjectObj()
3999 4000
4000 4001 if not projectObj:
4001 4002 return
4002 4003
4003 4004 for idPU, puObj in projectObj.procUnitConfObjDict.items():
4004 4005
4005 4006 for opObj in puObj.getOperationObjList():
4006 4007
4007 4008 if opObj.name not in ('Scope', 'SpectraPlot', 'CrossSpectraPlot', 'RTIPlot', 'CoherenceMap', 'PowerProfilePlot', 'Noise', 'SpectraHeisScope', 'RTIfromSpectraHeis'):
4008 4009 continue
4009 4010
4010 4011 opObj.changeParameter(name='id', value=opObj.id, format='int')
4011 4012
4012 4013 def on_click(self, index):
4013 4014
4014 4015 self.selectedItemTree = self.projectExplorerModel.itemFromIndex(index)
4015 4016
4016 4017 projectObjView = self.getSelectedProjectObj()
4017 4018
4018 4019 if not projectObjView:
4019 4020 return
4020 4021
4021 4022 self.create = False
4022 4023 selectedObjView = self.getSelectedItemObj()
4023 4024
4024 4025 #A project has been selected
4025 4026 if projectObjView == selectedObjView:
4026 4027
4027 4028 self.refreshProjectWindow(projectObjView)
4028 4029 self.refreshProjectProperties(projectObjView)
4029 4030
4030 4031 self.tabProject.setEnabled(True)
4031 4032 self.tabVoltage.setEnabled(False)
4032 4033 self.tabSpectra.setEnabled(False)
4033 4034 self.tabCorrelation.setEnabled(False)
4034 4035 self.tabSpectraHeis.setEnabled(False)
4035 4036 self.tabWidgetProject.setCurrentWidget(self.tabProject)
4036 4037
4037 4038 return
4038 4039
4039 4040 #A processing unit has been selected
4040 4041 voltEnable = False
4041 4042 specEnable = False
4042 4043 corrEnable = False
4043 4044 specHeisEnable = False
4044 4045 tabSelected = self.tabProject
4045 4046
4046 4047 puObj = selectedObjView
4047 4048
4048 4049 self.refreshPUWindow(puObj)
4049 4050 self.refreshPUProperties(puObj)
4050 4051 self.showtabPUCreated(puObj.datatype)
4051 4052
4052 4053 def on_right_click(self, pos):
4053 4054
4054 4055 self.menu = QtGui.QMenu()
4055 4056 quitAction0 = self.menu.addAction("Create a New Project")
4056 4057 quitAction1 = self.menu.addAction("Create a New Processing Unit")
4057 4058 quitAction2 = self.menu.addAction("Delete Item")
4058 4059 quitAction3 = self.menu.addAction("Quit")
4059 4060
4060 4061 if len(self.__itemTreeDict) == 0:
4061 4062 quitAction2.setEnabled(False)
4062 4063 else:
4063 4064 quitAction2.setEnabled(True)
4064 4065
4065 4066 action = self.menu.exec_(self.mapToGlobal(pos))
4066 4067
4067 4068 if action == quitAction0:
4068 4069 self. setInputsProject_View()
4069 4070 self.create = True
4070 4071
4071 4072 if action == quitAction1:
4072 4073 if len(self.__projectObjDict) == 0:
4073 4074 outputstr = "You need to create a Project before adding a Processing Unit"
4074 4075 self.console.clear()
4075 4076 self.console.append(outputstr)
4076 4077 return 0
4077 4078 else:
4078 4079 self.addPUWindow()
4079 4080 self.console.clear()
4080 4081 self.console.append("Please, Choose the type of Processing Unit")
4081 4082 # self.console.append("If your Datatype is rawdata, you will start with processing unit Type Voltage")
4082 4083 # self.console.append("If your Datatype is pdata, you will choose between processing unit Type Spectra or Correlation")
4083 4084 # self.console.append("If your Datatype is fits, you will start with processing unit Type SpectraHeis")
4084 4085
4085 4086 if action == quitAction2:
4086 4087 index = self.selectedItemTree
4087 4088 try:
4088 4089 index.parent()
4089 4090 except:
4090 4091 self.console.append('Please, first at all select a Project or Processing Unit')
4091 4092 return 0
4092 4093 # print index.parent(),index
4093 4094 if index.parent() == None:
4094 4095 self.projectExplorerModel.removeRow(index.row())
4095 4096 else:
4096 4097 index.parent().removeRow(index.row())
4097 4098 self.removeItemTreeFromProject()
4098 4099 self.console.clear()
4099 4100 # for i in self.projectExplorerTree.selectionModel().selection().indexes():
4100 4101 # print i.row()
4101 4102
4102 4103 if action == quitAction3:
4103 4104 self.close()
4104 4105 return 0
4105 4106
4106 4107 def createProjectView(self, id):
4107 4108
4108 4109 # project_name, description, datatype, data_path, starDate, endDate, startTime, endTime, online, delay, walk, set = self.getParmsFromProjectWindow()
4109 4110 id = str(id)
4110 4111 projectParms = self.__getParmsFromProjectWindow()
4111 4112
4112 4113 if not projectParms.isValid():
4113 4114 return None
4114 4115
4115 4116 projectObjView = Project()
4116 4117 projectObjView.setup(id=id, name=projectParms.name, description=projectParms.description)
4117 4118
4118 4119 self.__projectObjDict[id] = projectObjView
4119 4120 self.addProject2ProjectExplorer(id=id, name=projectObjView.name)
4120 4121
4121 4122 return projectObjView
4122 4123
4123 4124 def updateProjectView(self):
4124 4125
4125 4126 # project_name, description, datatype, data_path, starDate, endDate, startTime, endTime, online, delay, walk, set = self.getParmsFromProjectWindow()
4126 4127
4127 4128 projectParms = self.__getParmsFromProjectWindow()
4128 4129
4129 4130 if not projectParms.isValid():
4130 4131 return None
4131 4132
4132 4133 projectObjView = self.getSelectedProjectObj()
4133 4134
4134 4135 if not projectObjView:
4135 4136 self.console.append("Please select a project before update it")
4136 4137 return None
4137 4138
4138 4139 projectObjView.update(name=projectParms.name, description=projectParms.description)
4139 4140
4140 4141 return projectObjView
4141 4142
4142 4143 def createReadUnitView(self, projectObjView, idReadUnit=None):
4143 4144
4144 4145 projectParms = self.__getParmsFromProjectWindow()
4145 4146
4146 4147 if not projectParms.isValid():
4147 4148 return None
4148 4149
4149 4150 if projectParms.datatype in ("Voltage", "Spectra", "Fits"):
4150 4151 readUnitConfObj = projectObjView.addReadUnit(id=idReadUnit,
4151 4152 datatype=projectParms.datatype,
4152 4153 path=projectParms.dpath,
4153 4154 startDate=projectParms.startDate,
4154 4155 endDate=projectParms.endDate,
4155 4156 startTime=projectParms.startTime,
4156 4157 endTime=projectParms.endTime,
4157 4158 online=projectParms.online,
4158 4159 walk=projectParms.walk
4159 4160 )
4160 4161
4161 4162 if projectParms.set:
4162 4163 readUnitConfObj.addParameter(name="set", value=projectParms.set, format="int")
4163 4164
4164 4165 if projectParms.delay:
4165 4166 readUnitConfObj.addParameter(name="delay", value=projectParms.delay, format="int")
4166 4167
4167 4168 if projectParms.expLabel:
4168 4169 readUnitConfObj.addParameter(name="expLabel", value=projectParms.expLabel)
4169 4170
4170 4171 readUnitConfObj.addOperation(name="printInfo")
4171 4172
4172 4173 if projectParms.datatype == "USRP":
4173 4174 readUnitConfObj = projectObjView.addReadUnit(id=idReadUnit,
4174 4175 datatype=projectParms.datatype,
4175 4176 path=projectParms.dpath,
4176 4177 startDate=projectParms.startDate,
4177 4178 endDate=projectParms.endDate,
4178 4179 startTime=projectParms.startTime,
4179 4180 endTime=projectParms.endTime,
4180 4181 online=projectParms.online,
4181 4182 ippKm=projectParms.ippKm
4182 4183 )
4183 4184
4184 4185 if projectParms.delay:
4185 4186 readUnitConfObj.addParameter(name="delay", value=projectParms.delay, format="int")
4186 4187
4187 4188 return readUnitConfObj
4188 4189
4189 4190 def updateReadUnitView(self, projectObjView, idReadUnit):
4190 4191
4191 4192 projectObjView.removeProcUnit(idReadUnit)
4192 4193
4193 4194 readUnitConfObj = self.createReadUnitView(projectObjView, idReadUnit)
4194 4195
4195 4196 return readUnitConfObj
4196 4197
4197 4198 def createProcUnitView(self, projectObjView, datatype, inputId):
4198 4199
4199 4200 procUnitConfObj = projectObjView.addProcUnit(datatype=datatype, inputId=inputId)
4200 4201
4201 4202 self.__puObjDict[procUnitConfObj.getId()] = procUnitConfObj
4202 4203
4203 4204 return procUnitConfObj
4204 4205
4205 4206 def updateProcUnitView(self, id):
4206 4207
4207 4208 pass
4208 4209
4209 4210 def addPUWindow(self):
4210 4211
4211 4212 self.configUPWindowObj = UnitProcessWindow(self)
4212 4213 fatherObj = self.getSelectedItemObj()
4213 4214 try:
4214 4215 fatherObj.getElementName()
4215 4216 except:
4216 4217 self.console.append("First left click on Project or Processing Unit")
4217 4218 return 0
4218 4219
4219 4220 if fatherObj.getElementName() == 'Project':
4220 4221 readUnitConfObj = fatherObj.getReadUnitObj()
4221 4222 self.configUPWindowObj.dataTypeProject = str(readUnitConfObj.datatype)
4222 4223
4223 4224 self.configUPWindowObj.getfromWindowList.append(fatherObj)
4224 4225 self.configUPWindowObj.loadTotalList()
4225 4226 self.configUPWindowObj.show()
4226 4227 self.configUPWindowObj.closed.connect(self.createPUWindow)
4227 4228
4228 4229 def createPUWindow(self):
4229 4230
4230 4231 if not self.configUPWindowObj.create:
4231 4232 return
4232 4233
4233 4234 fatherObj = self.configUPWindowObj.getFromWindow
4234 4235 datatype = self.configUPWindowObj.typeofUP
4235 4236
4236 4237 if fatherObj.getElementName() == 'Project':
4237 4238 inputId = fatherObj.getReadUnitId()
4238 4239 projectObjView = fatherObj
4239 4240 else:
4240 4241 inputId = fatherObj.getId()
4241 4242 projectObjView = self.getSelectedProjectObj()
4242 4243
4243 4244 if not projectObjView:
4244 4245 return
4245 4246
4246 4247 puObj = self.createProcUnitView(projectObjView, datatype, inputId)
4247 4248
4248 4249 self.addPU2ProjectExplorer(puObj)
4249 4250
4250 4251 self.showtabPUCreated(datatype)
4251 4252
4252 4253 self.clearPUWindow(datatype)
4253 4254
4254 4255 self.showPUinitView()
4255 4256
4256 4257 def addFTPConf2Operation(self, puObj, opObj):
4257 4258
4258 4259 if not self.temporalFTP.create:
4259 4260 self.temporalFTP.setwithoutconfiguration()
4260 4261
4261 4262 # opObj.addParameter(name='server', value=self.temporalFTP.server, format='str')
4262 4263 # opObj.addParameter(name='remotefolder', value=self.temporalFTP.remotefolder, format='str')
4263 4264 # opObj.addParameter(name='username', value=self.temporalFTP.username, format='str')
4264 4265 # opObj.addParameter(name='password', value=self.temporalFTP.password, format='str')
4265 4266
4266 4267 if self.temporalFTP.ftp_wei:
4267 4268 opObj.addParameter(name='ftp_wei', value=int(self.temporalFTP.ftp_wei), format='int')
4268 4269 if self.temporalFTP.exp_code:
4269 4270 opObj.addParameter(name='exp_code', value=int(self.temporalFTP.exp_code), format='int')
4270 4271 if self.temporalFTP.sub_exp_code:
4271 4272 opObj.addParameter(name='sub_exp_code', value=int(self.temporalFTP.sub_exp_code), format='int')
4272 4273 if self.temporalFTP.plot_pos:
4273 4274 opObj.addParameter(name='plot_pos', value=int(self.temporalFTP.plot_pos), format='int')
4274 4275
4275 4276 # def __checkFTPProcUnit(self, projectObj, localfolder):
4276 4277 #
4277 4278 # puId = None
4278 4279 # puObj = None
4279 4280 #
4280 4281 # for thisPuId, thisPuObj in projectObj.procUnitItems():
4281 4282 #
4282 4283 # if not thisPuObj.name == "SendToServer":
4283 4284 # continue
4284 4285 #
4285 4286 # opObj = thisPuObj.getOperationObj(name='run')
4286 4287 #
4287 4288 # parmObj = opObj.getParameterObj('localfolder')
4288 4289 #
4289 4290 # #localfolder parameter should always be set, if it is not set then ProcUnit should be removed
4290 4291 # if not parmObj:
4291 4292 # projectObj.removeProcUnit(thisPuId)
4292 4293 # continue
4293 4294 #
4294 4295 # thisLocalfolder = parmObj.getValue()
4295 4296 #
4296 4297 # if localfolder != thisLocalfolder:
4297 4298 # continue
4298 4299 #
4299 4300 # puId = thisPuId
4300 4301 # puObj = thisPuObj
4301 4302 # break
4302 4303 #
4303 4304 # return puObj
4304 4305
4305 4306 def createFTPProcUnitView(self):
4306 4307
4307 4308 if not self.temporalFTP.create:
4308 4309 self.temporalFTP.setwithoutconfiguration()
4309 4310
4310 4311 projectObj = self.getSelectedProjectObj()
4311 4312
4312 4313 if not projectObj:
4313 4314 return
4314 4315
4315 4316 self.removeAllFTPProcUnitView(projectObj)
4316 4317
4317 4318 if not self.__puLocalFolder2FTP:
4318 4319 return
4319 4320
4320 4321 folderList = ",".join(self.__puLocalFolder2FTP.values())
4321 4322
4322 4323 procUnitConfObj = projectObj.addProcUnit(name="SendToServer")
4323 4324
4324 4325 procUnitConfObj.addParameter(name='server', value=self.temporalFTP.server, format='str')
4325 4326 procUnitConfObj.addParameter(name='username', value=self.temporalFTP.username, format='str')
4326 4327 procUnitConfObj.addParameter(name='password', value=self.temporalFTP.password, format='str')
4327 4328 procUnitConfObj.addParameter(name='localfolder', value=folderList, format='list')
4328 4329 procUnitConfObj.addParameter(name='remotefolder', value=self.temporalFTP.remotefolder, format='str')
4329 4330 procUnitConfObj.addParameter(name='ext', value=self.temporalFTP.extension, format='str')
4330 4331 procUnitConfObj.addParameter(name='period', value=self.temporalFTP.period, format='int')
4331 4332 procUnitConfObj.addParameter(name='protocol', value=self.temporalFTP.protocol, format='str')
4332 4333
4333 4334 procUnitConfObj.addParameter(name='ftp_wei', value=self.temporalFTP.ftp_wei, format='int')
4334 4335 procUnitConfObj.addParameter(name='exp_code', value=self.temporalFTP.exp_code, format='int')
4335 4336 procUnitConfObj.addParameter(name='sub_exp_code', value=self.temporalFTP.sub_exp_code, format='int')
4336 4337 procUnitConfObj.addParameter(name='plot_pos', value=self.temporalFTP.plot_pos, format='int')
4337 4338
4338 4339 self.__puObjDict[procUnitConfObj.getId()] = procUnitConfObj
4339 4340
4340 4341 def removeAllFTPProcUnitView(self, projectObj):
4341 4342
4342 4343 for thisPuId, thisPuObj in projectObj.procUnitItems():
4343 4344
4344 4345 if not thisPuObj.name == "SendToServer":
4345 4346 continue
4346 4347
4347 4348 projectObj.removeProcUnit(thisPuId)
4348 4349
4349 4350 if thisPuId not in self.__puObjDict.keys():
4350 4351 continue
4351 4352
4352 4353 self.__puObjDict.pop(thisPuId)
4353 4354
4354 4355 def showPUinitView(self):
4355 4356
4356 4357 self.propertiesModel = TreeModel()
4357 4358 self.propertiesModel.initPUVoltageView()
4358 4359 self.treeProjectProperties.setModel(self.propertiesModel)
4359 4360 self.treeProjectProperties.expandAll()
4360 4361 self.treeProjectProperties.allColumnsShowFocus()
4361 4362 self.treeProjectProperties.resizeColumnToContents(1)
4362 4363
4363 4364 def saveFTPFromOpObj(self, operationObj):
4364 4365
4365 4366 if operationObj.name != "SendByFTP":
4366 4367 return
4367 4368
4368 4369 server = operationObj.getParameterValue("server")
4369 4370 username = operationObj.getParameterValue("username")
4370 4371 password = operationObj.getParameterValue("password")
4371 4372 localfolder = operationObj.getParameterValue("localfolder")
4372 4373 remotefolder = operationObj.getParameterValue("remotefolder")
4373 4374 ext = operationObj.getParameterValue("ext")
4374 4375 period = operationObj.getParameterValue("period")
4375 4376
4376 4377 self.temporalFTP.save(server=server,
4377 4378 remotefolder=remotefolder,
4378 4379 username=username,
4379 4380 password=password,
4380 4381 localfolder=localfolder,
4381 4382 extension=ext)
4382 4383
4383 4384 return
4384 4385
4385 4386 def saveFTPFromProcUnitObj(self, puObj):
4386 4387
4387 4388 opObj = puObj.getOperationObj(name="run")
4388 4389
4389 4390 parmObj = opObj.getParameterObj(parameterName="server")
4390 4391 if parmObj == None:
4391 4392 server = 'jro-app.igp.gob.pe'
4392 4393 else:
4393 4394 server = parmObj.getValue()
4394 4395
4395 4396 parmObj = opObj.getParameterObj(parameterName="remotefolder")
4396 4397 if parmObj == None:
4397 4398 remotefolder = '/home/wmaster/graficos'
4398 4399 else:
4399 4400 remotefolder = parmObj.getValue()
4400 4401
4401 4402 parmObj = opObj.getParameterObj(parameterName="username")
4402 4403 if parmObj == None:
4403 4404 username = 'wmaster'
4404 4405 else:
4405 4406 username = parmObj.getValue()
4406 4407
4407 4408 parmObj = opObj.getParameterObj(parameterName="password")
4408 4409 if parmObj == None:
4409 4410 password = 'mst2010vhf'
4410 4411 else:
4411 4412 password = parmObj.getValue()
4412 4413
4413 4414 parmObj = opObj.getParameterObj(parameterName="ftp_wei")
4414 4415 if parmObj == None:
4415 4416 ftp_wei = 0
4416 4417 else:
4417 4418 ftp_wei = parmObj.getValue()
4418 4419
4419 4420 parmObj = opObj.getParameterObj(parameterName="exp_code")
4420 4421 if parmObj == None:
4421 4422 exp_code = 0
4422 4423 else:
4423 4424 exp_code = parmObj.getValue()
4424 4425
4425 4426 parmObj = opObj.getParameterObj(parameterName="sub_exp_code")
4426 4427 if parmObj == None:
4427 4428 sub_exp_code = 0
4428 4429 else:
4429 4430 sub_exp_code = parmObj.getValue()
4430 4431
4431 4432 parmObj = opObj.getParameterObj(parameterName="plot_pos")
4432 4433 if parmObj == None:
4433 4434 plot_pos = 0
4434 4435 else:
4435 4436 plot_pos = parmObj.getValue()
4436 4437
4437 4438 parmObj = opObj.getParameterObj(parameterName="localfolder")
4438 4439 if parmObj == None:
4439 4440 localfolder = None
4440 4441 else:
4441 4442 localfolder = parmObj.getValue()
4442 4443
4443 4444 parmObj = opObj.getParameterObj(parameterName="ext")
4444 4445 if parmObj == None:
4445 4446 extension = '.png'
4446 4447 else:
4447 4448 extension = parmObj.getValue()
4448 4449
4449 4450 self.temporalFTP.save(server=server,
4450 4451 remotefolder=remotefolder,
4451 4452 username=username,
4452 4453 password=password,
4453 4454 ftp_wei=ftp_wei,
4454 4455 exp_code=exp_code,
4455 4456 sub_exp_code=sub_exp_code,
4456 4457 plot_pos=plot_pos,
4457 4458 localfolder=localfolder,
4458 4459 extension=extension)
4459 4460
4460 4461 def addProject2ProjectExplorer(self, id, name):
4461 4462
4462 4463 itemTree = QtGui.QStandardItem(QtCore.QString(str(name)))
4463 4464
4464 4465 parentItem = self.projectExplorerModel.invisibleRootItem()
4465 4466 parentItem.appendRow(itemTree)
4466 4467
4467 4468 self.projectExplorerTree.setCurrentIndex(itemTree.index())
4468 4469
4469 4470 self.selectedItemTree = itemTree
4470 4471
4471 4472 self.__itemTreeDict[id] = itemTree
4472 4473
4473 4474 def addPU2ProjectExplorer(self, puObj):
4474 4475
4475 4476 id, name = puObj.id, puObj.datatype
4476 4477
4477 4478 itemTree = QtGui.QStandardItem(QtCore.QString(str(name)))
4478 4479
4479 4480 parentItem = self.selectedItemTree
4480 4481 parentItem.appendRow(itemTree)
4481 4482 self.projectExplorerTree.expandAll()
4482 4483
4483 4484 self.projectExplorerTree.setCurrentIndex(itemTree.index())
4484 4485
4485 4486 self.selectedItemTree = itemTree
4486 4487
4487 4488 self.__itemTreeDict[id] = itemTree
4488 4489
4489 4490 def addPU2PELoadXML(self, puObj):
4490 4491
4491 4492 id, name, inputId = puObj.id, puObj.datatype, puObj.inputId
4492 4493
4493 4494 itemTree = QtGui.QStandardItem(QtCore.QString(str(name)))
4494 4495
4495 4496 if self.__itemTreeDict.has_key(inputId):
4496 4497 parentItem = self.__itemTreeDict[inputId]
4497 4498 else:
4498 4499 #If parent is a Reader object
4499 4500 parentItem = self.__itemTreeDict[id[:-1]]
4500 4501
4501 4502 parentItem.appendRow(itemTree)
4502 4503 self.projectExplorerTree.expandAll()
4503 4504 parentItem = itemTree
4504 4505 self.projectExplorerTree.setCurrentIndex(parentItem.index())
4505 4506
4506 4507 self.__itemTreeDict[id] = itemTree
4507 4508 self.selectedItemTree = itemTree
4508 4509
4509 4510 def getSelectedProjectObj(self):
4510 4511 """
4511 4512 Return the current project object selected. If a processing unit is
4512 4513 actually selected this function returns associated project.
4513 4514
4514 4515 None if any project or processing unit is selected
4515 4516 """
4516 4517 for key in self.__itemTreeDict.keys():
4517 4518 if self.__itemTreeDict[key] != self.selectedItemTree:
4518 4519 continue
4519 4520
4520 4521 if self.__projectObjDict.has_key(key):
4521 4522 projectObj = self.__projectObjDict[key]
4522 4523 return projectObj
4523 4524
4524 4525 puObj = self.__puObjDict[key]
4525 4526
4526 4527 if puObj.parentId == None:
4527 4528 projectId = puObj.getId()[0]
4528 4529 else:
4529 4530 projectId = puObj.parentId
4530 4531
4531 4532 projectObj = self.__projectObjDict[projectId]
4532 4533 return projectObj
4533 4534
4534 4535 return None
4535 4536
4536 4537 def getSelectedItemObj(self):
4537 4538 """
4538 4539 Return the current project or processing unit object selected
4539 4540
4540 4541 None if any project or processing unit is selected
4541 4542 """
4542 4543 for key in self.__itemTreeDict.keys():
4543 4544 if self.__itemTreeDict[key] != self.selectedItemTree:
4544 4545 continue
4545 4546
4546 4547 if self.__projectObjDict.has_key(key) == True:
4547 4548 fatherObj = self.__projectObjDict[key]
4548 4549 else:
4549 4550 fatherObj = self.__puObjDict[key]
4550 4551
4551 4552 return fatherObj
4552 4553
4553 4554 return None
4554 4555
4555 4556 def _WarningWindow(self, text, information):
4556 4557
4557 4558 msgBox = QtGui.QMessageBox()
4558 4559 msgBox.setText(text)
4559 4560 msgBox.setInformativeText(information)
4560 4561 msgBox.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel)
4561 4562 msgBox.setDefaultButton(QtGui.QMessageBox.Ok)
4562 4563 ret = msgBox.exec_()
4563 4564
4564 4565 answer = False
4565 4566
4566 4567 if ret == QtGui.QMessageBox.Ok:
4567 4568 answer = True
4568 4569
4569 4570 return answer
4570 4571
4571 4572 def __getNewProjectId(self):
4572 4573
4573 4574 loadProject = False
4574 4575
4575 4576 for thisId in range(1,10):
4576 4577 newId = str(thisId)
4577 4578 if newId in self.__projectObjDict.keys():
4578 4579 continue
4579 4580
4580 4581 loadProject = True
4581 4582 projectId = newId
4582 4583 break
4583 4584
4584 4585 if not loadProject:
4585 4586 self.console.clear()
4586 4587 self.console.append("The maximum number of projects has been loaded, a new project can not be loaded")
4587 4588 return None
4588 4589
4589 4590 return projectId
4590 4591
4591 4592 def openProject(self):
4592 4593
4593 4594 self._disable_save_button()
4594 4595 self._disable_play_button()
4595 4596
4596 4597 self.frame_2.setEnabled(True)
4597 4598
4598 4599 # print self.dir
4599 4600 filename = str(QtGui.QFileDialog.getOpenFileName(self, "Open a project file", self.pathWorkSpace, self.tr("Html Files (*.xml)")))
4600 4601
4601 4602 projectObjLoad = Project()
4602 4603
4603 4604 try:
4604 4605 projectObjLoad.readXml(filename)
4605 4606 except:
4606 4607 self.console.clear()
4607 4608 self.console.append("The selected xml file could not be loaded ...")
4608 4609 return 0
4609 4610
4610 4611 self.create = False
4611 4612 self.refreshProjectWindow(projectObjLoad)
4612 4613 self.refreshProjectProperties(projectObjLoad)
4613 4614
4614 4615 projectId = projectObjLoad.id
4615 4616
4616 4617 if projectId in self.__projectObjDict.keys():
4617 4618
4618 4619 # answer = self._WarningWindow("You already have a project loaded with the same Id",
4619 4620 # "Do you want to load the file anyway?")
4620 4621 # if not answer:
4621 4622 # return
4622 4623
4623 4624 projectId = self.__getNewProjectId()
4624 4625
4625 4626 if not projectId:
4626 4627 return
4627 4628
4628 4629 projectObjLoad.updateId(projectId)
4629 4630
4630 4631 self.__projectObjDict[projectId] = projectObjLoad
4631 4632
4632 4633 self.addProject2ProjectExplorer(id=projectId, name=projectObjLoad.name)
4633 4634
4634 4635 self.tabWidgetProject.setEnabled(True)
4635 4636 self.tabWidgetProject.setCurrentWidget(self.tabProject)
4636 4637 # Disable tabProject after finish the creation
4637 4638 self.tabProject.setEnabled(True)
4638 4639 puObjorderList = OrderedDict(sorted(projectObjLoad.procUnitConfObjDict.items(), key=lambda x: x[0]))
4639 4640
4640 4641 for puId, puObj in puObjorderList.items():
4641 4642
4642 4643 self.__puObjDict[puId] = puObj
4643 4644
4644 4645 if puObj.name == "SendToServer":
4645 4646 self.saveFTPFromProcUnitObj(puObj)
4646 4647
4647 4648 ############## COMPATIBLE WITH OLD VERSIONS ################
4648 4649 operationObj = puObj.getOperationObj("SendByFTP")
4649 4650
4650 4651 if operationObj:
4651 4652 self.saveFTPFromOpObj(operationObj)
4652 4653 ############################################################
4653 4654
4654 4655 if puObj.inputId == '0':
4655 4656 continue
4656 4657
4657 4658 self.addPU2PELoadXML(puObj)
4658 4659
4659 4660 self.refreshPUWindow(puObj)
4660 4661 self.refreshPUProperties(puObj)
4661 4662 self.showtabPUCreated(datatype=puObj.datatype)
4662 4663
4663 4664 self.console.clear()
4664 4665 self.console.append("The selected xml file has been loaded successfully")
4665 4666
4666 4667 self._disable_save_button()
4667 4668 self._enable_play_button()
4668 4669
4669 4670 def create_updating_timer(self):
4671
4670 4672 self.comm_data_timer = QtCore.QTimer(self)
4671 4673 self.comm_data_timer.timeout.connect(self.on_comm_updating_timer)
4672 4674 self.comm_data_timer.start(1000)
4673 4675
4674 4676 def on_comm_updating_timer(self):
4675 4677 # Verifica si algun proceso ha sido inicializado y sigue ejecutandose
4676 4678 # Si el proceso se ha parado actualizar el GUI (stopProject)
4677 4679 if not self.threadStarted:
4678 4680 return
4679 4681
4680 4682 if self.controllerThread.isFinished():
4681 4683 self.stopProject()
4684 return
4685
4686 def use_plotmanager(self, controllerThread):
4687
4688 plotter_queue = Queue(10)
4689 controllerThread.setPlotterQueue(plotter_queue)
4690 controllerThread.useExternalPlotManager()
4691
4692 self.plotManager = PlotManager(plotter_queue)
4693
4694 self.plot_timer = QtCore.QTimer()
4695 self.plot_timer.timeout.connect(self.on_plotmanager_timer)
4696 self.plot_timer.start(10)
4682 4697
4698 def on_plotmanager_timer(self):
4699
4700 if not self.plotManager:
4701 return
4702
4703 self.plotManager.run()
4704
4683 4705 def playProject(self, ext=".xml", save=1):
4684 4706
4685 4707 self._disable_play_button()
4686 4708 self._disable_save_button()
4687 4709
4688 4710 if self.controllerThread:
4689 4711 if self.controllerThread.isRunning():
4690 4712 self.console.append("There is already another process running")
4691 4713 self._enable_stop_button()
4692 4714 return
4693 4715
4694 4716 projectObj = self.getSelectedProjectObj()
4695 4717
4696 4718 if not projectObj:
4697 4719 self.console.append("Please, select a project to start it")
4698 4720 return
4699 4721
4700 4722 if save:
4701 4723 filename = self.saveProject()
4702 4724 if filename == None:
4703 4725 self.console.append("Process not initialized.")
4704 4726 return
4705 4727 else:
4706 4728 filename = TEMPORAL_FILE
4707 4729 projectObj.writeXml( os.path.join(self.pathWorkSpace,filename) )
4708 4730
4709 4731 self.console.clear()
4710 4732 self.console.append("Please wait...")
4711 4733
4712 self.controllerThread = ControllerThread(filename)
4734 self.controllerThread = ControllerThread()
4713 4735 self.controllerThread.readXml(filename)
4736
4737 self.use_plotmanager(self.controllerThread)
4738
4714 4739 self.controllerThread.start()
4715 4740
4716 4741 sleep(0.5)
4717 4742
4718 4743 self.threadStarted = True
4719 4744
4720 4745 self._disable_play_button()
4721 4746 self._disable_save_button()
4722 4747 self._enable_stop_button()
4723 4748
4724 4749 def stopProject(self):
4725 4750
4726 # self.commCtrlPThread.cmd_q.put(ProcessCommand(ProcessCommand.STOP, True))
4727 self.controllerThread.stop()
4728 4751 self.threadStarted = False
4752 self.controllerThread.stop()
4729 4753
4730 4754 while self.controllerThread.isRunning():
4755 self.plotManager.run()
4731 4756 sleep(0.5)
4732 4757
4758 if self.plotManager is not None:
4759 self.plotManager.stop()
4760 self.plotManager.close()
4761 self.plotManager = None
4762
4733 4763 self._disable_stop_button()
4734 4764 self._enable_play_button()
4735 4765
4736 4766 def pauseProject(self):
4737 4767
4738 4768 # self.commCtrlPThread.cmd_q.put(ProcessCommand(ProcessCommand.PAUSE, data=True))
4739 4769 paused = self.controllerThread.pause()
4740 4770
4741 4771 self.changePauseIcon(paused)
4742 4772
4743 4773 def saveProject(self, filename=None):
4744 4774
4745 4775 self._disable_save_button()
4746 4776 self._disable_play_button()
4747 4777
4748 4778 projectObj = self.getSelectedProjectObj()
4749 4779
4750 4780 if not projectObj:
4751 4781
4752 4782 if self.create:
4753 4783 self.console.append("Please press Ok before save it")
4754 4784 else:
4755 4785 self.console.append("Please select a project before save it")
4756 4786 return
4757 4787
4758 4788 self.refreshGraphicsId()
4759 4789
4760 4790 sts = True
4761 4791 selectedItemObj = self.getSelectedItemObj()
4762 4792
4763 4793 #A Processing Unit has been selected
4764 4794 if projectObj == selectedItemObj:
4765 4795 if not self.on_proOk_clicked():
4766 4796 return None
4767 4797
4768 4798 #A Processing Unit has been selected
4769 4799 if projectObj != selectedItemObj:
4770 4800 puObj = selectedItemObj
4771 4801
4772 4802 if puObj.name == 'VoltageProc':
4773 4803 sts = self.on_volOpOk_clicked()
4774 4804 if puObj.name == 'SpectraProc':
4775 4805 sts = self.on_specOpOk_clicked()
4776 4806 if puObj.name == 'SpectraHeisProc':
4777 4807 sts = self.on_specHeisOpOk_clicked()
4778 4808
4779 4809 if not sts:
4780 4810 return None
4781 4811
4782 4812 self.createFTPProcUnitView()
4783 4813
4784 4814 if not filename:
4785 4815 filename = os.path.join( str(self.pathWorkSpace), "%s%s" %(str(projectObj.name), '.xml') )
4786 4816
4787 4817 projectObj.writeXml(filename)
4788 4818 self.console.clear()
4789 4819 self.console.append("Project saved")
4790 4820 self.console.append("Press Play button to start data processing ...")
4791 4821
4792 4822 self._disable_save_button()
4793 4823 self._enable_play_button()
4794 4824
4795 4825 return filename
4796 4826
4797 4827 def removeItemTreeFromProject(self):
4798 4828 """
4799 4829 Metodo para eliminar el proyecto en el dictionario de proyectos y en el dictionario de vista de arbol
4800 4830 """
4801 4831 for key in self.__itemTreeDict.keys():
4802 4832
4803 4833 #Check again because an item can delete multiple items (childs)
4804 4834 if key not in self.__itemTreeDict.keys():
4805 4835 continue
4806 4836
4807 4837 if self.__itemTreeDict[key] != self.selectedItemTree:
4808 4838 continue
4809 4839
4810 4840 if self.__projectObjDict.has_key(key) == True:
4811 4841
4812 4842 del self.__projectObjDict[key]
4813 4843 del self.__itemTreeDict[key]
4814 4844
4815 4845 else:
4816 4846 puObj = self.__puObjDict[key]
4817 4847 idProjectParent = puObj.parentId
4818 4848 projectObj = self.__projectObjDict[idProjectParent]
4819 4849
4820 4850 del self.__puObjDict[key]
4821 4851 del self.__itemTreeDict[key]
4822 4852 del projectObj.procUnitConfObjDict[key]
4823 4853
4824 4854 for key in projectObj.procUnitConfObjDict.keys():
4825 4855 if projectObj.procUnitConfObjDict[key].inputId != puObj.getId():
4826 4856 continue
4827 4857 del self.__puObjDict[projectObj.procUnitConfObjDict[key].getId()]
4828 4858 del self.__itemTreeDict[projectObj.procUnitConfObjDict[key].getId()]
4829 4859 del projectObj.procUnitConfObjDict[key]
4830 4860 # print projectObj.procUnitConfObjDict
4831 4861 # print self.__itemTreeDict,self.__projectObjDict,self.__puObjDict
4832 4862
4833 4863 def setInputsProject_View(self):
4834 4864
4835 4865 self.tabWidgetProject.setEnabled(True)
4836 4866 self.tabWidgetProject.setCurrentWidget(self.tabProject)
4837 4867 self.tabProject.setEnabled(True)
4838 4868 self.frame_2.setEnabled(False)
4839 4869 self.proName.clear()
4840 4870 self.proName.setFocus()
4841 4871 self.proName.setSelection(0, 0)
4842 4872 self.proName.setCursorPosition(0)
4843 4873 self.proDataType.setText('.r')
4844 4874 self.proDataPath.clear()
4845 4875 self.proComDataType.clear()
4846 4876 self.proComDataType.addItem("Voltage")
4847 4877 self.proComDataType.addItem("Spectra")
4848 4878 self.proComDataType.addItem("Fits")
4849 4879 self.proComDataType.addItem("USRP")
4850 4880
4851 4881 self.proComStartDate.clear()
4852 4882 self.proComEndDate.clear()
4853 4883
4854 4884 startTime = "00:00:00"
4855 4885 endTime = "23:59:59"
4856 4886 starlist = startTime.split(":")
4857 4887 endlist = endTime.split(":")
4858 4888 self.proDelay.setText("60")
4859 4889 self.proSet.setText("")
4860 4890
4861 4891 self.labelSet.show()
4862 4892 self.proSet.show()
4863 4893
4864 4894 self.labelIPPKm.hide()
4865 4895 self.proIPPKm.hide()
4866 4896
4867 4897 self.time.setHMS(int(starlist[0]), int(starlist[1]), int(starlist[2]))
4868 4898 self.proStartTime.setTime(self.time)
4869 4899 self.time.setHMS(int(endlist[0]), int(endlist[1]), int(endlist[2]))
4870 4900 self.proEndTime.setTime(self.time)
4871 4901 self.proDescription.clear()
4872 4902 self.proOk.setEnabled(False)
4873 4903 # self.console.append("Please, Write a name Project")
4874 4904 # self.console.append("Introduce Project Parameters")DC
4875 4905 # self.console.append("Select data type Voltage( .rawdata) or Spectra(.pdata)")
4876 4906
4877 4907 def clearPUWindow(self, datatype):
4878 4908
4879 4909 projectObjView = self.getSelectedProjectObj()
4880 4910
4881 4911 if not projectObjView:
4882 4912 return
4883 4913
4884 4914 puObj = self.getSelectedItemObj()
4885 4915 inputId = puObj.getInputId()
4886 4916 inputPUObj = projectObjView.getProcUnitObj(inputId)
4887 4917
4888 4918 if datatype == 'Voltage':
4889 4919 self.volOpComChannels.setEnabled(False)
4890 4920 self.volOpComHeights.setEnabled(False)
4891 4921 self.volOpFilter.setEnabled(False)
4892 4922 self.volOpComProfile.setEnabled(False)
4893 4923 self.volOpComCode.setEnabled(False)
4894 4924 self.volOpCohInt.setEnabled(False)
4895 4925 self.volOpChannel.setEnabled(False)
4896 4926 self.volOpHeights.setEnabled(False)
4897 4927 self.volOpProfile.setEnabled(False)
4898 4928 self.volOpRadarfrequency.setEnabled(False)
4899 4929 self.volOpCebChannels.setCheckState(0)
4900 4930 self.volOpCebRadarfrequency.setCheckState(0)
4901 4931 self.volOpCebHeights.setCheckState(0)
4902 4932 self.volOpCebFilter.setCheckState(0)
4903 4933 self.volOpCebProfile.setCheckState(0)
4904 4934 self.volOpCebDecodification.setCheckState(0)
4905 4935 self.volOpCebCohInt.setCheckState(0)
4906 4936
4907 4937 self.volOpChannel.clear()
4908 4938 self.volOpHeights.clear()
4909 4939 self.volOpProfile.clear()
4910 4940 self.volOpFilter.clear()
4911 4941 self.volOpCohInt.clear()
4912 4942 self.volOpRadarfrequency.clear()
4913 4943
4914 4944 if datatype == 'Spectra':
4915 4945
4916 4946 if inputPUObj.datatype == 'Spectra':
4917 4947 self.specOpnFFTpoints.setEnabled(False)
4918 4948 self.specOpProfiles.setEnabled(False)
4919 4949 self.specOpippFactor.setEnabled(False)
4920 4950 else:
4921 4951 self.specOpnFFTpoints.setEnabled(True)
4922 4952 self.specOpProfiles.setEnabled(True)
4923 4953 self.specOpippFactor.setEnabled(True)
4924 4954
4925 4955 self.specOpCebCrossSpectra.setCheckState(0)
4926 4956 self.specOpCebChannel.setCheckState(0)
4927 4957 self.specOpCebHeights.setCheckState(0)
4928 4958 self.specOpCebIncoherent.setCheckState(0)
4929 4959 self.specOpCebRemoveDC.setCheckState(0)
4930 4960 self.specOpCebRemoveInt.setCheckState(0)
4931 4961 self.specOpCebgetNoise.setCheckState(0)
4932 4962 self.specOpCebRadarfrequency.setCheckState(0)
4933 4963
4934 4964 self.specOpRadarfrequency.setEnabled(False)
4935 4965 self.specOppairsList.setEnabled(False)
4936 4966 self.specOpChannel.setEnabled(False)
4937 4967 self.specOpHeights.setEnabled(False)
4938 4968 self.specOpIncoherent.setEnabled(False)
4939 4969 self.specOpgetNoise.setEnabled(False)
4940 4970
4941 4971 self.specOpRadarfrequency.clear()
4942 4972 self.specOpnFFTpoints.clear()
4943 4973 self.specOpProfiles.clear()
4944 4974 self.specOpippFactor.clear
4945 4975 self.specOppairsList.clear()
4946 4976 self.specOpChannel.clear()
4947 4977 self.specOpHeights.clear()
4948 4978 self.specOpIncoherent.clear()
4949 4979 self.specOpgetNoise.clear()
4950 4980
4951 4981 self.specGraphCebSpectraplot.setCheckState(0)
4952 4982 self.specGraphCebCrossSpectraplot.setCheckState(0)
4953 4983 self.specGraphCebRTIplot.setCheckState(0)
4954 4984 self.specGraphCebRTInoise.setCheckState(0)
4955 4985 self.specGraphCebCoherencmap.setCheckState(0)
4956 4986 self.specGraphPowerprofile.setCheckState(0)
4957 4987
4958 4988 self.specGraphSaveSpectra.setCheckState(0)
4959 4989 self.specGraphSaveCross.setCheckState(0)
4960 4990 self.specGraphSaveRTIplot.setCheckState(0)
4961 4991 self.specGraphSaveRTInoise.setCheckState(0)
4962 4992 self.specGraphSaveCoherencemap.setCheckState(0)
4963 4993 self.specGraphSavePowerprofile.setCheckState(0)
4964 4994
4965 4995 self.specGraphftpRTIplot.setCheckState(0)
4966 4996 self.specGraphftpRTInoise.setCheckState(0)
4967 4997 self.specGraphftpCoherencemap.setCheckState(0)
4968 4998
4969 4999 self.specGraphPath.clear()
4970 5000 self.specGraphPrefix.clear()
4971 5001
4972 5002 self.specGgraphftpratio.clear()
4973 5003
4974 5004 self.specGgraphChannelList.clear()
4975 5005 self.specGgraphFreq.clear()
4976 5006 self.specGgraphHeight.clear()
4977 5007 self.specGgraphDbsrange.clear()
4978 5008 self.specGgraphmagnitud.clear()
4979 5009 self.specGgraphTminTmax.clear()
4980 5010 self.specGgraphTimeRange.clear()
4981 5011
4982 5012 if datatype == 'SpectraHeis':
4983 5013 self.specHeisOpCebIncoherent.setCheckState(0)
4984 5014 self.specHeisOpIncoherent.setEnabled(False)
4985 5015 self.specHeisOpIncoherent.clear()
4986 5016
4987 5017 self.specHeisGraphCebSpectraplot.setCheckState(0)
4988 5018 self.specHeisGraphCebRTIplot.setCheckState(0)
4989 5019
4990 5020 self.specHeisGraphSaveSpectra.setCheckState(0)
4991 5021 self.specHeisGraphSaveRTIplot.setCheckState(0)
4992 5022
4993 5023 self.specHeisGraphftpSpectra.setCheckState(0)
4994 5024 self.specHeisGraphftpRTIplot.setCheckState(0)
4995 5025
4996 5026 self.specHeisGraphPath.clear()
4997 5027 self.specHeisGraphPrefix.clear()
4998 5028 self.specHeisGgraphChannelList.clear()
4999 5029 self.specHeisGgraphXminXmax.clear()
5000 5030 self.specHeisGgraphYminYmax.clear()
5001 5031 self.specHeisGgraphTminTmax.clear()
5002 5032 self.specHeisGgraphTimeRange.clear()
5003 5033 self.specHeisGgraphftpratio.clear()
5004 5034
5005 5035 def showtabPUCreated(self, datatype):
5006 5036
5007 5037 if datatype == "Voltage":
5008 5038 self.tabVoltage.setEnabled(True)
5009 5039 self.tabProject.setEnabled(False)
5010 5040 self.tabSpectra.setEnabled(False)
5011 5041 self.tabCorrelation.setEnabled(False)
5012 5042 self.tabSpectraHeis.setEnabled(False)
5013 5043 self.tabWidgetProject.setCurrentWidget(self.tabVoltage)
5014 5044
5015 5045 if datatype == "Spectra":
5016 5046 self.tabVoltage.setEnabled(False)
5017 5047 self.tabProject.setEnabled(False)
5018 5048 self.tabSpectra.setEnabled(True)
5019 5049 self.tabCorrelation.setEnabled(False)
5020 5050 self.tabSpectraHeis.setEnabled(False)
5021 5051 self.tabWidgetProject.setCurrentWidget(self.tabSpectra)
5022 5052
5023 5053 if datatype == "SpectraHeis":
5024 5054 self.tabVoltage.setEnabled(False)
5025 5055 self.tabProject.setEnabled(False)
5026 5056 self.tabSpectra.setEnabled(False)
5027 5057 self.tabCorrelation.setEnabled(False)
5028 5058 self.tabSpectraHeis.setEnabled(True)
5029 5059 self.tabWidgetProject.setCurrentWidget(self.tabSpectraHeis)
5030 5060
5031 5061 def checkInputsProject(self):
5032 5062 """
5033 5063 Check Inputs Project:
5034 5064 - project_name
5035 5065 - datatype
5036 5066 - ext
5037 5067 - data_path
5038 5068 - readmode
5039 5069 - delay
5040 5070 - set
5041 5071 - walk
5042 5072 """
5043 5073 parms_ok = True
5044 5074 project_name = str(self.proName.text())
5045 5075 if project_name == '' or project_name == None:
5046 5076 outputstr = "Enter the Project Name"
5047 5077 self.console.append(outputstr)
5048 5078 parms_ok = False
5049 5079 project_name = None
5050 5080
5051 5081 datatype = str(self.proComDataType.currentText())
5052 5082 if not(datatype in ['Voltage', 'Spectra', 'Fits', 'USRP']):
5053 5083 outputstr = 'datatype = %s, this must be either Voltage, Spectra, SpectraHeis or USRP' % datatype
5054 5084 self.console.append(outputstr)
5055 5085 parms_ok = False
5056 5086 datatype = None
5057 5087
5058 5088 ext = str(self.proDataType.text())
5059 5089 if not(ext in ['.r', '.pdata', '.fits', '.hdf5']):
5060 5090 outputstr = "extension files must be .r , .pdata, .fits or .hdf5"
5061 5091 self.console.append(outputstr)
5062 5092 parms_ok = False
5063 5093 ext = None
5064 5094
5065 5095 data_path = str(self.proDataPath.text())
5066 5096
5067 5097 if data_path == '':
5068 5098 outputstr = 'Datapath is empty'
5069 5099 self.console.append(outputstr)
5070 5100 parms_ok = False
5071 5101 data_path = None
5072 5102
5073 5103 if data_path != None:
5074 5104 if not os.path.isdir(data_path):
5075 5105 outputstr = 'Datapath:%s does not exists' % data_path
5076 5106 self.console.append(outputstr)
5077 5107 parms_ok = False
5078 5108 data_path = None
5079 5109
5080 5110 read_mode = str(self.proComReadMode.currentText())
5081 5111 if not(read_mode in ['Online', 'Offline']):
5082 5112 outputstr = 'Read Mode: %s, this must be either Online or Offline' % read_mode
5083 5113 self.console.append(outputstr)
5084 5114 parms_ok = False
5085 5115 read_mode = None
5086 5116
5087 5117 delay = None
5088 5118 if read_mode == "Online":
5089 5119 parms_ok = False
5090 5120 try:
5091 5121 delay = int(str(self.proDelay.text()))
5092 5122 parms_ok = True
5093 5123 except:
5094 5124 outputstr = 'Delay: %s, this must be a integer number' % str(self.proDelay.text())
5095 5125 self.console.append(outputstr)
5096 5126
5097 5127 try:
5098 5128 set = int(str(self.proSet.text()))
5099 5129 except:
5100 5130 # outputstr = 'Set: %s, this must be a integer number' % str(self.proName.text())
5101 5131 # self.console.append(outputstr)
5102 5132 # parms_ok = False
5103 5133 set = None
5104 5134
5105 5135 walk = int(self.proComWalk.currentIndex())
5106 5136 expLabel = str(self.proExpLabel.text())
5107 5137
5108 5138 return parms_ok, project_name, datatype, ext, data_path, read_mode, delay, walk, set, expLabel
5109 5139
5110 5140 def checkInputsPUSave(self, datatype):
5111 5141 """
5112 5142 Check Inputs Spectra Save:
5113 5143 - path
5114 5144 - blocks Per File
5115 5145 - sufix
5116 5146 - dataformat
5117 5147 """
5118 5148 parms_ok = True
5119 5149
5120 5150 if datatype == "Voltage":
5121 5151 output_path = str(self.volOutputPath.text())
5122 5152 blocksperfile = str(self.volOutputblocksperfile.text())
5123 5153 profilesperblock = str(self.volOutputprofilesperblock.text())
5124 5154
5125 5155 if datatype == "Spectra":
5126 5156 output_path = str(self.specOutputPath.text())
5127 5157 blocksperfile = str(self.specOutputblocksperfile.text())
5128 5158 profilesperblock = 0
5129 5159
5130 5160 if datatype == "SpectraHeis":
5131 5161 output_path = str(self.specHeisOutputPath.text())
5132 5162 blocksperfile = str(self.specHeisOutputblocksperfile.text())
5133 5163 metadata_file = str(self.specHeisOutputMetada.text())
5134 5164
5135 5165 if output_path == '':
5136 5166 outputstr = 'Outputpath is empty'
5137 5167 self.console.append(outputstr)
5138 5168 parms_ok = False
5139 5169
5140 5170 if not os.path.isdir(output_path):
5141 5171 outputstr = 'OutputPath:%s does not exists' % output_path
5142 5172 self.console.append(outputstr)
5143 5173 parms_ok = False
5144 5174
5145 5175 try:
5146 5176 profilesperblock = int(profilesperblock)
5147 5177 except:
5148 5178 if datatype == "Voltage":
5149 5179 outputstr = 'Profilesperblock: %s, this must be a integer number' % str(self.volOutputprofilesperblock.text())
5150 5180 self.console.append(outputstr)
5151 5181 parms_ok = False
5152 5182 profilesperblock = None
5153 5183
5154 5184 try:
5155 5185 blocksperfile = int(blocksperfile)
5156 5186 except:
5157 5187 if datatype == "Voltage":
5158 5188 outputstr = 'Blocksperfile: %s, this must be a integer number' % str(self.volOutputblocksperfile.text())
5159 5189 elif datatype == "Spectra":
5160 5190 outputstr = 'Blocksperfile: %s, this must be a integer number' % str(self.specOutputblocksperfile.text())
5161 5191 elif datatype == "SpectraHeis":
5162 5192 outputstr = 'Blocksperfile: %s, this must be a integer number' % str(self.specHeisOutputblocksperfile.text())
5163 5193
5164 5194 self.console.append(outputstr)
5165 5195 parms_ok = False
5166 5196 blocksperfile = None
5167 5197
5168 5198 if datatype == "SpectraHeis":
5169 5199 if metadata_file != '':
5170 5200 if not os.path.isfile(metadata_file):
5171 5201 outputstr = 'Metadata file %s does not exist' % metadata_file
5172 5202 self.console.append(outputstr)
5173 5203 parms_ok = False
5174 5204
5175 5205 if datatype == "Voltage":
5176 5206 return parms_ok, output_path, blocksperfile, profilesperblock
5177 5207
5178 5208
5179 5209 if datatype == "Spectra":
5180 5210 return parms_ok, output_path, blocksperfile, profilesperblock
5181 5211
5182 5212
5183 5213 if datatype == "SpectraHeis":
5184 5214 return parms_ok, output_path, blocksperfile, metadata_file
5185 5215
5186 5216 def findDatafiles(self, data_path, ext, walk, expLabel=''):
5187 5217
5188 5218 dateList = []
5189 5219 fileList = []
5190 5220
5191 5221 if ext == ".r":
5192 5222 from schainpy.model.io.jroIO_base import JRODataReader
5193 5223
5194 5224 readerObj = JRODataReader()
5195 5225 dateList = readerObj.findDatafiles(path=data_path,
5196 5226 expLabel=expLabel,
5197 5227 ext=ext,
5198 5228 walk=walk)
5199 5229
5200 5230 if ext == ".pdata":
5201 5231 from schainpy.model.io.jroIO_base import JRODataReader
5202 5232
5203 5233 readerObj = JRODataReader()
5204 5234 dateList = readerObj.findDatafiles(path=data_path,
5205 5235 expLabel=expLabel,
5206 5236 ext=ext,
5207 5237 walk=walk)
5208 5238
5209 5239 if ext == ".fits":
5210 5240 from schainpy.model.io.jroIO_base import JRODataReader
5211 5241
5212 5242 readerObj = JRODataReader()
5213 5243 dateList = readerObj.findDatafiles(path=data_path,
5214 5244 expLabel=expLabel,
5215 5245 ext=ext,
5216 5246 walk=walk)
5217 5247
5218 5248 if ext == ".hdf5":
5219 5249 from schainpy.model.io.jroIO_usrp import USRPReader
5220 5250
5221 5251 readerObj = USRPReader()
5222 5252 dateList = readerObj.findDatafiles(path=data_path)
5223 5253
5224 5254 return dateList
5225 5255
5226 5256 def loadDays(self, data_path, ext, walk, expLabel=''):
5227 5257 """
5228 5258 Method to loads day
5229 5259 """
5230 5260 # self._disable_save_button()
5231 5261 # self._disable_play_button()
5232 5262 # self.proOk.setEnabled(False)
5233 5263
5234 5264 self.proComStartDate.clear()
5235 5265 self.proComEndDate.clear()
5236 5266
5237 5267 self.dateList = []
5238 5268
5239 5269 if not data_path:
5240 5270 return []
5241 5271
5242 5272 if not os.path.isdir(data_path):
5243 5273 return []
5244 5274
5245 5275 self.dataPath = data_path
5246 5276
5247 5277 dateList = self.findDatafiles(data_path, ext=ext, walk=walk, expLabel=expLabel)
5248 5278
5249 5279 if not dateList:
5250 5280 # self.console.clear()
5251 5281 if walk:
5252 5282 if expLabel:
5253 5283 outputstr = "No files (*%s) were found on %s/DOYPATH/%s" % (ext, data_path, expLabel)
5254 5284 else:
5255 5285 outputstr = "No files (*%s) were found on %s" % (ext, data_path)
5256 5286 else:
5257 5287 outputstr = "No files (*%s) were found on %s" % (ext, data_path)
5258 5288
5259 5289 self.console.append(outputstr)
5260 5290 return []
5261 5291
5262 5292 dateStrList = []
5263 5293 for thisDate in dateList:
5264 5294 dateStr = thisDate.strftime("%Y/%m/%d")
5265 5295
5266 5296 self.proComStartDate.addItem(dateStr)
5267 5297 self.proComEndDate.addItem(dateStr)
5268 5298 dateStrList.append(dateStr)
5269 5299
5270 5300 self.proComStartDate.setCurrentIndex(0)
5271 5301 self.proComEndDate.setCurrentIndex(self.proComEndDate.count() - 1)
5272 5302
5273 5303 self.dateList = dateStrList
5274 5304
5275 5305 self.console.clear()
5276 5306 self.console.append("Successful load")
5277 5307
5278 5308 # self.proOk.setEnabled(True)
5279 5309 # self._enable_play_button()
5280 5310 # self._enable_save_button()
5281 5311
5282 5312 return self.dateList
5283 5313
5284 5314 def setWorkSpaceGUI(self, pathWorkSpace=None):
5285 5315
5286 5316 if pathWorkSpace == None:
5287 5317 home = os.path.expanduser("~")
5288 5318 pathWorkSpace = os.path.join(home,'schain_workspace')
5289 5319
5290 5320 self.pathWorkSpace = pathWorkSpace
5291 5321
5292 5322 """
5293 5323 Comandos Usados en Console
5294 5324 """
5295 5325 def __del__(self):
5296 5326 sys.stdout = sys.__stdout__
5297 5327 sys.stderr = sys.__stderr__
5298 5328
5299 5329 def normalOutputWritten(self, text):
5300 5330 color_black = QtGui.QColor(0,0,0)
5301 5331 self.console.setTextColor(color_black)
5302 5332 self.console.append(text)
5303 5333
5304 5334 def errorOutputWritten(self, text):
5305 5335 color_red = QtGui.QColor(255,0,0)
5306 5336 color_black = QtGui.QColor(0,0,0)
5307 5337
5308 5338 self.console.setTextColor(color_red)
5309 5339 self.console.append(text)
5310 5340 self.console.setTextColor(color_black)
5311 5341
5312 5342 def _enable_save_button(self):
5313 5343
5314 5344 self.actionSaveToolbar.setEnabled(True)
5315 5345 self.actionSave.setEnabled(True)
5316 5346
5317 5347 def _disable_save_button(self):
5318 5348
5319 5349 self.actionSaveToolbar.setEnabled(False)
5320 5350 self.actionSave.setEnabled(False)
5321 5351
5322 5352 def _enable_play_button(self):
5323 5353
5324 5354 self.actionStart.setEnabled(True)
5325 5355 self.actionStarToolbar.setEnabled(True)
5326 5356
5327 5357 self.changeStartIcon(started=False)
5328 5358
5329 5359 def _disable_play_button(self):
5330 5360
5331 5361 self.actionStart.setEnabled(False)
5332 5362 self.actionStarToolbar.setEnabled(False)
5333 5363
5334 5364 self.changeStartIcon(started=True)
5335 5365
5336 5366 def _enable_stop_button(self):
5337 5367
5338 5368 self.actionPause.setEnabled(True)
5339 5369 self.actionStop.setEnabled(True)
5340 5370
5341 5371 self.actionPauseToolbar.setEnabled(True)
5342 5372 self.actionStopToolbar.setEnabled(True)
5343 5373
5344 5374 self.changePauseIcon(paused=False)
5345 5375 self.changeStopIcon(started=True)
5346 5376
5347 5377 def _disable_stop_button(self):
5348 5378
5349 5379 self.actionPause.setEnabled(False)
5350 5380 self.actionStop.setEnabled(False)
5351 5381
5352 5382 self.actionPauseToolbar.setEnabled(False)
5353 5383 self.actionStopToolbar.setEnabled(False)
5354 5384
5355 5385 self.changePauseIcon(paused=False)
5356 5386 self.changeStopIcon(started=False)
5357 5387
5358 5388 def setGUIStatus(self):
5359 5389
5360 5390 self.setWindowTitle("ROJ-Signal Chain")
5361 5391 self.setWindowIcon(QtGui.QIcon( os.path.join(FIGURES_PATH,"logo.png") ))
5362 5392
5363 5393 self.tabWidgetProject.setEnabled(False)
5364 5394 self.tabVoltage.setEnabled(False)
5365 5395 self.tabSpectra.setEnabled(False)
5366 5396 self.tabCorrelation.setEnabled(False)
5367 5397 self.frame_2.setEnabled(False)
5368 5398
5369 5399 self.actionCreate.setShortcut('Ctrl+N')
5370 5400 self.actionOpen.setShortcut('Ctrl+O')
5371 5401 self.actionSave.setShortcut('Ctrl+S')
5372 5402 self.actionClose.setShortcut('Ctrl+X')
5373 5403
5374 5404 self.actionStart.setShortcut('Ctrl+1')
5375 5405 self.actionPause.setShortcut('Ctrl+2')
5376 5406 self.actionStop.setShortcut('Ctrl+3')
5377 5407
5378 5408 self.actionFTP.setShortcut('Ctrl+F')
5379 5409
5380 5410 self.actionStart.setEnabled(False)
5381 5411 self.actionPause.setEnabled(False)
5382 5412 self.actionStop.setEnabled(False)
5383 5413
5384 5414 self.actionStarToolbar.setEnabled(False)
5385 5415 self.actionPauseToolbar.setEnabled(False)
5386 5416 self.actionStopToolbar.setEnabled(False)
5387 5417
5388 5418 self.proName.clear()
5389 5419 self.proDataPath.setText('')
5390 5420 self.console.setReadOnly(True)
5391 5421 self.console.append("Welcome to Signal Chain\nOpen a project or Create a new one")
5392 5422 self.proStartTime.setDisplayFormat("hh:mm:ss")
5393 5423 self.proDataType.setEnabled(False)
5394 5424 self.time = QtCore.QTime()
5395 5425 self.hour = 0
5396 5426 self.min = 0
5397 5427 self.sec = 0
5398 5428 self.proEndTime.setDisplayFormat("hh:mm:ss")
5399 5429 startTime = "00:00:00"
5400 5430 endTime = "23:59:59"
5401 5431 starlist = startTime.split(":")
5402 5432 endlist = endTime.split(":")
5403 5433 self.time.setHMS(int(starlist[0]), int(starlist[1]), int(starlist[2]))
5404 5434 self.proStartTime.setTime(self.time)
5405 5435 self.time.setHMS(int(endlist[0]), int(endlist[1]), int(endlist[2]))
5406 5436 self.proEndTime.setTime(self.time)
5407 5437 self.proOk.setEnabled(False)
5408 5438 # set model Project Explorer
5409 5439 self.projectExplorerModel = QtGui.QStandardItemModel()
5410 5440 self.projectExplorerModel.setHorizontalHeaderLabels(("Project Explorer",))
5411 5441 layout = QtGui.QVBoxLayout()
5412 5442 layout.addWidget(self.projectExplorerTree)
5413 5443 self.projectExplorerTree.setModel(self.projectExplorerModel)
5414 5444 self.projectExplorerTree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
5415 5445 self.projectExplorerTree.customContextMenuRequested.connect(self.on_right_click)
5416 5446 self.projectExplorerTree.clicked.connect(self.on_click)
5417 5447 self.projectExplorerTree.expandAll()
5418 5448 # set model Project Properties
5419 5449
5420 5450 self.propertiesModel = TreeModel()
5421 5451 self.propertiesModel.initProjectView()
5422 5452 self.treeProjectProperties.setModel(self.propertiesModel)
5423 5453 self.treeProjectProperties.expandAll()
5424 5454 self.treeProjectProperties.allColumnsShowFocus()
5425 5455 self.treeProjectProperties.resizeColumnToContents(1)
5426 5456
5427 5457 # set Project
5428 5458 self.proExpLabel.setEnabled(True)
5429 5459 self.proDelay.setEnabled(False)
5430 5460 self.proSet.setEnabled(True)
5431 5461 self.proDataType.setReadOnly(True)
5432 5462
5433 5463 # set Operation Voltage
5434 5464 self.volOpComChannels.setEnabled(False)
5435 5465 self.volOpComHeights.setEnabled(False)
5436 5466 self.volOpFilter.setEnabled(False)
5437 5467 self.volOpComProfile.setEnabled(False)
5438 5468 self.volOpComCode.setEnabled(False)
5439 5469 self.volOpFlip.setEnabled(False)
5440 5470 self.volOpCohInt.setEnabled(False)
5441 5471 self.volOpRadarfrequency.setEnabled(False)
5442 5472
5443 5473 self.volOpChannel.setEnabled(False)
5444 5474 self.volOpHeights.setEnabled(False)
5445 5475 self.volOpProfile.setEnabled(False)
5446 5476 self.volOpComMode.setEnabled(False)
5447 5477
5448 5478 self.volGraphPath.setEnabled(False)
5449 5479 self.volGraphPrefix.setEnabled(False)
5450 5480 self.volGraphToolPath.setEnabled(False)
5451 5481
5452 5482 # set Graph Voltage
5453 5483 self.volGraphChannelList.setEnabled(False)
5454 5484 self.volGraphfreqrange.setEnabled(False)
5455 5485 self.volGraphHeightrange.setEnabled(False)
5456 5486
5457 5487 # set Operation Spectra
5458 5488 self.specOpnFFTpoints.setEnabled(False)
5459 5489 self.specOpProfiles.setEnabled(False)
5460 5490 self.specOpippFactor.setEnabled(False)
5461 5491 self.specOppairsList.setEnabled(False)
5462 5492 self.specOpComChannel.setEnabled(False)
5463 5493 self.specOpComHeights.setEnabled(False)
5464 5494 self.specOpIncoherent.setEnabled(False)
5465 5495 self.specOpgetNoise.setEnabled(False)
5466 5496 self.specOpRadarfrequency.setEnabled(False)
5467 5497
5468 5498
5469 5499 self.specOpChannel.setEnabled(False)
5470 5500 self.specOpHeights.setEnabled(False)
5471 5501 # set Graph Spectra
5472 5502 self.specGgraphChannelList.setEnabled(False)
5473 5503 self.specGgraphFreq.setEnabled(False)
5474 5504 self.specGgraphHeight.setEnabled(False)
5475 5505 self.specGgraphDbsrange.setEnabled(False)
5476 5506 self.specGgraphmagnitud.setEnabled(False)
5477 5507 self.specGgraphTminTmax.setEnabled(False)
5478 5508 self.specGgraphTimeRange.setEnabled(False)
5479 5509 self.specGraphPath.setEnabled(False)
5480 5510 self.specGraphToolPath.setEnabled(False)
5481 5511 self.specGraphPrefix.setEnabled(False)
5482 5512
5483 5513 self.specGgraphftpratio.setEnabled(False)
5484 5514 # set Operation SpectraHeis
5485 5515 self.specHeisOpIncoherent.setEnabled(False)
5486 5516 self.specHeisOpCobIncInt.setEnabled(False)
5487 5517 # set Graph SpectraHeis
5488 5518 self.specHeisGgraphChannelList.setEnabled(False)
5489 5519 self.specHeisGgraphXminXmax.setEnabled(False)
5490 5520 self.specHeisGgraphYminYmax.setEnabled(False)
5491 5521 self.specHeisGgraphTminTmax.setEnabled(False)
5492 5522 self.specHeisGgraphTimeRange.setEnabled(False)
5493 5523 self.specHeisGgraphftpratio.setEnabled(False)
5494 5524 self.specHeisGraphPath.setEnabled(False)
5495 5525 self.specHeisGraphPrefix.setEnabled(False)
5496 5526 self.specHeisGraphToolPath.setEnabled(False)
5497 5527
5498 5528
5499 5529 # tool tip gui
5500 5530 QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
5501 5531 self.projectExplorerTree.setToolTip('Right clik to add Project or Unit Process')
5502 5532 # tool tip gui project
5503 5533 self.proComWalk.setToolTip('<b>On Files</b>:<i>Search file in format .r or pdata</i> <b>On Folders</b>:<i>Search file in a directory DYYYYDOY</i>')
5504 5534 self.proComWalk.setCurrentIndex(0)
5505 5535 # tool tip gui volOp
5506 5536 self.volOpChannel.setToolTip('Example: 1,2,3,4,5')
5507 5537 self.volOpHeights.setToolTip('Example: 90,180')
5508 5538 self.volOpFilter.setToolTip('Example: 2')
5509 5539 self.volOpProfile.setToolTip('Example:0,127')
5510 5540 self.volOpCohInt.setToolTip('Example: 128')
5511 5541 self.volOpFlip.setToolTip('ChannelList where flip will be applied. Example: 0,2,3')
5512 5542 self.volOpOk.setToolTip('If you have finished, please Ok ')
5513 5543 # tool tip gui volGraph
5514 5544 self.volGraphfreqrange.setToolTip('Height range. Example: 50,100')
5515 5545 self.volGraphHeightrange.setToolTip('Amplitude. Example: 0,10000')
5516 5546 # tool tip gui specOp
5517 5547 self.specOpnFFTpoints.setToolTip('Example: 128')
5518 5548 self.specOpProfiles.setToolTip('Example: 128')
5519 5549 self.specOpippFactor.setToolTip('Example:1.0')
5520 5550 self.specOpIncoherent.setToolTip('Example: 10')
5521 5551 self.specOpgetNoise.setToolTip('Example:20,180,30,120 (minHei,maxHei,minVel,maxVel)')
5522 5552
5523 5553 self.specOpChannel.setToolTip('Example: 0,1,2,3')
5524 5554 self.specOpHeights.setToolTip('Example: 90,180')
5525 5555 self.specOppairsList.setToolTip('Example: (0,1),(2,3)')
5526 5556 # tool tip gui specGraph
5527 5557
5528 5558 self.specGgraphChannelList.setToolTip('Example: 0,3,4')
5529 5559 self.specGgraphFreq.setToolTip('Example: -20,20')
5530 5560 self.specGgraphHeight.setToolTip('Example: 100,400')
5531 5561 self.specGgraphDbsrange.setToolTip('Example: 30,170')
5532 5562
5533 5563 self.specGraphPrefix.setToolTip('Example: EXPERIMENT_NAME')
5534 5564
5535 5565
5536 5566 self.specHeisOpIncoherent.setToolTip('Example: 10')
5537 5567
5538 5568 self.specHeisGgraphChannelList.setToolTip('Example: 0,2,3')
5539 5569 self.specHeisGgraphXminXmax.setToolTip('Example (Hz): -1000, 1000')
5540 5570 self.specHeisGgraphYminYmax.setToolTip('Example (dB): 5, 35')
5541 5571 self.specHeisGgraphTminTmax.setToolTip('Example (hours): 0, 24')
5542 5572 self.specHeisGgraphTimeRange.setToolTip('Example (hours): 8')
5543 5573
5544 5574 self.labelSet.show()
5545 5575 self.proSet.show()
5546 5576
5547 5577 self.labelIPPKm.hide()
5548 5578 self.proIPPKm.hide()
5549 5579
5550 5580 sys.stdout = ShowMeConsole(textWritten=self.normalOutputWritten)
5551 5581 # sys.stderr = ShowMeConsole(textWritten=self.errorOutputWritten)
5552 5582
5553 5583
5554 5584 class UnitProcessWindow(QMainWindow, Ui_UnitProcess):
5555 5585 """
5556 5586 Class documentation goes here.
5557 5587 """
5558 5588 closed = pyqtSignal()
5559 5589 create = False
5560 5590
5561 5591 def __init__(self, parent=None):
5562 5592 """
5563 5593 Constructor
5564 5594 """
5565 5595 QMainWindow.__init__(self, parent)
5566 5596 self.setupUi(self)
5567 5597 self.getFromWindow = None
5568 5598 self.getfromWindowList = []
5569 5599 self.dataTypeProject = None
5570 5600
5571 5601 self.listUP = None
5572 5602
5573 5603 @pyqtSignature("")
5574 5604 def on_unitPokbut_clicked(self):
5575 5605 """
5576 5606 Slot documentation goes here.
5577 5607 """
5578 5608 self.create = True
5579 5609 self.getFromWindow = self.getfromWindowList[int(self.comboInputBox.currentIndex())]
5580 5610 # self.nameofUP= str(self.nameUptxt.text())
5581 5611 self.typeofUP = str(self.comboTypeBox.currentText())
5582 5612 self.close()
5583 5613
5584 5614
5585 5615 @pyqtSignature("")
5586 5616 def on_unitPcancelbut_clicked(self):
5587 5617 """
5588 5618 Slot documentation goes here.
5589 5619 """
5590 5620 self.create = False
5591 5621 self.close()
5592 5622
5593 5623 def loadTotalList(self):
5594 5624 self.comboInputBox.clear()
5595 5625 for i in self.getfromWindowList:
5596 5626
5597 5627 name = i.getElementName()
5598 5628 if name == 'Project':
5599 5629 id = i.id
5600 5630 name = i.name
5601 5631 if self.dataTypeProject == 'Voltage':
5602 5632 self.comboTypeBox.clear()
5603 5633 self.comboTypeBox.addItem("Voltage")
5604 5634
5605 5635 if self.dataTypeProject == 'Spectra':
5606 5636 self.comboTypeBox.clear()
5607 5637 self.comboTypeBox.addItem("Spectra")
5608 5638 self.comboTypeBox.addItem("Correlation")
5609 5639 if self.dataTypeProject == 'Fits':
5610 5640 self.comboTypeBox.clear()
5611 5641 self.comboTypeBox.addItem("SpectraHeis")
5612 5642
5613 5643
5614 5644 if name == 'ProcUnit':
5615 5645 id = int(i.id) - 1
5616 5646 name = i.datatype
5617 5647 if name == 'Voltage':
5618 5648 self.comboTypeBox.clear()
5619 5649 self.comboTypeBox.addItem("Spectra")
5620 5650 self.comboTypeBox.addItem("SpectraHeis")
5621 5651 self.comboTypeBox.addItem("Correlation")
5622 5652 if name == 'Spectra':
5623 5653 self.comboTypeBox.clear()
5624 5654 self.comboTypeBox.addItem("Spectra")
5625 5655 self.comboTypeBox.addItem("SpectraHeis")
5626 5656 self.comboTypeBox.addItem("Correlation")
5627 5657 if name == 'SpectraHeis':
5628 5658 self.comboTypeBox.clear()
5629 5659 self.comboTypeBox.addItem("SpectraHeis")
5630 5660
5631 5661 self.comboInputBox.addItem(str(name))
5632 5662 # self.comboInputBox.addItem(str(name)+str(id))
5633 5663
5634 5664 def closeEvent(self, event):
5635 5665 self.closed.emit()
5636 5666 event.accept()
5637 5667
5638 5668 class Ftp(QMainWindow, Ui_Ftp):
5639 5669 """
5640 5670 Class documentation goes here.
5641 5671 """
5642 5672 create = False
5643 5673 closed = pyqtSignal()
5644 5674 server = None
5645 5675 remotefolder = None
5646 5676 username = None
5647 5677 password = None
5648 5678 ftp_wei = None
5649 5679 exp_code = None
5650 5680 sub_exp_code = None
5651 5681 plot_pos = None
5652 5682
5653 5683 def __init__(self, parent=None):
5654 5684 """
5655 5685 Constructor
5656 5686 """
5657 5687 QMainWindow.__init__(self, parent)
5658 5688 self.setupUi(self)
5659 5689 self.setGUIStatus()
5660 5690
5661 5691 def setGUIStatus(self):
5662 5692 self.setWindowTitle("ROJ-Signal Chain")
5663 5693 self.serverFTP.setToolTip('Example: jro-app.igp.gob.pe')
5664 5694 self.folderFTP.setToolTip('Example: /home/wmaster/graficos')
5665 5695 self.usernameFTP.setToolTip('Example: myusername')
5666 5696 self.passwordFTP.setToolTip('Example: mypass ')
5667 5697 self.weightFTP.setToolTip('Example: 0')
5668 5698 self.expcodeFTP.setToolTip('Example: 0')
5669 5699 self.subexpFTP.setToolTip('Example: 0')
5670 5700 self.plotposFTP.setToolTip('Example: 0')
5671 5701
5672 5702 def setParmsfromTemporal(self, server, remotefolder, username, password, ftp_wei, exp_code, sub_exp_code, plot_pos):
5673 5703 self.serverFTP.setText(str(server))
5674 5704 self.folderFTP.setText(str(remotefolder))
5675 5705 self.usernameFTP.setText(str(username))
5676 5706 self.passwordFTP.setText(str(password))
5677 5707 self.weightFTP.setText(str(ftp_wei))
5678 5708 self.expcodeFTP.setText(str(exp_code))
5679 5709 self.subexpFTP.setText(str(sub_exp_code))
5680 5710 self.plotposFTP.setText(str(plot_pos))
5681 5711
5682 5712 def getParmsFromFtpWindow(self):
5683 5713 """
5684 5714 Return Inputs Project:
5685 5715 - server
5686 5716 - remotefolder
5687 5717 - username
5688 5718 - password
5689 5719 - ftp_wei
5690 5720 - exp_code
5691 5721 - sub_exp_code
5692 5722 - plot_pos
5693 5723 """
5694 5724 name_server_ftp = str(self.serverFTP.text())
5695 5725 if not name_server_ftp:
5696 5726 self.console.clear()
5697 5727 self.console.append("Please Write a FTP Server")
5698 5728 return 0
5699 5729
5700 5730 folder_server_ftp = str(self.folderFTP.text())
5701 5731 if not folder_server_ftp:
5702 5732 self.console.clear()
5703 5733 self.console.append("Please Write a Folder")
5704 5734 return 0
5705 5735
5706 5736 username_ftp = str(self.usernameFTP.text())
5707 5737 if not username_ftp:
5708 5738 self.console.clear()
5709 5739 self.console.append("Please Write a User Name")
5710 5740 return 0
5711 5741
5712 5742 password_ftp = str(self.passwordFTP.text())
5713 5743 if not password_ftp:
5714 5744 self.console.clear()
5715 5745 self.console.append("Please Write a passwordFTP")
5716 5746 return 0
5717 5747
5718 5748 ftp_wei = str(self.weightFTP.text())
5719 5749 if not ftp_wei == "":
5720 5750 try:
5721 5751 ftp_wei = int(self.weightFTP.text())
5722 5752 except:
5723 5753 self.console.clear()
5724 5754 self.console.append("Please Write a ftp_wei number")
5725 5755 return 0
5726 5756
5727 5757 exp_code = str(self.expcodeFTP.text())
5728 5758 if not exp_code == "":
5729 5759 try:
5730 5760 exp_code = int(self.expcodeFTP.text())
5731 5761 except:
5732 5762 self.console.clear()
5733 5763 self.console.append("Please Write a exp_code number")
5734 5764 return 0
5735 5765
5736 5766
5737 5767 sub_exp_code = str(self.subexpFTP.text())
5738 5768 if not sub_exp_code == "":
5739 5769 try:
5740 5770 sub_exp_code = int(self.subexpFTP.text())
5741 5771 except:
5742 5772 self.console.clear()
5743 5773 self.console.append("Please Write a sub_exp_code number")
5744 5774 return 0
5745 5775
5746 5776 plot_pos = str(self.plotposFTP.text())
5747 5777 if not plot_pos == "":
5748 5778 try:
5749 5779 plot_pos = int(self.plotposFTP.text())
5750 5780 except:
5751 5781 self.console.clear()
5752 5782 self.console.append("Please Write a plot_pos number")
5753 5783 return 0
5754 5784
5755 5785 return name_server_ftp, folder_server_ftp, username_ftp, password_ftp, ftp_wei, exp_code, sub_exp_code, plot_pos
5756 5786
5757 5787 @pyqtSignature("")
5758 5788 def on_ftpOkButton_clicked(self):
5759 5789 server, remotefolder, username, password, ftp_wei, exp_code, sub_exp_code, plot_pos = self.getParmsFromFtpWindow()
5760 5790 self.create = True
5761 5791 self.close()
5762 5792
5763 5793 @pyqtSignature("")
5764 5794 def on_ftpCancelButton_clicked(self):
5765 5795 self.create = False
5766 5796 self.close()
5767 5797
5768 5798 def closeEvent(self, event):
5769 5799 self.closed.emit()
5770 5800 event.accept()
5771 5801
5772 5802 class ftpBuffer():
5773 5803
5774 5804 server = None
5775 5805 remotefolder = None
5776 5806 username = None
5777 5807 password = None
5778 5808 ftp_wei = None
5779 5809 exp_code = None
5780 5810 sub_exp_code = None
5781 5811 plot_pos = None
5782 5812 create = False
5783 5813 withoutconfig = False
5784 5814 createforView = False
5785 5815 localfolder = None
5786 5816 extension = None
5787 5817 period = None
5788 5818 protocol = None
5789 5819
5790 5820 def __init__(self):
5791 5821
5792 5822 self.create = False
5793 5823 self.server = None
5794 5824 self.remotefolder = None
5795 5825 self.username = None
5796 5826 self.password = None
5797 5827 self.ftp_wei = None
5798 5828 self.exp_code = None
5799 5829 self.sub_exp_code = None
5800 5830 self.plot_pos = None
5801 5831 # self.create = False
5802 5832 self.localfolder = None
5803 5833 self.extension = None
5804 5834 self.period = None
5805 5835 self.protocol = None
5806 5836
5807 5837 def setwithoutconfiguration(self):
5808 5838
5809 5839 self.create = False
5810 5840 self.server = "jro-app.igp.gob.pe"
5811 5841 self.remotefolder = "/home/wmaster/graficos"
5812 5842 self.username = "wmaster"
5813 5843 self.password = "mst2010vhf"
5814 5844 self.withoutconfig = True
5815 5845 self.localfolder = './'
5816 5846 self.extension = '.png'
5817 5847 self.period = 60
5818 5848 self.protocol = 'ftp'
5819 5849 self.createforView = True
5820 5850
5821 5851 if not self.ftp_wei:
5822 5852 self.ftp_wei = 0
5823 5853
5824 5854 if not self.exp_code:
5825 5855 self.exp_code = 0
5826 5856
5827 5857 if not self.sub_exp_code:
5828 5858 self.sub_exp_code = 0
5829 5859
5830 5860 if not self.plot_pos:
5831 5861 self.plot_pos = 0
5832 5862
5833 5863 def save(self, server, remotefolder, username, password, ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, localfolder='./', extension='.png', period=60, protocol='ftp'):
5834 5864
5835 5865 self.server = server
5836 5866 self.remotefolder = remotefolder
5837 5867 self.username = username
5838 5868 self.password = password
5839 5869 self.ftp_wei = ftp_wei
5840 5870 self.exp_code = exp_code
5841 5871 self.sub_exp_code = sub_exp_code
5842 5872 self.plot_pos = plot_pos
5843 5873 self.create = True
5844 5874 self.withoutconfig = False
5845 5875 self.createforView = True
5846 5876 self.localfolder = localfolder
5847 5877 self.extension = extension
5848 5878 self.period = period
5849 5879 self.protocol = protocol
5850 5880
5851 5881 def recover(self):
5852 5882
5853 5883 return self.server, self.remotefolder, self.username, self.password, self.ftp_wei, self.exp_code, self.sub_exp_code, self.plot_pos, self.extension, self.period, self.protocol
5854 5884
5855 5885 class ShowMeConsole(QtCore.QObject):
5856 5886
5857 5887 textWritten = QtCore.pyqtSignal(str)
5858 5888
5859 5889 def write(self, text):
5860 5890
5861 5891 if len(text) == 0:
5862 5892 self.textWritten.emit("\n")
5863 5893 return
5864 5894
5865 5895 if text[-1] == "\n":
5866 5896 text = text[:-1]
5867 5897
5868 5898 self.textWritten.emit(str(text))
General Comments 0
You need to be logged in to leave comments. Login now