class TestGeneral(unittest.TestCase): def setUp(self): #run before each test self.FSW = VSA().jav_OpenTest(host) self.FSW.Init_Spectral() def tearDown(self): #Run after each test self.assertEqual(self.FSW.jav_Error()[0],'0') self.FSW.jav_Close() ############################################################################### ### <Test> ############################################################################### def test_FSW_Autolevel(self): self.FSW.Set_Autolevel() self.FSW.Set_Autolevel_IFOvld() def test_FSW_ACLR(self): self.FSW.Init_ACLR() self.FSW.Set_ACLR_AdjBW(95e6) self.FSW.Set_ACLR_AdjSpace(100e6) self.FSW.Set_ACLR_CHBW(100e6) self.FSW.Set_ACLR_NumAdj(2) self.FSW.Get_ACLR() def test_FSW_ChannelManagement(self): if self.FSW.connected: getVal = self.FSW.Get_ChannelName() getVal = self.FSW.Get_Channels() self.FSW.Init_IQ() self.FSW.Set_ChannelName('IQ','IQ_Test') self.FSW.Set_ChannelSelect('Spectrum') def test_FSW_Connect(self): self.FSW.jav_IDN() if self.FSW.connected: self.assertEqual(self.FSW.Make,"Rohde&Schwarz") # Valuecompare def test_FSW_Ex_SpectralSettings(self): self.FSW.Set_Freq(1e6) self.FSW.Set_RefLevel(10) self.FSW.Set_ResBW(1e6) self.FSW.Set_VidBW(1e6) self.FSW.Set_Span(100e6) self.FSW.Set_AttnMech(10) self.FSW.Get_IFOvld() self.FSW.Get_ACLR() self.FSW.Set_DisplayUpdate('ON') self.FSW.Set_Ref_Source('INT') def test_FSW_Ex_SpectralSettings_Auto(self): self.FSW.Set_Freq(1e6) self.FSW.Set_ResBW(0) self.FSW.Set_VidBW(0) self.FSW.Set_Span(100e6) self.FSW.Set_Autolevel() self.FSW.Set_AttnAuto() self.FSW.Get_IFOvld() self.FSW.Get_ACLR() self.FSW.Set_DisplayUpdate('ON') def test_FSW_Equalizer(self): self.FSW.Set_EQ_File('Test') self.FSW.Set_EQ_State('ON') self.FSW.Set_EQ_State('OFF') def test_FSW_Freq(self): self.FSW.Set_FreqStart(10e6) self.FSW.Set_FreqStop(100e6) # self.FSW.Set_FreqStep(1e5) self.FSW.Set_Freq(100e6) rdStr = self.FSW.Get_Freq() #var = input("Please enter something: ") if self.FSW.connected: self.assertEqual(100e6,rdStr) # Valuecompare def test_FSW_GetParams(self): nullVal = self.FSW.Get_Params_Amp(1) nullVal = self.FSW.Get_Params_Amp() nullVal = self.FSW.Get_Params_Sweep(1) nullVal = self.FSW.Get_Params_Sweep() nullVal = self.FSW.Get_Params_Trace(1) nullVal = self.FSW.Get_Params_Trace() nullVal = self.FSW.Get_Params_System(1) nullVal = self.FSW.Get_Params_System() nullVal = self.FSW.Get_Params_MkrBand(1) nullVal = self.FSW.Get_Params_MkrBand() nullVal = self.FSW.Get_Params(1,1,1,1,0) def test_FSW_GetScreenshot(self): getVal = self.FSW.Get_Screenshot() def test_FSW_GetTrace(self): getVal = self.FSW.Get_Trace_Data() def test_FSW_Input(self): self.FSW.Set_Freq(1e9) self.FSW.Set_Input('RF') self.FSW.Set_In_YIG('ON') self.FSW.Set_In_YIG('OFF') self.FSW.Set_In_HPFilter('ON') def test_FSW_Marker_dB(self): self.FSW.Set_Mkr_AllOff() self.FSW.Set_Mkr_Peak() self.FSW.Set_Mkr_On(2) self.FSW.Set_Mkr_Next(2) getVal = self.FSW.Get_Mkr_Freq() getVal = self.FSW.Get_Mkr_XY() getVal = self.FSW.Get_Mkr_Y() def test_FSW_Marker_BanddB(self): self.FSW.Set_Mkr_AllOff() self.FSW.Set_Mkr_BandSetRef() self.FSW.Set_Mkr_BandDelta(1e9) self.FSW.Get_Mkr_Band() def test_FSW_Marker_Noise(self): self.FSW.Get_Mkr_Noise() def test_FSW_Marker_Time(self): self.FSW.Set_Span(0) self.FSW.Set_SweepTime(0.010) self.FSW.Set_Mkr_Time(0.001) rdStr = self.FSW.Get_Mkr_TimeDomain() if self.FSW.connected: self.assertEqual(rdStr, 0.001) self.FSW.Set_Span(900e6) self.FSW.Set_SweepTime(0) #Auto Sweeptime def test_FSW_Trigger(self): self.FSW.Set_Trig1_Source('IMM') self.FSW.Set_Trig2_Dir('OUT') self.FSW.Set_Trig2_OutType('DEV') def test_FSW_TraceAvg(self): self.FSW.Set_Trace_Avg('LIN') self.FSW.Set_Trace_AvgCount(10) self.FSW.Set_Trace_Detector('RMS') self.FSW.Set_Trace_Mode('WRIT') self.FSW.Set_Trace_AvgOff() def test_FSW_Sweep(self): self.FSW.Set_SweepPoints(1001) self.FSW.Set_SweepType('AUTO') self.FSW.Set_SweepOpt('AUTO') def test_FSW_Sys_Overload(self): getVal = self.FSW.Get_Ovld_Stat()
AmpParam = VSA.Get_AmpParams(1) TrcParam = VSA.Get_TraceParams(1) SysParam = VSA.Get_System_Params(1) MeasData = 'MkrFreq,MkrBndPwr' OFile.write(f'{LoopParam},TotalTime,{AmpParam},{SwpParam},{TrcParam},{SysParam},{MeasData}') for i in range(Repeat): for SwpTime in swpTimeArry: for rbw in rbwArry: tick = timeit.default_timer() ### <\thing we are timing> VSA.Set_Channel('Spectrum') VSA.Set_ResBW(rbw) VSA.Set_SweepTime(0) VSA.query(':INIT:IMM;*OPC?') # Take Sweep BndMkr = VSA.Get_Mkr_Band() ### <\thing we are timing> tock = timeit.default_timer() LoopParam = f'{i},{rbw:8.0f},{SwpTime:5.3f}' SwpParam = VSA.Get_SweepParams() AmpParam = VSA.Get_AmpParams() TrcParam = VSA.Get_TraceParams() SysParam = VSA.Get_System_Params() TotTime = f'{(tock-tick):2,.6f}' MeasData = f'{BndMkr[0]:.0f},{BndMkr[1]:.3f}' OutStr = f'{LoopParam},{TotTime},{AmpParam},{SwpParam},{TrcParam},{SysParam},{MeasData}' OFile.write (OutStr) ################################################################################ ### Cleanup Automation ################################################################################