##// END OF EJS Templates
Multiprocessing for digitalRF just for reading Unit(Task #1461 )
George Yong -
r1192:fa272605c13d
parent child
Show More
@@ -416,7 +416,7 class OperationConf():
416 self.name = opElement.get('name')
416 self.name = opElement.get('name')
417 self.type = opElement.get('type')
417 self.type = opElement.get('type')
418 self.priority = opElement.get('priority')
418 self.priority = opElement.get('priority')
419 self.project_id = str(project_id) #yong
419 self.project_id = str(project_id)
420
420
421 # Compatible with old signal chain version
421 # Compatible with old signal chain version
422 # Use of 'run' method instead 'init'
422 # Use of 'run' method instead 'init'
@@ -673,7 +673,7 class ProcUnitConf():
673 '''
673 '''
674 Instancia de unidades de procesamiento.
674 Instancia de unidades de procesamiento.
675 '''
675 '''
676
676
677 className = eval(self.name)
677 className = eval(self.name)
678 kwargs = self.getKwargs()
678 kwargs = self.getKwargs()
679 procUnitObj = className(self.id, self.inputId, self.project_id, **kwargs) # necesitan saber su id y su entrada por fines de ipc
679 procUnitObj = className(self.id, self.inputId, self.project_id, **kwargs) # necesitan saber su id y su entrada por fines de ipc
@@ -1130,8 +1130,11 class Project(Process):
1130
1130
1131 def createObjects(self):
1131 def createObjects(self):
1132
1132
1133 for procUnitConfObj in self.procUnitConfObjDict.values():
1133
1134 procUnitConfObj.createObjects()
1134 keys = list(self.procUnitConfObjDict.keys())
1135 keys.sort()
1136 for key in keys:
1137 self.procUnitConfObjDict[key].createObjects()
1135
1138
1136 def __handleError(self, procUnitConfObj, modes=None, stdout=True):
1139 def __handleError(self, procUnitConfObj, modes=None, stdout=True):
1137
1140
@@ -24,7 +24,7 except:
24
24
25 from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader
25 from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader
26 from schainpy.model.data.jrodata import Voltage
26 from schainpy.model.data.jrodata import Voltage
27 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
27 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator
28 from time import time
28 from time import time
29
29
30 import pickle
30 import pickle
@@ -33,18 +33,18 try:
33 except:
33 except:
34 print('You should install "digital_rf" module if you want to read Digital RF data')
34 print('You should install "digital_rf" module if you want to read Digital RF data')
35
35
36
36 @MPDecorator
37 class DigitalRFReader(ProcessingUnit):
37 class DigitalRFReader(ProcessingUnit):
38 '''
38 '''
39 classdocs
39 classdocs
40 '''
40 '''
41
41
42 def __init__(self, **kwargs):
42 def __init__(self):
43 '''
43 '''
44 Constructor
44 Constructor
45 '''
45 '''
46
46
47 ProcessingUnit.__init__(self, **kwargs)
47 ProcessingUnit.__init__(self)
48
48
49 self.dataOut = Voltage()
49 self.dataOut = Voltage()
50 self.__printInfo = True
50 self.__printInfo = True
@@ -569,18 +569,22 class DigitalRFReader(ProcessingUnit):
569 if self.__readNextBlock():
569 if self.__readNextBlock():
570 break
570 break
571 if self.__thisUnixSample > self.__endUTCSecond * self.__sample_rate:
571 if self.__thisUnixSample > self.__endUTCSecond * self.__sample_rate:
572 return False
572 self.dataOut.error = (1, '')
573 return
573
574
574 if self.__flagDiscontinuousBlock:
575 if self.__flagDiscontinuousBlock:
575 print('[Reading] discontinuous block found ... continue with the next block')
576 print('[Reading] discontinuous block found ... continue with the next block')
576 continue
577 self.dataOut.error = (1, '')
577
578 return
579
578 if not self.__online:
580 if not self.__online:
579 return False
581 self.dataOut.error = (1, '')
582 return
580
583
581 err_counter += 1
584 err_counter += 1
582 if err_counter > nTries:
585 if err_counter > nTries:
583 return False
586 self.dataOut.error = (1, '')
587 return
584
588
585 print('[Reading] waiting %d seconds to read a new block' % seconds)
589 print('[Reading] waiting %d seconds to read a new block' % seconds)
586 sleep(seconds)
590 sleep(seconds)
@@ -599,7 +603,7 class DigitalRFReader(ProcessingUnit):
599 if self.profileIndex == self.dataOut.nProfiles:
603 if self.profileIndex == self.dataOut.nProfiles:
600 self.profileIndex = 0
604 self.profileIndex = 0
601
605
602 return True
606 return
603
607
604 def printInfo(self):
608 def printInfo(self):
605 '''
609 '''
@@ -780,6 +784,8 class DigitalRFWriter(Operation):
780 # self.writeMetadata()
784 # self.writeMetadata()
781 ## if self.currentSample == self.__nProfiles: self.currentSample = 0
785 ## if self.currentSample == self.__nProfiles: self.currentSample = 0
782
786
787 return dataOut
788
783 def close(self):
789 def close(self):
784 print('[Writing] - Closing files ')
790 print('[Writing] - Closing files ')
785 print('Average of writing to digital rf format is ', self.oldAverage * 1000)
791 print('Average of writing to digital rf format is ', self.oldAverage * 1000)
@@ -789,12 +795,3 class DigitalRFWriter(Operation):
789 pass
795 pass
790
796
791
797
792 # raise
793 if __name__ == '__main__':
794
795 readObj = DigitalRFReader()
796
797 while True:
798 readObj.run(path='/home/jchavez/jicamarca/mocked_data/')
799 # readObj.printInfo()
800 # readObj.printNumberOfBlock() No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now