class TestGeneral(unittest.TestCase): def setUp(self): #run before each test self.SMW = VSG() try: self.SMW.jav_Open(host, prnt=0) self.SMW.jav_Reset() self.SMW.jav_ClrErr() self.SMW.dLastErr = "" except: self.assertTrue(1) def tearDown(self): #Run after each test self.SMW.jav_Close() ############################################################################### ### <Test> ############################################################################### def test_SMW_Connect(self): self.SMW.jav_IDN(prnt=0) self.assertEqual(self.SMW.Make, "Rohde&Schwarz") def test_SMW_Freq(self): frq = 1e6 self.SMW.Set_Freq(frq) rdFrq = self.SMW.Get_Freq() self.assertEqual(self.SMW.jav_Error()[0], '0') self.assertEqual(frq, rdFrq) def test_SMW_Pwr(self): pwr = -10 self.SMW.Set_RFPwr(pwr) rdPwr = self.SMW.Get_PowerRMS() self.assertEqual(self.SMW.jav_Error()[0], '0') self.assertEqual(pwr, rdPwr)
class TestGeneral(unittest.TestCase): def setUp(self): #run before each test self.SMW = VSG() try: self.SMW.jav_Open(host) self.SMW.jav_Reset() self.SMW.jav_ClrErr() self.SMW.dLastErr = "" except: self.assertTrue(1) def test_SMW_Connect(self): self.assertEqual(self.SMW.jav_Error()[0],'0') def test_SMW_Common(self): self.SMW.Set_Freq(1e6) self.SMW.Set_Power(10) self.SMW.Get_Freq() self.SMW.Get_Level() self.assertEqual(self.SMW.jav_Error()[0],'0')
class VST(object): def __init__(self): self.Freq = 19e9 def jav_Open(self, SMW_IP, FSW_IP, OFile=''): self.SMW = VSG().jav_Open(SMW_IP, OFile) #Create SMW Object self.FSW = VSA().jav_Open(FSW_IP, OFile) #Create FSW Object return self def jav_Close(self): self.SMW.jav_Close() self.FSW.jav_Close() def jav_ClrErr(self): self.SMW.jav_ClrErr() self.FSW.jav_ClrErr() def Set_Freq(self, freq): self.SMW.Set_Freq(freq) self.FSW.Set_Freq(freq)
class VST(object): """ Rohde & Schwarz Vector Signal Transceiver Object """ def __init__(self): self.Freq = 19e9 def jav_Open(self,SMW_IP,FSW_IP,OFile=''): self.SMW = VSG().jav_Open(SMW_IP,OFile) #Create SMW Object self.FSW = VSA().jav_Open(FSW_IP,OFile) #Create FSW Object return self def jav_Close(self): self.SMW.jav_Close() self.FSW.jav_Close() def jav_ClrErr(self): self.SMW.jav_ClrErr() self.FSW.jav_ClrErr() def Set_Freq(self,freq): self.SMW.Set_Freq(freq) self.FSW.Set_Freq(freq)
VSE.Set_K96_OFDMSymbols(14) FSW.jav_Reset() FSW.Init_IQ() #FSW IQ Channel FSW.Set_IQ_SamplingRate(Fs) FSW.Set_SweepTime(MeasTim) SMW.Set_RFState("ON") ########################################################## ### Make Measurement ########################################################## for Freq in FreqArry: ### Set Frequency SMW.Set_Freq(Freq) FSW.Set_Freq(Freq + 50e6) VSE.Set_Freq(0) for Pwr in PwrArry: ### Set Power SMW.Set_RFPwr(Pwr) #FSW.Set_Autolevel_IFOvld() #Maximize Dynamic Range ### Measure EVM FSW.Get_IQ_Data(IQFile) #Save IQ Data to file VSE.Set_InitImm() #Update VSE EVM_Meas = VSE.Get_EVM_Params() #Attn; RefLvl; Pwr; EVM f.write(EVM_Meas) VSE.jav_ClrErr() #Clear Errors #end PwrLoop
########################################################## ### Rohde & Schwarz Automation for demonstration use. ### ### Purpose: Load arb file on SMW ### Author: mclim ### Date: 2018.05.17 ########################################################## ### User Entry ########################################################## host = '192.168.1.114' #Get local machine name ########################################################## ### Code Start ########################################################## from rssd.SMW_Common import VSG SMW = VSG().jav_Open(host) #SMW.jav_logSCPI() #Log SCPI commands SMW.Set_Freq(10e9) #Set 10GHz SMW.Set_RFPwr(-30) #Output -30dBm SMW.Set_RFState('ON') #Turn RF Output on SMW.Set_ArbWv('composer.wv') #Load file SMW.Set_ArbState('ON') #Turn on Arb & IQ Mod SMW.jav_ClrErr() #Clear Errors
OFileXML = FileIO().makeFile(__file__+'xml') SMW = VSG().jav_Open(SMW_IP,OFileCSV) #Create SMW Object FSW = VSA().jav_Open(FSW_IP,OFileCSV) #Create FSW Object ########################################################## ### Instrument Settings ########################################################## SMW.Set_RFPwr(SWM_Out) #Output Power SMW.Set_RFState('ON') #Turn RF Output on FSW.Set_SweepCont(0) #FSW.Set_SweepTime(200e-3) FSW.Set_Span(fSpan) if Mixer: #Mixer FSW.write('SENS:MIX:STAT ON') FSW.write('SENS:MIX:HARM:BAND V') for freq in range(FreqStart,FreqStop,FreqStep): SMW.Set_Freq(freq) time.sleep(0.01) FSW.Set_Freq(freq) FSW.Set_InitImm() FSW.Set_Mkr_Peak() Mkr = FSW.Get_Mkr_XY() OFileCSV.write(f'{freq},{Mkr[0]},{Mkr[1]}') OFileXML.write(f' <Point x="{Mkr[0]}" y="{Mkr[1]}"/>') SMW.jav_ClrErr() #Clear Errors FSW.jav_ClrErr() #Clear Errors
if leaveLoop: break return AvgAvg ########################################################## ### Code Start ########################################################## sDate = time.strftime("%y%m%d-%H%M%S") OFile.write('DemodBW,Phase,Mkr1,Mkr2,Mkr3,Mkr4,Meas,MeasAvg\n') FSW.write('SYST:DISP:UPD ON') #********************************* #*** SMW-Setup #********************************* SMW.Set_Freq(28e9) SMW.Set_BBState(0) #Arb Off SMW.Set_IQMod(0) #IQ Mod Off SMW.write(':SOUR1:ROSC:SOUR EXT') #ExtReference SMW.write(':SOUR1:ROSC:EXT:FREQ 10MHZ') SMW.write(':SOUR1:ROSC:EXT:SBAN WIDE' ) #SMW WIDE(Vary less)|NARR(varys more) bandwidth SMW.Set_RFState('ON') #********************************* #*** FSW-Analog Demodulation #********************************* FSW.Set_Channel('ADEM') FSW.write('LAY:REPL:WIND "1","XTIM:PM"') #PM Demod window FSW.Set_SweepCont('OFF') #Single sweep FSW.write('ROSC:SOUR INT') #Reference