The example code below illustrates how to handle events with N5990A Valiframe automation.
These examples suppress all windows dialog prompts and instead redirect messages to the Python prompt

For a more general overview of automation of Agilent Instruments using Python including N5990A ValiFrame see here

First we will make our imports and connections to the ValiFrame environment.

In [9]:
import time
import win32api
import sys
sys.path.append('C:\\Program Files (x86)\\BitifEye\\ValiFrame\\MPhy') # 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 ValiFrameRemote DLL
clr.AddReference("VFBase") # Create a reference from CLR to the VFBase DLL
clr.AddReference("VFSequence") # Create a reference from CLR to the VFSequence DLL
clr.AddReference("VFUserInterface") # Create a reference from CLR to the VFUserInterface DLL

from BitifEye.ValiFrame.ValiFrameRemote import * # Import the entire ValiFrameRemote namespace from the DLL
from BitifEye.ValiFrame.Base import * # Import the entire Base namespace from the DLL
from BitifEye.ValiFrame.Sequence import * # Import the entire Sequence namespace from the DLL
from BitifEye.ValiFrame.UserInterface import * # Import the entire UserInterface namespace from the DLL
from BitifEye.Controls import * # Import the entire Controls namespace from the DLL

Next we need to create functions to handle what happens when Valiframe creates an event.
In the example below we choose to handle events in the following way:

  • **Log Events:** There are many events logged during procedure runs and it is undesirable to print these out or pause the program flow. We will simply ignore them using the **pass** statement.
  • **All Other Events:** We use the **raw_input()** function to pause the program allowing messages to be printed to the interpreter. The user must hit enter to continue the program flow
In [10]:
def my_LogChanged(logentry):
    pass

def my_StatusChanged(source,status):
    print('Status Changed: ' + status)

def my_ProcedureCompleted(procedure,xmlresult):
    raw_input('Procedure Completed: ' + procedure + ' ' + xmlresult)

def my_DialogPopUp(source, args):
    #args.Dialog.ShowDialog()  #Uncomment to show Valiframe dialog box for all cases
    msgbox = args.DialogText

    # Definition for args.DialogType
    #Member name           Value   Description 
    #Form                  0       General Form if the dialog is not one of the other dialog types  
    #MessageBox            1       Standard Windows.Forms.MessageBox.  
    #ConnectionDialog      2       Connection dialog. The dialog which pops up if a connection change is required.  
    #UserInformationDialog 3       User Information Dialog, which contains a text and one button.  
    #UserDecisionDialog    4       User Decision Dialog, which contains one text and 2 buttons.  
    #InfoDialog            5       Info Dialog, which is the same as the UserInformationDialog (obsolete, will be removed in one of the next releases).  

    if args.DialogType == 0:
            raw_input('General Form Dialog: '+str(msgbox))
            #  add actions here.....
            #  args.Dialog.ShowDialog() #Uncomment to show dialog box for this case
    elif args.DialogType == 1:
            raw_input('Standard Windows.Forms.MessageBox: '+str(msgbox))
            #  add actions here.....
            #  args.Dialog.ShowDialog() #Uncomment to show dialog box for this case
    elif args.DialogType == 2:
            raw_input('Connection Dialog: '+str(msgbox))
            #  add actions here.....
            #  args.Dialog.ShowDialog() #Uncomment to show dialog box for this case
    elif args.DialogType == 3:
            raw_input('UserInformationDialog: '+str(msgbox))
            #  add actions here.....
            #  args.Dialog.ShowDialog() #Uncomment to show dialog box for this case
    elif args.DialogType == 4:
            raw_input('UserDecisionDialog: '+str(msgbox))
            #  add actions here.....
            #  args.Dialog.ShowDialog() #Uncomment to show dialog box for this case
    elif args.DialogType == 5:
            raw_input('InfoDialog: '+str(msgbox))
            #  add actions here.....
            #  args.Dialog.ShowDialog() #Uncomment to show dialog box for this case
    else:
            raw_input('Message not handled: '+str(msgbox))

Now we need to create an instance of the ValiFrameRemote object

In [11]:
my_vf_mipi = ValiFrameRemote() # Creates an instance of the ValiFrameRemote class

Next we need to register the event ValiFrame event handlers with the functions created above

In [12]:
#register event handlers
my_vf_mipi.LogChanged += LogChangedEventHandler(my_LogChanged);
my_vf_mipi.StatusChanged += StatusChangedEventHandler(my_StatusChanged);
my_vf_mipi.ProcedureCompleted += ProcedureCompletedEventHandler(my_ProcedureCompleted);
my_vf_mipi.DialogPopUp += DialogShowEventHandler(my_DialogPopUp);

Now we launch the application & load a config

In [13]:
my_vf_mipi.InitApplication("MPhy") # Initialize the application
my_vf_mipi.LoadProject("my_MIPI3_proj.vfp")

Example 1: Synchronous RunProcedure() or RunProcedure() methods

  • The RunProcedure() and RunProcedures() methods are **synchronous** in the sense that the Procedure must complete before control is returned to the Python prompt.
In [6]:
# run procedures synchronously
results = my_vf_mipi.RunProcedure(5500000)
Status Changed: Start
Status Changed: Station Init
Status Changed: Product MPhy Init
Status Changed: Procedure Test 2.1.1 - HS-RX Differential Input Voltage Amplitude Data0 at 1.248 GBit/s Init
Connection Dialog: Connect the outputs of Data0 to the test fixture of the DUT.\par Connect the Trig/Ref Clock outputs of the JBERT to the Ref Clock Input of the DUT.\par Add TTCs of 250 ps to the signal path.
Standard Windows.Forms.MessageBox: Missing Levels Calibration! Do you like to run the test without calibration?
Status Changed: Procedure Test 2.1.1 - HS-RX Differential Input Voltage Amplitude Data0 at 1.248 GBit/s Start Iteration 0
Status Changed: Procedure Test 2.1.1 - HS-RX Differential Input Voltage Amplitude Data0 at 1.248 GBit/s Step 0
Status Changed: Procedure Test 2.1.1 - HS-RX Differential Input Voltage Amplitude Data0 at 1.248 GBit/s Step 1
Status Changed: Procedure Test 2.1.1 - HS-RX Differential Input Voltage Amplitude Data0 at 1.248 GBit/s CleanUp
Status Changed: Procedure Test 2.1.1 - HS-RX Differential Input Voltage Amplitude Data0 at 1.248 GBit/s Complete
Status Changed: Product MPhy Complete
Status Changed: Station Complete
Status Changed: Complete

In the above example the program pauses at each line above waiting for the user to hit enter per our use of raw_input().

Example 2: Asynchronous StartRun() method

  • Since StartRun() returns control to the Python interpreter immediately we can insert a while loop to check the status of the procedures. This will allow the flow to execute just as the synchronous method above did.
In [14]:
# run procedures asynchronously
my_procedure = [5500000]  ## define variable for procedures to execute
my_vf_mipi.SelectProcedures(my_procedure)
my_vf_mipi.StartRun()
while True:
    time.sleep(2)
    status = my_vf_mipi.GetActualStatus()
    if status == 'Complete':
        break
Connection Dialog: Connect the outputs of Data0 to the test fixture of the DUT.\par Connect the Trig/Ref Clock outputs of the JBERT to the Ref Clock Input of the DUT.\par Add TTCs of 250 ps to the signal path.
Standard Windows.Forms.MessageBox: Missing Levels Calibration! Do you like to run the test without calibration?
Status Changed: Start
Status Changed: Station Init
Status Changed: Product MPhy Init
Status Changed: Procedure Test 2.1.1 - HS-RX Differential Input Voltage Amplitude Data0 at 1.248 GBit/s Init
Status Changed: Procedure Test 2.1.1 - HS-RX Differential Input Voltage Amplitude Data0 at 1.248 GBit/s Start Iteration 0
Status Changed: Procedure Test 2.1.1 - HS-RX Differential Input Voltage Amplitude Data0 at 1.248 GBit/s Step 0
Status Changed: Procedure Test 2.1.1 - HS-RX Differential Input Voltage Amplitude Data0 at 1.248 GBit/s Step 1
Status Changed: Procedure Test 2.1.1 - HS-RX Differential Input Voltage Amplitude Data0 at 1.248 GBit/s CleanUp
Status Changed: Procedure Test 2.1.1 - HS-RX Differential Input Voltage Amplitude Data0 at 1.248 GBit/s Complete
Status Changed: Product MPhy Complete
Status Changed: Station Complete
Status Changed: Complete
In [8]:
# Unregister the event handlers
my_vf_mipi.LogChanged -= LogChangedEventHandler(my_LogChanged);
my_vf_mipi.StatusChanged -= StatusChangedEventHandler(my_StatusChanged);
my_vf_mipi.ProcedureCompleted -= ProcedureCompletedEventHandler(my_ProcedureCompleted);
my_vf_mipi.DialogPopUp -= DialogShowEventHandler(my_DialogPopUp);
# close object
my_vf_mipi.Finalize()

Copyright © 2011 Agilent Technologies Inc. All rights reserved.

You have a royalty-free right to use, modify, reproduce and distribute this content (and/or any modified version) in any way you find useful, provided that you agree that Agilent has no warranty, obligations or liability.