Passing Data between TestStand and Python

TestStand 2019 Help

Edition Date: May 2019

Part Number: 370052AA-01

»View Product Info
Download Help (Windows Only)

Purpose

The example will showcase how data types of TestStand can be passed into Python modules.

Example File Location


Open Example

<TestStand Public>Examples\Fundamentals\Python\Passing Data to Python\Passing Data to Python.seq

Highlighted Features

Major API

None

Prerequisites

You must have required version of CPython interpreter installed and added to your PATH variable. You must update the Python version to use in the Python adapter configuration dialog before using the example.

How to Use This Example

Note Note  The example simulates an UUT that is being interfaced. The Model type, serial number, ports and voltage values mentioned in the example are hypothetical. The methods in the classes UUTInterface and UUTDatabase in the Python module are template methods and do not interface with any hardware or database.

Complete the following steps to use this example.

  1. On the Steps pane, review the steps in the Main step group.
    • The Working with Number step, which is a Sequence Call step, calls the Numbers subsequence to demonstrate passing numbers (integers and real) between TestStand and Python module.
    • The Working with Boolean step, which is a Sequence Call step, calls the Boolean subsequence to demonstrate passing Boolean data between TestStand and Python module.
    • The Working with String step, which is a Sequence Call step, calls the String subsequence to demonstrate passing string data between TestStand and Python module.
    • The Working with List step, which is a Sequence Call step, calls the Lists subsequence to demonstrate passing data between TestStand Array and Python List.
    • The Working with Tuple step, which is a Sequence Call step, calls the Tuples subsequence to demonstrate passing data between TestStand Container and Python Tuple.
    • The Working with PyObject step, which is a Sequence Call step, calls the PyObject subsequence to demonstrate passing data between TestStand object reference and Python object (PyObject).
  2. On the Steps pane of the Number subsequence, review the steps in the Main step group.
    • The subsequence has four sections that demonstrate the addition, subtraction, multiplication, and division of two TestStand numbers in Python module followed by a summary of the results, which is an Additional Results step. The four sections use 64-bit signed integers, 64-bit unsigned integers, 64-bit double precision floating point number, and float and number together respectively.
  3. On the Steps pane of the Boolean subsequence, review the steps in the Main step group.
    • The Boolean section demonstrates the inversion of the Boolean state of a TestStand variable in Python module. The section has a summary of the results, which is an Additional Results step.
  4. On the Steps pane of the String subsequence, review the steps in the Main step group.
    • The String section demonstrate the concatenation of two TestStand strings in Python module. The section has a summary of the results, which is an Additional Results step.
  5. On the Steps pane of the List subsequence, review the steps in the Main step group.
    • The subsequence demonstrates different operations (sorting and converting array to string) performed in Python module over TestStand Arrays.
  6. On the Steps pane of the Tuple subsequence, review the steps in the Main step group.
    • The subsequence retrieves a single element from a TestStand container using a Python module, sets a Python attribute as a tuple using a TestStand container, and get a Python tuple attribute into a TestStand container.
  7. On the Steps pane of the PyObject subsequence, review the steps in the Setup step group.
    • The Create UUTInterface Object step and the Initialize Database step obtains the references to the instances of the Python classes that are instantiated in the Python module. The references are stored in TestStand object reference variables. These references will be used in steps in the Main and Cleanup step groups.
  8. On the Steps pane of the PyObject subsequence, review the steps in the Main step group.
    • The Get UUT Model Type step, which is an Action step, gets the value in the class static attribute of the Python class UUTInterface.
    • The Get UUT Serial Number step gets the value of the attribute serialNumber from the object of the class UUTInterface whose reference was obtained earlier.
    • The Create UUT Record in Database step calls the createRecord method in the class instance object of Python class UUTDatabase whose reference was obtained earlier.
    • The Powerup UUT step calls the PowerupUUT method in the class instance object of Python class UUTInterface whose reference was obtained earlier.
    • The UUT String Value Test step, which is a String Value Test step, validates the serial number of the UUTInterface object.
    • The UUT Multiple Numeric Limit Test step, which is a Multiple Numeric Limit Test step, validates the range of ports assigned to the UUTInterface object.
    • The UUT Numeric Limit Test step, which is a Numeric Limit Test step, validates the voltage read by the UUTInterface object.
    • The UUT Pass/Fail Test step, which is a Pass/Fail Test step, validates the UUTInterface object's test result.
  9. Select Execute»Single Pass to run the sequence.
  10. When execution completes, review the report.

WAS THIS ARTICLE HELPFUL?

Not Helpful