Python Examples

This section illustrates using Python 3.9 to control FlexOTO. Even if you don't use Python, these scripts will help you to understand the program requirements. The examples were all tested using the following environment:

  • Windows 10 PC
  • Keysight IO Libraries Suite installed for VISA (Virtual Instrument Software Architecture) library. Go to http://www.keysight.com/find/iosuite.
  • PyVISA which is a Python front end for the VISA library. To learn about PyVISA, go to https://sourceforge.net/projects/pyvisa/ and to pyvisa.readthedocs.org.

In any of the script topics, you'll find the script's code as shown in the following picture. Click the Copy button to copy the code to Windows clipboard and paste the code into your coding application.

Bootup scripts simply build FlexOTO's Hardware Diagram and launch the required Stations. Although vital, building the Hardware Diagram and launching Stations are seldom needed after the first time. You can accomplish this task either with a script, by using FlexOTO's GUI, or by saving and then recalling a FlexOTO Hardware Diagram Setup file.

You will constantly need to run Test Station scripts which configure, modify, and perform all of FlexOTO Test Plans. Don't even think of combining the bootup and test station scripts as this negates many of FlexOTO's benefits!

  • Hardware Bootup (N7734A). Creates Hardware Diagram for two 4 lane DUT fixtures with a Keysight N7734A optical switch.
  • Hardware Bootup (Dicon 600). Creates Hardware Diagram for two 8 lane DUT fixtures with a DiCon GP600 optical switch.
  • Test Station Setup. Creates a Test Station's Test Plan and runs measurements.
  • Optical Path Calibration. Shows the basics of performing an optical calibration of all optical paths in the Hardware Diagram.
  • ID Supported DCA-Ms. A very simple script to query all DCA-M modules recognized by FlexOTO and lists modules that are installed on the Hardware Diagram.
  • Driver for Unrecognized Switch. Demonstrates how to write a switch driver for an unrecognized optical switch in FlexOTO.
  • Driver for Unrecognized Instrument. Demonstrates how to write a instrument driver for an user measurement instrument in FlexOTO.
  • Driver Validate JSON. Demonstrates how validate your JSON string that you include in your switch and instrument drivers. This is a basic confirmation that may catch some errors.

Python Environment

Although uncommon, you may run into a situation where the "byteness" of the Python installation does not match the "byteness" of the Visa library. If this happens, you can force the instantiation of the pyVisa object with the proper Visa version. For example, instead of using:

rm = visa.ResourceManager()
Flex = rm.open_resource('TCPIP0::localhost::hislip0,4880::INSTR')

Pass an argument to include the correct dll:

rm = visa.ResourceManager(r'C:\WINDOWS\system32\visa64.dll')
Flex = rm.open_resource('TCPIP0::localhost::hislip0,4880::INSTR')