def Generate_Output_Signals ( self, In, Out, Par, XIn, XOut, XPar ) : if not ( In [1] ) : return if XIn [1] : #print ( '******************** BP1', Par ) # get index of the selected signal S = Par [2] - 1 #print ( 'BP1', S ) data, params = Analyze_TIO_Array ( In [1] ) #print ( 'BP2', type(data),len(data)) #print ( 'BP3', type(data[S]),len(data[S]),data[S].shape) #Analyze_TIO_Array # limit the selector switch #print ( 'Selected Signal', S, len (data), data.shape ) if S > len ( data ) : S = len ( data ) self.GUI_Controls [0] = SetValue ( S ) # MetaData = [] if not ( self.Initialized ) : self.Initialized = True Names = self.BP.Get_Signal_Names () for chan, Name in enumerate ( Names ) : Signal_Attr = class_MetaData () MetaData.append ( Signal_Attr ) Signal_Attr.SignalName = Name if chan in ( 3, 4 ) : Signal_Attr.Calibrate = 1, 0 else : Signal_Attr.Calibrate = params[0].Get ( 'Calibrate', (1,0) ) Signal_Attr.Units = params[0].Get ( 'Units', 'mmHg' ) """ return [ 'Psys', 'Pdias', 'MAP', 'BPM', 'RR [msec]', 'BP-filt' ] """ #Out[1] = \ # self.BP.execute ( data [S] )[0], MetaData if MetaData : MetaData = MetaData[0] print ( 'METEATAT', MetaData.SignalName) Out[1] = \ self.BP.execute ( data [S] )[0], MetaData
def Run_Script(self, node, recursive): from control_scope_base import tScope_Display_Light nodename = self.Tree.GetItemText(node) print('************ RUN SCRIPT ' + nodename) self.tree_globs['DISPLAY'] = None # Signals self.tree_globs['Display_Params'] = None # Signal Parameters self.tree_globs['Display_Title'] = None # Window Caption self.tree_globs['Auto'] = True # AutoScale filename = self.Get_Editor_Filename(nodename) execfile(filename, self.tree_globs) # Update Display if output and display is On Display_On = (self.Tree.GetItemImage(node) == 78) Display_Data = self.tree_globs['DISPLAY'] Display_Params = self.tree_globs['Display_Params'] Display_Title = self.tree_globs['Display_Title'] if Display_On and (Display_Data != None): PyData = self.Tree.GetPyData(node) if len(PyData) < 4: PyData.append(tScope_Display_Light(self, node)) self.Tree.SetPyData(node, PyData) # Create a list of MetaData MetaData = [] for par in Display_Params: Signal_Attr = class_MetaData() Signal_Attr.SignalName = par.pop(0) if len(par) >= 2: bottom = par.pop(0) top = par.pop(0) Signal_Attr.DisplayRange = (bottom, top) MetaData.append(Signal_Attr) #PyData[3].Scope.Add_Data ( Display_Data, Display_Params, Display_Title ) PyData[3].Scope.Add_Data(Display_Data, MetaData) # process children through recursion if recursive and self.Tree.HasChildren(node): item, cookie = self.Tree.GetFirstChild(node) while item: self.Run_Script(item, recursive) item = self.Tree.GetNextSibling(item)
def Generate_Output_Signals ( self, In, Out, Par, XIn, XOut, XPar ) : # If parameter changed, send all if XPar[0] : """ self.Signal_Attr.Name = Par [2] self.Signal_Attr.Color = Par [3] self.Signal_Attr.LineWidth = Par [4] Out[1] = In[1], self.Signal_Attr """ Signal_Attr = class_MetaData () Signal_Attr.Name = Par [2] Signal_Attr.Color = Par [3] Signal_Attr.LineWidth = Par [4] Out[1] = In[1], Signal_Attr print ( '++++++++++ PyPlot Signal', XPar ) # else send only the signal else : #print ( '++++++++++ PyPlot Signal nooooo PARRRR') Out[1] = In[1] """
def Generate_Output_Signals ( self, In, Out, Par, XIn, XOut, XPar ) : if XPar [1] : if not ( File_Exists ( Par [1] ) ) : return Out [1] = Par [1] if self.Output_Connected [2] : import wave wav = wave.open ( Par[1], 'r' ) amount = 14 * 256 * 35 #Max Amount MetaData = class_MetaData() MetaData.Frequency = wav.getframerate () MetaData.ByteWidth = wav.getsampwidth () if MetaData.ByteWidth == 1: data = fromstring(wav.readframes(amount),uint8) else: data = fromstring(wav.readframes(amount),'>i'+str(MetaData.ByteWidth)) Out [2] = data,MetaData print ( 'BTC', type ( Out[2]), type (data) )
def Start_ADC_FirstTime ( self ): self.ADC_NChan = self.Spin_NChan.GetValue() # ADC / NChan / sample-frequency / bufsize / file line = str ( self.Combo_ADC.GetSelection () ) + '/' line += str ( self.ADC_NChan ) + '/' line += self.Fsamp.GetValue() + '/' # BUF_max zou moeten zijn 0.5 seconden of zo: Nchan*4*fSamp line += str ( self.Buf_Max ) + '/' line += self.ADC_File.GetValue () self.Start_Code = line #if self.Test : self.Memo.AppendText ( 'OPEN: ' + line ) # Get MetaData filename ,ext = os.path.splitext ( self.ADC_File.GetValue () ) self.ADC_MetaFile = filename + '.c' + ext [2:] self.Memo.AppendText ( '\nMetaDataFile = ' + self.ADC_MetaFile ) self.MetaData = [] meta_ini = win_inifile ( self.ADC_MetaFile, Force_Identifiers = True ) meta_ini.Section = 'ad-converter' First_Channel = meta_ini.Read_Integer ( 'AD-channel_first', 1 ) Last_Channel = meta_ini.Read_Integer ( 'AD-channel_last' , 4 ) self.Memo.AppendText ( '\nChannels = ' + str (First_Channel) + '/' + str(Last_Channel) ) #ADC1 = meta_ini.Read_Integer ( 'AD_ondergrens_(ADC)' , -10 ) #ADC2 = meta_ini.Read_Integer ( 'AD_bovengrens_(ADC)' , +10 ) #V1 = meta_ini.Read_Integer ( 'AD_ondergrens_(V)' , -110 ) #V2 = meta_ini.Read_Integer ( 'AD_bovengrens_(V)' , +110 ) #print 'PPPPPPPPPTTTT', ADC1,ADC2, V1,V2 self.gain = [] self.offset = [] ##self.ADC_NChan = Last_Channel + 1 - First_Channel for chan in range ( First_Channel, Last_Channel+1 ) : Signal_Attr = class_MetaData () self.MetaData.append ( Signal_Attr ) meta_ini.Section = 'Signal-' + str ( chan ) Chan_Name = meta_ini.Read ( 'name' , '???' ) Chan_Units = meta_ini.Read ( 'measurement_units' , '' ) line = Chan_Name + ' [' + Chan_Units + ']' self.Memo.AppendText ( '\n chan-' + str ( chan ) + ' = ' + line ) Signal_Attr.SignalName = line x1 = ADV1 = meta_ini.Read_Integer ( 'lower_ADV-value' , -10 ) x2 = ADV2 = meta_ini.Read_Integer ( 'upper_ADV-value' , 10 ) y1 = Cal1 = meta_ini.Read_Integer ( 'lower_cal-value' , -110 ) y2 = Cal2 = meta_ini.Read_Integer ( 'upper_cal-value' , 110 ) #print 'PPPPPPPPPTTTT', chan, ADV1,ADV2, Cal1,Cal2 y2y1 = 1.0 * ( y2 - y1 ) / ( x2 - x1 ) self.gain.append ( 5 * y2y1 / 2048 ) self.offset.append ( y1 - y2y1 * ( 5 + x1 ) ) Signal_Attr.Calibrate = self.gain [-1], self.offset [-1] #Signal_Attr.DisplayRange = ( 0, 200 ) #v3print ( 'GAIN', self.gain ) #v3print ( 'OFFS', self.offset ) # Set Change flag, should be cleared by the ADC-Brick self.MetaData_Changed = True self.Memo.AppendText ( '\n' ) """