@@ -647,21 +647,49 class Project(Process): | |||||
647 |
|
647 | |||
648 | err = False |
|
648 | err = False | |
649 | n = len(self.configurations) |
|
649 | n = len(self.configurations) | |
650 | #print(n) |
|
650 | flag_no_read = False | |
651 |
|
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 | while not err: |
|
664 | while not err: | |
653 | #print(self.getUnits()) |
|
665 | n_proc = 0 | |
654 | for conf in self.getUnits(): |
|
666 | for conf in self.getUnits(): | |
655 | #print(conf) |
|
667 | if flag_no_read: | |
656 | ok = conf.run() |
|
668 | if n_proc >= nProc_noRead: | |
657 | #print("ok", ok) |
|
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 | if ok == 'Error': |
|
678 | if ok == 'Error': | |
659 | n -= 1 |
|
679 | n -= 1 | |
660 | continue |
|
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 | elif not ok: |
|
690 | elif not ok: | |
662 | break |
|
691 | break | |
663 | #print("****************************************************end") |
|
692 | ||
664 | #exit(1) |
|
|||
665 | if n == 0: |
|
693 | if n == 0: | |
666 | err = True |
|
694 | err = True | |
667 |
|
695 |
@@ -67,29 +67,25 class ProcessingUnit(object): | |||||
67 | return self.operations[objId] |
|
67 | return self.operations[objId] | |
68 |
|
68 | |||
69 | def call(self, **kwargs): |
|
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 | try: |
|
73 | try: | |
74 | if self.dataIn is not None and self.dataIn.flagNoData and not self.dataIn.error: |
|
74 | if mybool: | |
75 | #if self.dataIn is not None and self.dataIn.flagNoData and not self.dataIn.error and not self.dataIn.runNextUnit: |
|
75 | #print("run jeje") | |
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() |
|
|||
86 | self.run(**kwargs) |
|
76 | self.run(**kwargs) | |
87 |
el |
|
77 | else: | |
88 | #print("Elif 2") |
|
78 | if self.dataIn is not None and self.dataIn.flagNoData and not self.dataIn.error: | |
89 |
|
|
79 | return self.dataIn.isReady() | |
90 | self.dataOut.flagNoData = True |
|
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 | except: |
|
87 | except: | |
92 | #print("Except") |
|
88 | ||
93 | err = traceback.format_exc() |
|
89 | err = traceback.format_exc() | |
94 | if 'SchainWarning' in err: |
|
90 | if 'SchainWarning' in err: | |
95 | log.warning(err.split('SchainWarning:')[-1].split('\n')[0].strip(), self.name) |
|
91 | log.warning(err.split('SchainWarning:')[-1].split('\n')[0].strip(), self.name) | |
@@ -98,39 +94,37 class ProcessingUnit(object): | |||||
98 | else: |
|
94 | else: | |
99 | log.error(err, self.name) |
|
95 | log.error(err, self.name) | |
100 | self.dataOut.error = True |
|
96 | self.dataOut.error = True | |
101 | #print("before op") |
|
97 | ||
|
98 | ||||
102 | for op, optype, opkwargs in self.operations: |
|
99 | for op, optype, opkwargs in self.operations: | |
103 | aux = self.dataOut.copy() |
|
100 | ||
104 | #aux = copy.deepcopy(self.dataOut) |
|
101 | if (optype == 'other' and self.dataOut.isReady()) or mybool: | |
105 | #print("**********************Before",op) |
|
102 | try: | |
106 | if optype == 'other' and not self.dataOut.flagNoData: |
|
103 | self.dataOut = op.run(self.dataOut, **opkwargs) | |
107 | #print("**********************Other",op) |
|
104 | except Exception as e: | |
108 |
|
|
105 | print(e) | |
109 |
self.dataOut = |
|
106 | self.dataOut.error = True | |
110 | elif optype == 'external' and not self.dataOut.flagNoData: |
|
107 | return 'Error' | |
111 | op.queue.put(aux) |
|
108 | elif optype == 'external' and self.dataOut.isReady() : | |
|
109 | op.queue.put(copy.deepcopy(self.dataOut)) | |||
112 | elif optype == 'external' and self.dataOut.error: |
|
110 | elif optype == 'external' and self.dataOut.error: | |
113 |
op.queue.put( |
|
111 | op.queue.put(copy.deepcopy(self.dataOut)) | |
114 | #elif optype == 'external' and self.dataOut.isReady(): |
|
|||
115 | #op.queue.put(copy.deepcopy(self.dataOut)) |
|
|||
116 | #print(not self.dataOut.isReady()) |
|
|||
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 | else: |
|
122 | else: | |
125 | runNextUnit = self.dataOut.isReady() |
|
123 | #print("ret True") | |
126 | except: |
|
124 | return True | |
127 | runNextUnit = self.dataOut.isReady() |
|
125 | else: | |
128 |
|
|
126 | return 'Error' | |
129 |
# |
|
127 | #return 'Error' if self.dataOut.error else True #self.dataOut.isReady() | |
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() |
|
|||
134 |
|
128 | |||
135 | def setup(self): |
|
129 | def setup(self): | |
136 |
|
130 |
@@ -7483,3 +7483,97 class PulsePairVoltage(Operation): | |||||
7483 | # self.__startIndex += self.__newNSamples |
|
7483 | # self.__startIndex += self.__newNSamples | |
7484 | # |
|
7484 | # | |
7485 | # return |
|
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