Program Fact 4. To Create a Test Program

The following Python script connects to a Station process and creates a simple test program. The script shows that the :TPRogram SCPI subsystem is used to create Test Programs. Notice that the visa address selects hislip1 for Station 1.

In the script's specify_measurements() function, the :TPRogram:SETup:INSTruments command is used to add a user instrument to the Hardware Block. A user measurement instrument is added to FlexOTO by writing an instrument driver. The name of the measurements performed by a user instruments is defined by the instrument driver and not by FlexOTO. When an instrument driver is enabled in a Test Program, it measurements will be ran in a separate Job ID.

Copy
#******************************************************************************
#    MIT License
#    Copyright(c) 2023 Keysight Technologies
#    Permission is hereby granted, free of charge, to any person obtaining a copy
#    of this software and associated documentation files (the "Software"), to deal
#    in the Software without restriction, including without limitation the rights
#    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#    copies of the Software, and to permit persons to whom the Software is
#    furnished to do so, subject to the following conditions:
#    The above copyright notice and this permission notice shall be included in all
#    copies or substantial portions of the Software.
#    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#    SOFTWARE.
#******************************************************************************

import pyvisa as visa  # import VISA library
visa_address = 'TCPIP0::localhost::hislip1,4880::INSTR'  # Address of Station 1


def open_station_connection(address):
    """ Returns a FlexOTO station visa object. """
    rm = visa.ResourceManager()
    connection = rm.open_resource(address)
    connection.timeout = 20000  # Set connection timeout to 20s
    connection.read_termination = '\n'
    connection.write_termination = '\n'
    return connection


def select_lanes_to_measure(station):
    """ Selects all DUT lanes for measurements. """
    station.write(':TPRogram:SETup:FIXTure "DUT Fixture 1", LANE1,LANE2,LANE3,LANE4')


def select_impairment(station):
    """ Selects to include impairments in optical path of selected lanes. """
    station.write(':TPRogram:SETup:IMPairments "Fiber Spool"')


def describe_waveform(station):
    """ Specify waveform symbol rate and pattern length. """
    station.write(':TPRogram:SETup:SRATe 5.3125000E+10')
    station.write(':TPRogram:SETup:PLENgth 65535')


def specify_presets(station):
    """ Select FlexOTO setting presets. FlexOTO configures FlexDCA. """
    station.write(':TPRogram:SETup:CRPReset "IEEE 802.3bs/cd/ck (53 GBd)"')
    station.write(':TPRogram:SETup:TMPReset "IEEE 802.3cd"')
    station.write(':TPRogram:SETup:TEPReset "IEEE 802.3cd"')


def specify_measurements(station):
    """ Selects measurements to perform on all selected lanes. Includes saving waveform data and screen image.
    Adds a measurement made by user instrument. Instrument must have been installed with user driver. """
    measurements = 'TDEQ,CEQ,OOMA,OER,LINearity,LEVels,TTIMe,OVERshoot,UNDershoot,' + \
                   'TPEXcursion,APOWer,PPPower,WDATa,EDIMage'
    station.write(':TPRogram:SETup:MEASurements')  # Clears all measurements selections for next add
    station.write(':TPRogram:SETup:MEASurements ' + measurements)
    station.write(':TPRogram:SETup:EDIMage:UWBackground ON')
    station.write(':TPRogram:SETup:EDIMage:FTYPe JPG')
    station.write(':TPRogram:SETup:INSTruments "Power Meter (#23)"')


def specify_meas_configuration(station):
    """ Specifies measurement units. """
    station.write(':TPRogram:SETup:PUNits WATT')
    station.write(':TPRogram:SETup:ERUNits DECibel')
    station.write(':TPRogram:SETup:LDEFinition RLMA120')
    station.write(':TPRogram:SETup:TRANsition SLOWest')
    station.write(':TPRogram:SETup:THRatio 1.0E-2')


station = open_station_connection(visa_address)
station.write('*CLS')
station.write(':TPRogram:REMove:All')  # removes all current test program lines
select_lanes_to_measure(station)
select_impairment(station)
describe_waveform(station)
specify_presets(station)
specify_measurements(station)
specify_meas_configuration(station)
station.write(':TPRogram:SETup:ADD')
station.write(':SYSTem:GTLocal')
station.close()