lta.connect() # connect to the Labview Host lta.s.settimeout(30) #---------------------Script code goes here------------------------------------ #------------------- Create output files ------------------------------------- Settings = lta.__get__('settings') out_dir = Settings['Directories']['RootDir']+'\\'+Settings['Directories']['OutDir']+'\\' output_python_path = ( out_dir + dfile + '.pkl') output_matlab_path = ( out_dir + dfile + '.mat') output_python = open(output_python_path, 'wb') output_matlab = open(output_matlab_path, 'wb') AppOut_arr = np.zeros((len(NoiseVariances)*iterations,), dtype=np.object) #----------------------- Get App Config ------------------------------------- AppCfg = lta.__get__('app.config') AppCfg['ModelValidationConfig']['NoiseVariance']=NoiseVariances[0] lta.__set__('app.config',AppCfg) #----------------------- Set Impairments ------------------------------------ # EventConfig = lta.__get__('bus1.event.config') # EventConfig['clEvtConfig']['bPosSeq']= bool(0) # lta.__set__('bus1.event.config',EventConfig) #--------------------- Set PMU impairment ------------------------------------ impair_string= 'C37BehaviourPlugin' ImpairPath=lta.__get__('bus1.PMUImpairment.PathToPlugin') ImpairPluginPath = os.path.split(ImpairPath['Path']) ImpairPluginPath = os.path.split(ImpairPluginPath[0]) ImpairPluginPath = os.path.join(ImpairPluginPath[0],impair_string) ImpairPluginPath = os.path.join(ImpairPluginPath,impair_string+'.ini') ImpairPath['Path']=ImpairPluginPath lta.__set__('bus1.PMUImpairment.PathToPlugin',ImpairPath) bus_impair_string='bus1.pmuimpairment.config' PMUImpCfg=lta.__get__(bus_impair_string)
# -*- coding: utf-8 -*- from lta import Lta import sys from lta_err import Lta_Error #------------------- following code must be in all scripts-------------------- lta = Lta("127.0.0.1", 60100) # all scripts must create an Lta object try: lta.connect() # connect to the Labview Host #---------------------Script code goes here------------------------------------ EvtCfg = lta.__get__('bus1.event.config') EvtCfg['clEvtConfig']['Fs'] = 60 lta.__set__('bus1.event.config', EvtCfg) lta.__run__() EvtCfg = lta.__get__('bus1.event.config') EvtCfg['clEvtConfig']['Fs'] = 30 lta.__set__('bus1.event.config', EvtCfg) lta.__run__() EvtCfg = lta.__get__('bus1.event.config') EvtCfg['clEvtConfig']['Fs'] = 20 lta.__set__('bus1.event.config', EvtCfg) lta.__run__() #------------------all scripts should send their errors to labview------------ except Exception as ex: err = Lta_Error(ex, sys.exc_info()) #format a labview error lta.send_error(err, 3, 'Abort') #send the error to labview for display lta.close() print err
# while (sleepTime > 0): # print sleepTime # time.sleep(1) # sleepTime = sleepTime-1 print 'freq:', freq, 'hz' #,'delay:',dlyTime,'us' time.sleep(2.5) fcnParams = lta.__get__( 'FGen.FunctionParams') # get the array of signal parameters for param in fcnParams[None]: param[frequency] = float(freq) lta.__set__('FGen.FunctionParams', fcnParams) ClkProperties = lta.__get__('Sync.ClockProperties') for element in ClkProperties[None]: # For Equivalent Time Sampling, move the digitizer trigger # if element['clClocks']['Name'] == "Pgm_PPS": # element['clClocks']['Delay'] = float(dlyTime) #Set initial Pgm_Pps delay time # set the PRS frequency: if element['clClocks']['Name'] == 'PRS': element['clClocks']['Frequency'] = float(freq) lta.__set__('Sync.ClockProperties', ClkProperties) timeout = 5
EventParams=lta.__get__('bus1.event.params') #----------------------- Get App Config ------------------------------------- AppCfg = lta.__get__('app.config') pmus_loc=AppCfg['LSEConfig']['PMULocations'] num_pmus=len(pmus_loc) #----------------------- Set Impairments ------------------------------------ for i in range(num_pmus): #--------------------- Set PMU impairment ------------------------------------ impair_string= 'C37PmuImpairPlugin' ImpairPath=lta.__get__('bus'+ str(i+1) +'.PMUImpairment.PathToPlugin') ImpairPluginPath = os.path.split(ImpairPath['Path']) ImpairPluginPath = os.path.split(ImpairPluginPath[0]) ImpairPluginPath = os.path.join(ImpairPluginPath[0],impair_string) ImpairPluginPath = os.path.join(ImpairPluginPath,impair_string+'.ini') ImpairPath['Path']=ImpairPluginPath lta.__set__('bus'+ str(i+1) +'.PMUImpairment.PathToPlugin',ImpairPath) bus_impair_string='bus'+`i+1`+'.pmuimpairment.config' PMUImpCfg=lta.__get__(bus_impair_string) PMUImpCfg['clImpairConfig']['FilterType'] = PMUFilterType lta.__set__(bus_impair_string,PMUImpCfg) #-------------------- Perform several runs ----------------------------------- for i in range(iterations): string_msg='iter: '+ str(i) print string_msg lta.__run__() AppOutput.append(lta.__get__('app.output')) AppOut_arr[i] = AppOutput[i] #---------------------- Save the results ------------------------------------- pickle.dump({'AppOutput': AppOut_arr,'EventTime': EventTime_arr,'EventParams': EventParams}, output_python) savemat(output_matlab, mdict={'AppOutput': AppOut_arr,'EventTime': EventTime_arr,'EventParams': EventParams}) output_python.close()
#------------------- following code must be in all scripts-------------------- lta = Lta("127.0.0.1", 60100) # all scripts must create an Lta object try: lta.connect() # connect to the Labview Host #---------------------Script code goes here------------------------------------ UsrTimeout = lta.s.gettimeout() freq_list = [5000, 2000, 1000, 500, 200, 100, 80, 60, 50, 40] for freq in freq_list: dlyTime = -.150 AnalysisConfig = lta.__get__('Analysis.Config') AnalysisConfig[None]['F0'] = np.uint32(freq) lta.__set__('Analysis.Config', AnalysisConfig) # after setting the clock properties, the Sync module becomes unlocked. Wait until it re-locks while (dlyTime <= .175): ClkProperties = lta.__get__('Sync.ClockProperties') for element in ClkProperties[None]: if element['clClocks']['Name'] == "Pgm_PPS": element['clClocks']['Frequency'] = float( freq) # Set Pgm_Pps Freuency element['clClocks']['Delay'] = float( dlyTime) #Set initial Pgm_Pps delay time lta.__set__('Sync.ClockProperties', ClkProperties) timeout = 5
#----------------------- Set Impairments ------------------------------------ for i in range(num_pmus): # EventConfig = lta.__get__('bus1.event.config') # EventConfig['clEvtConfig']['bPosSeq']= bool(0) # lta.__set__('bus1.event.config',EventConfig) #--------------------- Set PMU impairment ------------------------------------ impair_string = 'C37BehaviourPlugin' ImpairPath = lta.__get__('bus' + str(i + 1) + '.PMUImpairment.PathToPlugin') ImpairPluginPath = os.path.split(ImpairPath['Path']) ImpairPluginPath = os.path.split(ImpairPluginPath[0]) ImpairPluginPath = os.path.join(ImpairPluginPath[0], impair_string) ImpairPluginPath = os.path.join(ImpairPluginPath, impair_string + '.ini') ImpairPath['Path'] = ImpairPluginPath lta.__set__('bus' + str(i + 1) + '.PMUImpairment.PathToPlugin', ImpairPath) bus_impair_string = 'bus' + ` i + 1 ` + '.pmuimpairment.config' PMUImpCfg = lta.__get__(bus_impair_string) PMUImpCfg['clImpairConfig']['FilterType'] = 'Blackman' lta.__set__(bus_impair_string, PMUImpCfg) #------------------- Get events params --------------------------------------- EventInput = lta.__get__('bus1.event.reports') data_size = len(EventInput['clEvtReportArray']) EventTime_arr = np.zeros((data_size, ), dtype=np.object) for h in range(data_size): EventTime_arr[h] = EventInput['clEvtReportArray'][h]['clReportArg'][ 'Timestamp'] EventParams = lta.__get__('bus1.event.params') #-------------------- Perform several runs ----------------------------------- j = 0 #print (num_pmus-1)*iterations
freq_list = [5000] for freq in freq_list: dlyTime = -2.0 # microseconds while (dlyTime < 2.0): print dlyTime ClkProperties=lta.__get__('Sync.ClockProperties') for element in ClkProperties[None]: if element['clClocks']['Name'] == "Digi_Trigger": #element['clClocks']['Frequency'] = float(freq) # Set Pgm_Pps Freuency element['clClocks']['Delay'] = float(dlyTime) #Set initial Pgm_Pps delay time lta.__set__('Sync.ClockProperties',ClkProperties) timeout = 5 while(timeout > 0): time.sleep(10) locked = lta.__get__('Sync.LockStatus') print dlyTime if locked[None] == True: lta.s.settimeout(90) lta.__run__() lta.s.settimeout(UsrTimeout) break timeout = timeout - 1 if locked[None] != True: raise Exception ('Sync module is not locked')
# -*- coding: utf-8 -*- from lta import Lta import sys from lta_err import Lta_Error #------------------- following code must be in all scripts-------------------- lta = Lta("127.0.0.1", 60100) # all scripts must create an Lta object try: lta.connect() # connect to the Labview Host #---------------------Script code goes here------------------------------------ #lta.__run__() Param = lta.__get__('Analysis.Duration') print Param Param[None] = float(1.0) lta.__set__('Analysis.Duration', Param) #lta.__set__('test.wfrm.params',WfrmParam) #lta.__run__() #------------------all scripts should send their errors to labview------------ except Exception as ex: err = Lta_Error(ex, sys.exc_info()) #format a labview error lta.send_error(err, 3, 'Abort') #send the error to labview for display lta.close() print err
# -*- coding: utf-8 -*- from lta import Lta import sys import numpy as np from lta_err import Lta_Error #------------------- following code myst be in all scripts-------------------- lta = Lta("127.0.0.1", 60100) # all scripts must create an Lta object lta.connect() # connect to the Labview Host #----------------------------------------------------------------------------- try: #--------------- here is where your code goes----------------------------- CommsData = lta.__get__('TestCluster') CommsData['TestCluster']['EmbeddedCl_2']['TrueOrFalse'] = not CommsData[ 'TestCluster']['EmbeddedCl_2']['TrueOrFalse'] CommsData['TestCluster']['EmbeddedCl_1']['NumDbl'] += np.float32(1) CommsData['TestCluster']['DoeADeer'][0][0] = 'WRITTEN' lta.__set__('TestCluster', CommsData) lta.close() #------------------------------------------------------------------------- #------------------all scripts should send their errors to labview------------ except Exception as ex: err = Lta_Error(ex, sys.exc_info()) #format a labview error lta.send_error(err, 3, 'Abort') #send the error to labview for display lta.close()