@@ -647,21 +647,49 class Project(Process): | |||
|
647 | 647 | |
|
648 | 648 | err = False |
|
649 | 649 | n = len(self.configurations) |
|
650 | #print(n) | |
|
651 | ||
|
650 | flag_no_read = False | |
|
651 | nProc_noRead = 0 | |
|
652 | ||
|
653 | #while not err: | |
|
654 | # for conf in self.getUnits(): | |
|
655 | # ok = conf.run() | |
|
656 | # if ok == 'Error': | |
|
657 | # n -= 1 | |
|
658 | # continue | |
|
659 | # elif not ok: | |
|
660 | # break | |
|
661 | # if n == 0: | |
|
662 | # err = True | |
|
663 | ||
|
652 | 664 | while not err: |
|
653 | #print(self.getUnits()) | |
|
665 | n_proc = 0 | |
|
654 | 666 | for conf in self.getUnits(): |
|
655 | #print(conf) | |
|
656 | ok = conf.run() | |
|
657 | #print("ok", ok) | |
|
667 | if flag_no_read: | |
|
668 | if n_proc >= nProc_noRead: | |
|
669 | ok = conf.run() | |
|
670 | else: | |
|
671 | n_proc += 1 | |
|
672 | continue | |
|
673 | else: | |
|
674 | ok = conf.run() | |
|
675 | ||
|
676 | n_proc += 1 | |
|
677 | ||
|
658 | 678 | if ok == 'Error': |
|
659 | 679 | n -= 1 |
|
660 | 680 | continue |
|
681 | ||
|
682 | elif ok == 'no_Read' and (not flag_no_read): | |
|
683 | nProc_noRead = n_proc - 1 | |
|
684 | flag_no_read = True | |
|
685 | continue | |
|
686 | elif ok == 'new_Read': | |
|
687 | nProc_noRead = 0 | |
|
688 | flag_no_read = False | |
|
689 | continue | |
|
661 | 690 | elif not ok: |
|
662 | 691 | break |
|
663 | #print("****************************************************end") | |
|
664 | #exit(1) | |
|
692 | ||
|
665 | 693 | if n == 0: |
|
666 | 694 | err = True |
|
667 | 695 |
@@ -67,29 +67,25 class ProcessingUnit(object): | |||
|
67 | 67 | return self.operations[objId] |
|
68 | 68 | |
|
69 | 69 | def call(self, **kwargs): |
|
70 | ''' | |
|
71 | ''' | |
|
72 | 70 | |
|
71 | mybool = (self.dataOut.type == 'Voltage') and self.dataOut.useInputBuffer and (not self.dataOut.buffer_empty) #liberar desde buffer | |
|
72 | ||
|
73 | 73 | try: |
|
74 | if self.dataIn is not None and self.dataIn.flagNoData and not self.dataIn.error: | |
|
75 | #if self.dataIn is not None and self.dataIn.flagNoData and not self.dataIn.error and not self.dataIn.runNextUnit: | |
|
76 | if self.dataIn.runNextUnit: | |
|
77 | #print("SUCCESSSSSSS") | |
|
78 | #exit(1) | |
|
79 | return not self.dataIn.isReady() | |
|
80 | else: | |
|
81 | return self.dataIn.isReady() | |
|
82 | elif self.dataIn is None or not self.dataIn.error: | |
|
83 | if 'Reader' in self.name and self.bypass: | |
|
84 | print('Skipping...reader') | |
|
85 | return self.dataOut.isReady() | |
|
74 | if mybool: | |
|
75 | #print("run jeje") | |
|
86 | 76 | self.run(**kwargs) |
|
87 |
el |
|
|
88 | #print("Elif 2") | |
|
89 |
|
|
|
90 | self.dataOut.flagNoData = True | |
|
77 | else: | |
|
78 | if self.dataIn is not None and self.dataIn.flagNoData and not self.dataIn.error: | |
|
79 | return self.dataIn.isReady() | |
|
80 | elif self.dataIn is None or not self.dataIn.error: #unidad de lectura o procesamiento regular | |
|
81 | self.run(**kwargs) | |
|
82 | elif self.dataIn.error: | |
|
83 | self.dataOut.error = self.dataIn.error | |
|
84 | self.dataOut.flagNoData = True | |
|
85 | print("exec proc error") | |
|
86 | ||
|
91 | 87 | except: |
|
92 | #print("Except") | |
|
88 | ||
|
93 | 89 | err = traceback.format_exc() |
|
94 | 90 | if 'SchainWarning' in err: |
|
95 | 91 | log.warning(err.split('SchainWarning:')[-1].split('\n')[0].strip(), self.name) |
@@ -98,39 +94,37 class ProcessingUnit(object): | |||
|
98 | 94 | else: |
|
99 | 95 | log.error(err, self.name) |
|
100 | 96 | self.dataOut.error = True |
|
101 | #print("before op") | |
|
97 | ||
|
98 | ||
|
102 | 99 | for op, optype, opkwargs in self.operations: |
|
103 | aux = self.dataOut.copy() | |
|
104 | #aux = copy.deepcopy(self.dataOut) | |
|
105 | #print("**********************Before",op) | |
|
106 | if optype == 'other' and not self.dataOut.flagNoData: | |
|
107 | #print("**********************Other",op) | |
|
108 |
|
|
|
109 |
self.dataOut = |
|
|
110 | elif optype == 'external' and not self.dataOut.flagNoData: | |
|
111 | op.queue.put(aux) | |
|
100 | ||
|
101 | if (optype == 'other' and self.dataOut.isReady()) or mybool: | |
|
102 | try: | |
|
103 | self.dataOut = op.run(self.dataOut, **opkwargs) | |
|
104 | except Exception as e: | |
|
105 | print(e) | |
|
106 | self.dataOut.error = True | |
|
107 | return 'Error' | |
|
108 | elif optype == 'external' and self.dataOut.isReady() : | |
|
109 | op.queue.put(copy.deepcopy(self.dataOut)) | |
|
112 | 110 | elif optype == 'external' and self.dataOut.error: |
|
113 |
op.queue.put( |
|
|
114 | #elif optype == 'external' and self.dataOut.isReady(): | |
|
115 | #op.queue.put(copy.deepcopy(self.dataOut)) | |
|
116 | #print(not self.dataOut.isReady()) | |
|
111 | op.queue.put(copy.deepcopy(self.dataOut)) | |
|
117 | 112 | |
|
118 | try: | |
|
119 | if self.dataOut.runNextUnit: | |
|
120 | runNextUnit = self.dataOut.runNextUnit | |
|
121 | #print(self.operations) | |
|
122 | #print("Tru") | |
|
123 | 113 | |
|
114 | if not self.dataOut.error: | |
|
115 | if self.dataOut.type == 'Voltage': | |
|
116 | if not self.dataOut.buffer_empty : #continue | |
|
117 | return 'no_Read' | |
|
118 | elif self.dataOut.useInputBuffer and (self.dataOut.buffer_empty) and self.dataOut.isReady() : | |
|
119 | return 'new_Read' | |
|
120 | else: | |
|
121 | return True | |
|
124 | 122 | else: |
|
125 | runNextUnit = self.dataOut.isReady() | |
|
126 | except: | |
|
127 | runNextUnit = self.dataOut.isReady() | |
|
128 |
|
|
|
129 |
# |
|
|
130 | #return 'Error' if self.dataOut.error else input() | |
|
131 | #print("NexT",runNextUnit) | |
|
132 | #print("error: ",self.dataOut.error) | |
|
133 | return 'Error' if self.dataOut.error else runNextUnit# self.dataOut.isReady() | |
|
123 | #print("ret True") | |
|
124 | return True | |
|
125 | else: | |
|
126 | return 'Error' | |
|
127 | #return 'Error' if self.dataOut.error else True #self.dataOut.isReady() | |
|
134 | 128 | |
|
135 | 129 | def setup(self): |
|
136 | 130 |
@@ -7483,3 +7483,97 class PulsePairVoltage(Operation): | |||
|
7483 | 7483 | # self.__startIndex += self.__newNSamples |
|
7484 | 7484 | # |
|
7485 | 7485 | # return |
|
7486 | ||
|
7487 | class ToLilBlock(Operation): | |
|
7488 | ||
|
7489 | ''' | |
|
7490 | Class to separate blocks of data | |
|
7491 | ||
|
7492 | ''' | |
|
7493 | ||
|
7494 | isConfig = False | |
|
7495 | n = None | |
|
7496 | __timeInterval = None | |
|
7497 | __profIndex = 0 | |
|
7498 | __byTime = False | |
|
7499 | __dataReady = False | |
|
7500 | __buffer_data = [] | |
|
7501 | __buffer_times = [] | |
|
7502 | __initime = None | |
|
7503 | __count_exec = 0 | |
|
7504 | __profIndex = 0 | |
|
7505 | buffer = None | |
|
7506 | lenProfileOut = 1 | |
|
7507 | init_prof = 0 | |
|
7508 | end_prof = 0 | |
|
7509 | n_profiles = 0 | |
|
7510 | first_utcBlock = None | |
|
7511 | __dh = 0 | |
|
7512 | ||
|
7513 | ||
|
7514 | def __init__(self, **kwargs): | |
|
7515 | ||
|
7516 | Operation.__init__(self, **kwargs) | |
|
7517 | ||
|
7518 | self.isConfig = False | |
|
7519 | ||
|
7520 | ||
|
7521 | def setup(self,dataOut): | |
|
7522 | ||
|
7523 | self.init_prof = 0 | |
|
7524 | self.end_prof = 0 | |
|
7525 | ||
|
7526 | def releaseBlock(self, dataOut): | |
|
7527 | ||
|
7528 | if self.n % self.lenProfileOut != 0: | |
|
7529 | raise ValueError("lenProfileOut %d must be submultiple of nProfiles %d" %(self.lenProfileOut, self.n_profiles)) | |
|
7530 | return None | |
|
7531 | ||
|
7532 | dataOut.data = self.buffer[:,self.init_prof:self.end_prof,:] #ch, prof, alt | |
|
7533 | self.init_prof = self.end_prof | |
|
7534 | self.end_prof += self.lenProfileOut | |
|
7535 | if self.init_prof == self.n: | |
|
7536 | #if self.end_prof >= (self.n +self.lenProfileOut): | |
|
7537 | self.init_prof = 0 | |
|
7538 | self.__profIndex = 0 | |
|
7539 | self.buffer = None | |
|
7540 | dataOut.buffer_empty = True | |
|
7541 | #print("done") | |
|
7542 | return dataOut | |
|
7543 | ||
|
7544 | ||
|
7545 | def run(self, dataOut, nProfilesOut=1): | |
|
7546 | ||
|
7547 | self.n = dataOut.nProfiles | |
|
7548 | self.nChannels = dataOut.nChannels | |
|
7549 | self.nHeights = dataOut.nHeights | |
|
7550 | ||
|
7551 | #print(dataOut.data.shape) | |
|
7552 | #exit(1) | |
|
7553 | if not self.isConfig: | |
|
7554 | self.setup(dataOut) | |
|
7555 | self.isConfig = True | |
|
7556 | ||
|
7557 | dataBlock = None | |
|
7558 | ||
|
7559 | if not dataOut.buffer_empty: | |
|
7560 | if self.init_prof == 0: | |
|
7561 | self.lenProfileOut = nProfilesOut | |
|
7562 | dataOut.flagNoData = False | |
|
7563 | self.init_prof = 0 | |
|
7564 | self.end_prof = self.lenProfileOut | |
|
7565 | dataOut.nProfiles = self.lenProfileOut | |
|
7566 | dataOut.error = False | |
|
7567 | ||
|
7568 | dataOut.flagNoData = False | |
|
7569 | ||
|
7570 | return self.releaseBlock(dataOut) | |
|
7571 | ||
|
7572 | dataOut.flagNoData = True | |
|
7573 | self.buffer = dataOut.data.copy() | |
|
7574 | dataOut.error = False | |
|
7575 | dataOut.useInputBuffer = True | |
|
7576 | dataOut.buffer_empty = False | |
|
7577 | ||
|
7578 | ||
|
7579 | return dataOut No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now