Python Example 2. Show Input Variables

Meas. mode:
Scope
Eye
TDR
Package License:
L-RND
L-SNT

This Python example of a user measurement script simply shows the input variables that have been passed from FlexDCA into Python. It illustrates this action and may be useful for troubleshooting. The variables are printed to FlexDCA's Show dialog and to the text file c:/Temp/Show User Measurement Input Vars.txt. After you've been successful with this example, try the Example 3. Creating a Pre-Emphasis User Measurement script.

Procedure

  1. Copy the following XML listing into a text editor. Name the file ShowMeasurementInputVars.xml and save it in FlexDCA's user measurements folder (\Documents\Keysight\FlexDCA\User Measurements). Later, when this XML file is imported into the User Measurement Setup dialog, it identifies the ShowMeasurementInputVars.py script, populates the dialog and creates the user measurement button.
  2. Copy

    ShowInputVars.xml

    <?xml version="1.0" encoding="utf-8"?>
    <Measurement>
        <Name>Show Input Vars</Name>
        <Abbreviation>InVars</Abbreviation>
        <Comments>Writes input variables and their values to the Show Output window.
        </Comments>
        <Script>ShowInputVars.py</Script>
        <MeasurementType>1 Source</MeasurementType>
        <ValidMode>Scope</ValidMode>
        <Dependent Name='Rise Time'></Dependent>
    </Measurement>

  3. Start Anaconda's Navigator application and then start the Python editor, Spyder. Copy the following script into Spyder. Name your script file ShowMeasurementInputVars.py and save it in FlexDCA's user measurements folder (\Documents\Keysight\FlexDCA\User Measurements). Spyder will keep line indentation correct for Python and will help to flag any typing mistakes.
  4. Copy

    ShowMeasurementInputVars.py

    # Python 2.7 FlexDCA User Measurement
    def algorithm(variables):
        print 'Input variables from FlexDCA:'
        for var, value in variables.items():
            s = "  '{0}':  {1}".format(var, value)
            print s
        return {'Result': 4.2,
            'Units':'dB',
            'Status':'Correct',
            'ErrorMsg':''}

  5. Place FlexDCA into Oscilloscope mode and display a single waveform on the display.
  6. In FlexDCA's User measurement tab, click the User Meas Setup button.
  7. In the dialog, select an available tab, click Browse, and select your XML configuration file, ShowMeasurementInputVars.xml.
  8. Close the dialog and click on your new Show Vars measurement button.
  9. In the Results pane, notice that the ShowMeasurementInputVars measurement result is reported.
  10. On the User tab, click the User Meas Setup button. Click the Show Output button. This button only appears on the dialog after the measurement has been started. You may also need to Reload the XML file.
  11. Place FlexDCA in Single mode to acquire one trace.
  12. In the displayed Output dialog, you should see the output of the print statement in your ShowMeasurementInputVarsd.py script. The output is also printed to the c:/Temp/Show User Measurement Input Vars.txt.