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
- 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.
- 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.
- Place FlexDCA into Oscilloscope mode and display a single waveform on the display.
- In FlexDCA's User measurement tab, click the User Meas Setup button.
- In the dialog, select an available tab, click Browse, and select your XML configuration file, ShowMeasurementInputVars.xml.
- Close the dialog and click on your new Show Vars measurement button.
- In the Results pane, notice that the ShowMeasurementInputVars measurement result is reported.
- 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.
- Place FlexDCA in Single mode to acquire one trace.
- 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.
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>
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':''}