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