Python Measurement Troubleshooting
FlexDCA provides two methods to troubleshoot your scripts: Measurement error Details dialog and the User Measurement Output dialog.
Unicode characters cannot be displayed in the error Details dialog or in the User Measurement Output dialog.
Error Details dialog
If FlexDCA receives invalid results from your script, the Results table will show an error as shown in the following picture. To view the Details of the failure, click the Results table's Details button. In this picture, a returned dictionary key was spelled 'Results'
instead of 'Result'
. If the scrips ErrorMsg
output variable contains a string, the string is shown in the Details dialog.
User Measurement Output Dialog
You can add print statements to your Python scripts as a troubleshooting aid. The ouput of the print statement is written to the User Measurement Output dialog as shown in the following picture. Each time that the script is executed, which is once per measurement acquisition, the print statements are executed. It is often helpful to set FlexDCA's data acquisition to Single mode and then click the Single button to control the output. Example of printing all input variables.
The following script was used to write the results of two dependent measurements (Amplitude and Peak-Peak) in the above picture. This represent two waveform acquisitions.
def algorithm(variables): # Argument "variables" is a dictionary from FlexDCA that maps from variable name to value. … … … # Write dependent measurement results to Show Output i = 1 print '\nDependent measurement results:' for meas in MeasData: print 'Meas', i, '=', meas['Name'], ',', meas['Result'], ',', meas['Source1'], ',', meas['Status'] i = i + 1 … … …
To view the User Measurement Output dialog:
- Add print statements to your script.
- In the User measurement tab, click User Meas to open the User Measurement Setup dialog and load your XML file to add the measurement.
- Close the User Measurement Setup dialog.
- Click your User measurement button to start your measurement.
- Click the User Meas Setup button to open the Setup dialog and select the tab that defines your measurement.
- Click the Show Output button as seen in the following picture.
If the Show Output button is not shown on the dialog, close and then reopen the dialog. If the button is still not visible, click FlexDCA's Single button to run a data acquisition. Each time that you click Single the script runs again and prints to the Show Output dialog. If there are no print statements in your script, Show Output will not be displayed.