Guest User

Untitled

a guest
Nov 17th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.44 KB | None | 0 0
  1. class dataCapture(gr.sync_block):
  2.     """
  3.    docstring for block dataCapture
  4.    """
  5.     def __init__(self,IP="192.168.122.3",DataKind="RawTimeSamples",DataSource=0,Channel=0,size=1024,port=0):
  6.       gr.sync_block.__init__(self,name="dataCapture",in_sig=None,out_sig=[numpy.float32])
  7.                                
  8.       kind = 2
  9.       if  (DataKind=="RawTimeSamples"):
  10.         kind = 1
  11.         self.size     = size
  12.       elif(DataKind=="WindowingSamples"):
  13.         kind = 2
  14.         self.size     = size/2
  15.  
  16.       self.position = 0
  17.      
  18.       ### Capture packet
  19.       self.DataSelection = namedtuple('DataSelection',['DataKind','DataSource','Channel','SizePc'])
  20.       self.DataSelectionArray = []
  21.       self.newObject = self.DataSelection(kind,DataSource,Channel,5)
  22.       self.DataSelectionArray.append(self.newObject)
  23.  
  24.       ### Crear socket
  25.       self.socketServer = serverCommander.authenticate(IP)
  26.        
  27.  
  28.     def work(self, input_items, output_items):
  29.       for i in range(0, len(output_items[0])):
  30.         # rellenar
  31.         if (self.position == 0):
  32.           self.CaptureArray = serverCommander.captureData(self.socketServer[0],self.DataSelectionArray)
  33.  
  34.         output_items[0][i] = (self.CaptureArray[0].Data[self.subkind])[self.position]
  35.         self.position = self.position + 1
  36.        
  37.         ## reiniciar
  38.         if (self.position == self.size):
  39.           self.position = 0
  40.          
  41.       return len(output_items[0])
Add Comment
Please, Sign In to add comment