class VST(object): """ Rohde & Schwarz Vector Signal Transceiver Object """ def __init__(self): self.Freq = 19e9 self.SMW = '' self.FSW = '' 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_OpenTest(self,SMW_IP,FSW_IP): self.SMW = VSG().jav_OpenTest(SMW_IP) #Create SMW Object self.FSW = VSA().jav_OpenTest(FSW_IP) #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)
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 VSG_SCPI_Write(self): ### :MMEM:DATA:UNPR "NVWFM://var//user//<wave.wv>",#<numSize><NumBytes><I0Q0...IxQx> ### wave.wv : Name of *.wv to be created ### numSize : Number of bytes in <NumBytes> string ### NumBytes: Number of bytes to follow ### Each I (or Q) value is two bytes ### I(2 bytes) + Q(2bytes) = 4 bytes/IQ pair ### NumBytes = NumIQPair * 4 from rssd.VSG.Common import VSG #pylint: disable=C0415,E0401 SMW = VSG().jav_Open('192.168.1.114') #Create SMW Object ### ASCII scpi = ':MMEM:DATA:UNPR "NVWFM://var//user//IQGen.wv",#' # Ascii Cmd iqsize = str(len(self.IData) * 4) # Calculate bytes of IQ data scpi = scpi + str( len(iqsize)) + iqsize # Calculate length of iqsize string ### Binary iqdata = np.vstack((self.IData, self.QData)).reshape( (-1, ), order='F') # Combine I&Q Data bits = np.array(iqdata * 32767, dtype='>i2') # Convert to big-endian 2byte int cmd = bytes(scpi, 'utf-8') + bits.tostring() # Add ASCII + Bin SMW.K2.write_raw(cmd) SMW.write('SOUR1:BB:ARB:WAV:CLOC "/var/user/IQGen.wv",%f' % self.Fs) # Set Fs/Clk Rate SMW.write('BB:ARB:WAV:SEL "/var/user/IQGen.wv"') # Select Arb File print(SMW.query('SYST:ERR?'))
def test_VSG_WLAN_K54(self): from rssd.VSG.WLAN_K54 import VSG #pylint:disable=E0611,E0401 self.SMW = VSG() self.assertEqual(self.SMW.Model,"SMW")
def test_VSG_5GNR(self): from rssd.VSG.NR5G_K144 import VSG #pylint:disable=E0611,E0401 self.SMW = VSG() self.assertEqual(self.SMW.Model,"SMW")
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)
############################################################################### # Bench Settings ############################################################################### FSW_IP = '192.168.1.109' SMW_IP = '192.168.1.114' ############################################################################### ### Overhead: Import and create objects ############################################################################### from rssd.VSA.ADemod_K7 import VSA from rssd.VSG.Common import VSG from rssd.FileIO import FileIO OFile = FileIO().makeFile(__file__) SMW = VSG().jav_Open(SMW_IP,OFile) # Create SMW Object FSW = VSA().jav_Open(FSW_IP,OFile) # Create FSW Object ############################################################################### ### Function Definition ############################################################################### def MeasRelPhase(FSW, SMW, x): count = 0 leaveLoop = 0 while True: SMW.Set_PhaseDelta((x-1)*10) # Initial Phase Shift SMW.delay(Delay/1000) FSW.write('INIT:IMM') # Initiate Sweep SMW.delay(Delay/1000) for i in range(NumMkrs + 2): SMW.delay(Delay/1000)
super(VSG,self).__init__() #Python2/3 self.Model = "SMW" ##################################################################### ### SMW Get Methods ##################################################################### def Get_CDM_State(self): rdStr = self.queryInt(':SOUR1:BB:DM:STAT?') return rdStr ##################################################################### ### SMW Set Functions ##################################################################### def Set_CDM_State(self,State): """ON OFF 1 0 """ if (State == 1) or (State == 'ON'): self.write(':SOUR1:BB:DM:STAT ON') elif (State == 0) or (State == 'OFF'): self.write(':SOUR1:BB:DM:STAT OFF') else: # pragma: no cover print('State not supported, please set ON or OFF') ##################################################################### ### Run if Main ##################################################################### if __name__ == "__main__": # this won't be run when imported SMW = VSG() SMW.jav_Open("192.168.1.114") SMW.jav_Close()
self.write(':SOUR1:BB:NR5G:NODE:CELL0:NSSP 1') def Set_5GNR_TM(self, file): """NR-FR1-TM1_1__FDD_100MHz_30kHz """ self.query(f'SOUR1:BB:NR5G:SETT:TMOD:DL "{file}";*OPC?') def Set_5GNR_TransPrecoding(self, sState): """ SC-FDMA or DFT-S-OFDM 5GNR--> User/BWP --> UL BWP Config --> PUSCH --> TP """ if sState == 'ON': # self.write(':SOUR1:BB:NR5G:SCH:CELL0:SUBF0:USER0:BWP0:ALL0:TPST ON') #4.30SP2? self.write(':SOUR1:BB:NR5G:UBWP:USER0:CELL0:UL:BWP0:PUSC:TPST ON') #4.50 else: # self.write(':SOUR1:BB:NR5G:SCH:CELL0:SUBF0:USER0:BWP0:ALL0:TPST OFF') #4.30SP2? self.write(':SOUR1:BB:NR5G:UBWP:USER0:CELL0:UL:BWP0:PUSC:TPST OFF') #4.50 def Set_5GNR_savesetting(self, sName): self.query(f':SOUR:BB:NR5G:SETT:STOR "/var/user/{sName}";*OPC?') # self.query(f':SOUR:BB:NR5G:WAV:CRE "/var/user/{sName}";*OPC?') # self.delay(10) ##################################################################### ### Run if Main ##################################################################### if __name__ == "__main__": # this won't be run when imported SMW = VSG() SMW.jav_Open("192.168.1.114") SMW.Set_5GNR_savesetting('asdfasdf') SMW.jav_Close()
def jav_OpenTest(self,SMW_IP,FSW_IP): self.SMW = VSG().jav_OpenTest(SMW_IP) #Create SMW Object self.FSW = VSA().jav_OpenTest(FSW_IP) #Create FSW Object return self
############################################################################### # Bench Settings ############################################################################### FSW_IP = '192.168.1.109' SMW_IP = '192.168.1.114' ############################################################################### ### Overhead: Import and create objects ############################################################################### from rssd.VSA.ADemod_K7 import VSA from rssd.VSG.Common import VSG from rssd.FileIO import FileIO OFile = FileIO().makeFile(__file__) SMW = VSG().jav_Open(SMW_IP, OFile) # Create SMW Object FSW = VSA().jav_Open(FSW_IP, OFile) # Create FSW Object ############################################################################### ### Function Definition ############################################################################### def MeasRelPhase(FSW): leaveLoop = 0 for i in range(10): FSW.write('INIT:IMM') # Initiate Sweep mkrArry = [] for mkr in range(NumMkrs): # Read Markers mkrArry.append(FSW.Get_Mkr_Y(mkr + 1))
############################################################################### ### Rohde & Schwarz Automation for demonstration use. ############################################################################### SMW_IP = '192.168.1.114' SMW_IP = '10.0.0.10' FreqArry = [24e9, 28e9, 39e9] PwrArry = range(-50, 0, 2) ############################################################################### from rssd.VSG.Common import VSG from rssd.FileIO import FileIO FIL = FileIO().makeFile(__file__) SMW = VSG().jav_Open(SMW_IP, FIL) #Create SMW Object ############################################################################### ### Code Start ############################################################################### SMW.Set_IQMod('OFF') for frq in FreqArry: SMW.Set_Freq(frq) # SMW.Set_NRP_Freq(frq) for pwr in PwrArry: SMW.Set_RFPwr(pwr) SMW.Set_RFState(1) rdStr = SMW.Get_NRPPower() FIL.write(f'{frq},{pwr},{rdStr}')
### Rohde & Schwarz Automation for demonstration use. ### Title : Raw Binary to SMW ### Author : mclim ### Date : 2019.11.26 ############################################################################### ### User Entry ############################################################################### SMW_IP = '192.168.1.114' # SMW_IP = '10.0.0.7' ############################################################################### ### Code Overhead: Import and create objects ############################################################################### import numpy as np from rssd.VSG.Common import VSG SMW = VSG().jav_Open(SMW_IP) #Create SMW Object ############################################################################### ### Code Start ############################################################################### ### :MMEM:DATA:UNPR "NVWFM://var//user//<wave.wv>",#<numSize><NumBytes><I0Q0...IxQx> ### wave.wv : Name of *.wv to be created ### numSize : Number of bytes in <NumBytes> string ### NumBytes: Number of bytes to follow ### Each I (or Q) value is two bytes ### I(2 bytes) + Q(2bytes) = 4 bytes/IQ pair ### NumBytes = NumIQPair * 4 ### IData = [0.1, 0.2, 0.3] QData = [0.4, 0.5, 0.6]
def setUp(self): #run before each test self.SMW = VSG().jav_OpenTest(host)
class TestGeneral(unittest.TestCase): def setUp(self): #run before each test self.SMW = VSG().jav_OpenTest(host) def tearDown(self): #Run after each test self.assertEqual(self.SMW.jav_Error()[0], '0') self.SMW.jav_Close() ############################################################################### ### <Test> ############################################################################### def test_SMW_ALC(self): setVal = 'ON' self.SMW.Set_ALC_RFDriveAmp(setVal) def test_SMW_Arb_Freq(self): setVal = 10e6 self.SMW.Set_ArbClockFreq(setVal) getVal = self.SMW.Get_ArbClockFreq() if self.SMW.connected: self.assertEqual(setVal, getVal) def test_SMW_Arb_State(self): setVal = '/var/user/UCS2010/GSM.wv' self.SMW.Set_ArbWv(setVal) self.SMW.Set_ArbState(1) self.SMW.Set_ArbState(0) getVal = self.SMW.Get_ArbName() # nulVal = self.SMW.Get_ArbInfo() nulVal = self.SMW.Get_PowerInfo() if self.SMW.connected: self.assertTrue(getVal.find(setVal) > -1) def test_SMW_BB_State(self): self.SMW.Set_BBState(1) self.SMW.Set_BBState(0) def test_SMW_Connect(self): if self.SMW.connected: self.assertEqual(self.SMW.Make, "Rohde&Schwarz") def test_SMW_CrestFactor(self): getVal = self.SMW.Get_CrestFactor() def test_SMW_OS(self): self.SMW.Set_OS_Dir('UCS2010') getVal = self.SMW.Get_OS_Dir() getVal = self.SMW.Get_OS_FileList() def test_SMW_Init_Wideband(self): self.SMW.Init_Wideband() def test_SMW_IQMod(self): self.SMW.Set_IQMod(1) self.SMW.Set_IQMod(0) self.SMW.Set_IQMod('OFF') self.SMW.Set_IQMod('ON') def test_SMW_Freq(self): setVal = 2e6 self.SMW.Set_Freq(setVal) getVal = self.SMW.Get_Freq() if self.SMW.connected: self.assertEqual(setVal, getVal) def test_SMW_ListMode(self): self.SMW.Set_RFState(1) self.SMW.Set_ListMode_File('testListMode.lsw') self.SMW.Set_ListMode_File('testListMode') self.SMW.Set_ListMode('LIST') self.SMW.Set_ListMode_TrigSource('SING') self.SMW.Set_ListMode_Dwell(0.01) self.SMW.Set_ListMode_RMode('LIVE') # self.SMW.Set_ListMode_TrigExecute() # self.SMW.Set_ListMode_TrigWait() getVal = self.SMW.Get_ListMode_IndexCurr() getVal = self.SMW.Get_ListMode_IndexStop() self.SMW.Set_ListMode('CW') def test_SMW_ListMode_TrigSource(self): self.SMW.Set_ListMode_TrigSource('SING') self.SMW.Set_ListMode_TrigSource('AUTO') self.SMW.Set_ListMode_TrigSource('STEP') self.SMW.Set_ListMode_TrigSource('ESTEP') self.SMW.Set_ListMode_TrigSource('ESING') def test_SMW_PhaseDelta(self): setVal = -10 self.SMW.Set_PhaseDelta(setVal) def test_SMW_Pwr(self): setVal = -10 self.SMW.Set_RFPwr(setVal) getVal = self.SMW.Get_PowerRMS() self.assertEqual(self.SMW.jav_Error()[0], '0') if self.SMW.connected: self.assertEqual(setVal, getVal) def test_SMW_SysConfigAll(self): getVal = self.SMW.Get_SysC_All()
########################################################## ### Code Overhead: Import and create objects ########################################################## from datetime import datetime #pylint: disable=E0611,E0401 from rssd.FileIO import FileIO #pylint: disable=E0611,E0401 from rssd.VSG.Common import VSG #pylint: disable=E0611,E0401 from rssd.PNA.Common import PNA #pylint: disable=E0611,E0401 import time OFile = FileIO().makeFile(__file__) ########################################################## ### Code Start ########################################################## SMW = VSG().jav_Open(SMW_IP, OFile) FSWP = PNA().jav_Open(FSWP_IP, OFile) ########################################################## ### Measure Time ########################################################## Header = 'Iter,SetFreq,SMFPwr,FSWPFreq,FSWPPwr,LockStatus,PN1,PN2,PN3,PN4' OFile.write(Header) FSWP.Set_SweepCont(0) SMW.Set_RFPwr(-50) SMW.Set_RFState(1) for i in range(numMeas): #Loop: Measurements for freq in FreqArry: #Loop: Frequency SMW.Set_Freq(freq)
def Set_5GNR_TransPrecoding(self, sState): """ SC-FDMA or DFT-S-OFDM 5GNR--> User/BWP --> UL BWP Config --> PUSCH --> TP """ if sState == 'ON': # self.write(f':SOUR1:BB:NR5G:SCH:CELL{self.cc}:SUBF{self.subF}:USER0:BWP0:ALL0:TPST ON') #4.30SP2? self.write(f':SOUR1:BB:NR5G:UBWP:USER0:CELL{self.cc}:UL:BWP0:PUSC:TPST ON') #4.50 else: # self.write(f':SOUR1:BB:NR5G:SCH:CELL{self.cc}:SUBF{self.subF}:USER0:BWP0:ALL0:TPST OFF') #4.30SP2? self.write(f':SOUR1:BB:NR5G:UBWP:USER0:CELL{self.cc}:UL:BWP0:PUSC:TPST OFF') #4.50 def Set_5GNR_Setting_Load(self, sName): self.query(f':SOUR:BB:NR5G:SETT:LOAD "/var/user/{sName}";*OPC?') def Set_5GNR_savesetting(self, sName): self.query(f':SOUR:BB:NR5G:SETT:STOR "/var/user/{sName}";*OPC?') def Set_5GNR_saveAllocation(self, sName): self.query(f'SOUR1:BB:NR5G:ANAL:CONT "/var/user/{sName}";*OPC?') ##################################################################### ### Run if Main ##################################################################### if __name__ == "__main__": # this won't be run when imported SMW = VSG() SMW.jav_Open("192.168.1.114") SMW.cc = 1 print(SMW.Get_5GNR_CC_Freq()) SMW.jav_Close()
FreqStart = int(51e9) FreqStop = int(75e9) FreqStep = int(1e9) fSpan = 100e6 SWM_Out = -20 Mixer = 1 ########################################################## ### Code Start ########################################################## from rssd.VSG.Common import VSG from rssd.FileIO import FileIO f = FileIO() DataFile = f.Init(OutFile) SMW = VSG() SMW.jav_Open(SMW_IP, f.sFName) ########################################################## ### Instrument Settings ########################################################## SMW.Set_RFPwr(SWM_Out) #Output Power SMW.Set_RFState('ON') #Turn RF Output on f.write(SMW.query('FREQ:MULT:EXT:TYPE?')) #SMZ # f.write(SMW.query('FREQ:MULT:EXT:SNUM?')) #Serial Num f.write(SMW.query('FREQ:MULT:EXT:LOAD:VERS?')) f.write(SMW.query('FREQ:MULT:EXT:FMAX?')) f.write(SMW.query('FREQ:MULT:EXT:FMIN?')) f.write(SMW.query('FREQ:MULT:EXT:REV?')) #Revision
########################################################## # Bench Settings ########################################################## FSW_IP = '192.168.1.109' SMW_IP = '192.168.1.114' ########################################################## ### Code Overhead: Import and create objects ########################################################## from rssd.VSA.ADemod_K7 import VSA from rssd.VSG.Common import VSG from rssd.FileIO import FileIO import time OFile = FileIO().makeFile(__file__) SMW = VSG().jav_Open(SMW_IP, OFile) #Create SMW Object FSW = VSA().jav_Open(FSW_IP, OFile) #Create FSW Object ########################################################## ### Function Definition ########################################################## def MeasRelPhase(FSW, SMW, x): count = 0 leaveLoop = 0 while True: SMW.Set_PhaseDelta((x - 1) * 10) #Initial Phase Shift time.sleep(Delay / 1000) #Wait for phase settling FSW.write('INIT:IMM') #Initiate Sweep time.sleep(Delay / 1000) #Wait for i in range(NumMkrs + 2):
def test_VSG_CDM(self): from rssd.VSG.CustomDigMod import VSG #pylint:disable=E0611,E0401 self.SMW = VSG() self.assertEqual(self.SMW.Model,"SMW")
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 test_VSG_Fading(self): from rssd.VSG.Fading import VSG #pylint:disable=E0611,E0401 self.SMW = VSG() self.assertEqual(self.SMW.Model,"SMW")
##################################################################### ### Fading Set Methods ##################################################################### def Set_Fade_State(self, State): """ON OFF 1 0 """ self.K2.timeout = 20000 if State in (1, 'ON'): self.write(':SCON:MODE ADV') self.write(':SCON:APPL;*OPC?') self.delay(1) self.jav_OPC_Wait(f'ENT{self.entity}:SOUR1:FSIM:STAT 1') elif State in (0, 'OFF'): # self.write(':SCON:MODE STAN') # self.write(':SCON:APPL') self.jav_OPC_Wait(f'ENT{self.entity}:SOUR1:FSIM:STAT 0') else: print('State not supported, please set ON or OFF') self.K2.timeout = 5000 ##################################################################### ### Run if Main ##################################################################### if __name__ == "__main__": # this won't be run when imported SMW = VSG() SMW.jav_Open("192.168.1.115") SMW.entity = 2 SMW.Set_Fade_State(1) SMW.jav_Close()
def test_VSG_LTE_K55(self): from rssd.VSG.LTE_K55 import VSG #pylint:disable=E0611,E0401 self.SMW = VSG() self.assertEqual(self.SMW.Model,"SMW")
def Set_WLAN_Standard(self, sStd): #WLAN-->Frame Blocks-->TxMode sStd.upper() if sStd == 'B': self.write(f':SOUR:BB:WLNN:FBL1:PMOD LEG') #Set Physical Mode self.write(f':SOUR:BB:WLNN:FBL1:TMOD CCK') elif sStd == 'G' or sStd == 'A': self.write(f':SOUR:BB:WLNN:FBL1:PMOD LEG') #Set Physical Mode self.write(f':SOUR:BB:WLNN:FBL1:TMOD L{self.WLAN_ChBW}') elif sStd == 'N': self.write(f':SOUR:BB:WLNN:FBL1:PMOD MIX') #Set Physical Mode self.write(f':SOUR:BB:WLNN:FBL1:TMOD HT{self.WLAN_ChBW}') elif sStd == 'AC': self.write(f':SOUR:BB:WLNN:FBL1:PMOD MIX') #Set Physical Mode self.write(f':SOUR:BB:WLNN:FBL1:TMOD V{self.WLAN_ChBW}') elif sStd == 'AX': self.write(f':SOUR:BB:WLNN:FBL1:PMOD MIX') #Set Physical Mode self.write(f':SOUR:BB:WLNN:FBL1:TMOD HE{self.WLAN_ChBW}') else: print(f'Set_WLAN_Standard: {sStd} not supported') ##################################################################### ### Run if Main ##################################################################### if __name__ == "__main__": ### this won't be run when imported WLAN = VSG() WLAN.jav_Open("192.168.1.114") print(WLAN.Get_WLAN_Standard()) WLAN.jav_Close()
########################################################## ### 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.VSG.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