from visa import instrument # Import the instrument function from the visa module scope = instrument("TCPIP0::130.30.240.155::inst0::INSTR") # Connect to the scope using the VISA address (see below) scope.ask("*IDN?") # Query the IDN properties of the scope import numpy as np import matplotlib.pyplot as plt # Allow plots to appear inline with the IPython notebook %pylab inline scope.write(":TIM:SCALE 600e-12") scope.write(":DIG") # Capture a single waveform wfm_ascii = scope.ask(":WAV:DATA?") # Get the waveform data wfm_ascii = wfm_ascii[:-1] # Remove a trailing , wfm = [float(s) for s in wfm_ascii.split(',')] # Convert the ascii list of strings to a list of floats sa_rate = float(scope.ask(":ACQ:SRAT:ANAL?")) # Get the scope's sample rate mem_depth = float(scope.ask(":ACQ:POIN?")) # Get the current memory depth t = np.linspace(-mem_depth/sa_rate,mem_depth/sa_rate, len(wfm)) # Calculate the sample times of the waveform plt.plot(t,wfm) # Plot the waveform vs sample times scope.write("disp:data? png") data = scope.read_raw() # Read back the raw binary data as a string hash_idx = data.find('#') # Find the start of the image data len_datalen = int(data[hash_idx+1]) # The 1st character after '#' indicates the length of the length field data_start_idx = hash_idx+len_datalen+2 # The binary image data starts here datalen = int(data[hash_idx+2:hash_idx+len_datalen+2]) # The length of the binary data img_data = data[data_start_idx:data_start_idx+datalen] # Extract just the image binary data from IPython.display import Image # Ipython has some nice tools to display image data. embed = Image(img_data) embed target = open('screenshot.png','wb') target.write(img_data) target.close() # First set up the connection to the RPI DLL via the Python for .NET module import clr # Import the Common Runtime Library Python module clr.AddReference("Agilent.Infiniium.AppFW.Remote") # Create a reference from CLR to the Compliance App DLL from Agilent.Infiniium.AppFW.Remote import * # Import the entire compliance app namespace from the Compliance App DLL scopeIpAddress = "130.30.240.155" scope.write(":SYSTEM:LAUNCH 'N5393C PCIExpress Test App'") # Launch the compliance app using the pyvisa instrument connection remoteObj = RemoteAteUtilities.GetRemoteAte(scopeIpAddress) # Connect to the compliance app remoteApp = IRemoteAte(remoteObj) remoteApp.SetConfig("TestPoint_Transmitter", "1.0") testsinfos = remoteApp.GetCurrentOptions("TestsInfo") for test in testsinfos: print test.ID, test.Name remoteApp.SuppressMessages = True # Suppress the GUI prompts remoteApp.NewProject(True) # Create a new project # Set various Configuration Parameters remoteApp.SetConfig("DevicePCIErev", "PCIE 2.0") remoteApp.SetConfig("TestPoint_AddInCard", "1.0") remoteApp.SetConfig("DataRateOpt", "2.5 GT/s") remoteApp.SetConfig("EnableSignalCheck", "0.0") remoteApp.SelectedTests = [2301, 2310, 2320, 2330, 2340, 2350] # Select the tests to run remoteApp.Run() # Run the selected tests # Set up the project save options & save it to disk saveOptions = SaveProjectOptions() saveOptions.BaseDirectory = "c:\\temp" saveOptions.Name = "Demo" saveOptions.OverwriteExisting = True projectFullPath = remoteApp.SaveProjectCustom(saveOptions) # Set up the project results options and then get the results resultOptions = ResultOptions() resultOptions.TestIds = [2301] resultOptions.IncludeCsvData = True customResults = remoteApp.GetResultsCustom(resultOptions) results = customResults.CsvResults #remoteApp.Exit(True,True) # Exit the application # An example of how to manipulate and display results using the Pandas library import pandas as pd from StringIO import StringIO df_data = pd.read_csv(StringIO(results), sep=',', header=0, quotechar = '"') pd.set_option('display.max_colwidth', 22) df_data from visa import * dca = instrument("TCPIP0::130.30.240.150::inst0::INSTR") dca.ask("*idn?") dca.write(":SYST:LAUN 'N1012A OIF CEI 3_0'") # Launch the compliance app import sys sys.path.append('C:\\Program Files (x86)\\BitifEye\\ValiFrame\\PCI-Express3') # Add the location of the Valiframe dll's to the system path import clr # Import the Common Runtime Library Python module clr.AddReference("ValiFrameRemote") # Create a reference from CLR to the Valiframe App DLL from BitifEye.ValiFrame.ValiFrameRemote import * # Import the entire valiframe app namespace from the DLL my_vf_pcie = ValiFrameRemote() # Creates an instance of the ValiFrameRemote class my_vf_pcie.InitApplication("PciExpress3") # Initialize the application my_vf_pcie.LoadProject("my_pcie3_proj.vfp") #my_vf_pcie.ConfigureApplication() # This method creates a GUI prompt procedureIDs = procedureNames = [] # The variable names must be assigned to something but are overwritten in the next call _, procedureIDs, procedureNames = my_vf_pcie.GetProcedures(procedureIDs, procedureNames) procedureIDs = [int(id) for id in procedureIDs] # Convert to a python list of integers procedureNames = [str(name) for name in procedureNames] # Convert to a python list of strings procs = zip(procedureIDs, procedureNames) # Zip the id's & names together. A dictionary may also be a useful way to store these. for proc_id,proc_name in procs: print proc_id, proc_name my_vf_pcie.DialogPopUp += DialogShowEventHandler(VFDialogInformation()) # Register the Dialog event handler (suppresses all Dialogs) eyewidth_result = str() my_vf_pcie.RunProcedure(320104, eyewidth_result)