This document provides an overview of creating a LabVIEW code module with access to the TestStand API, and demonstrates how to access API properties and methods in LabVIEW. Refer to Using the NI TestStand Object Model for more information on the structure of TestStand objects and the TestStand API.
Follow the steps below to create a new LabVIEW code module with access to the TestStand API. You must have the LabVIEW development system active in the LabVIEW adapter settings to use this approach.
To create a new VI from a template, select the Create VI button in the module tab of the step, as shown.
After specifying a name and location for the new VI, the VI will be generated using the template below. TestStand uses a specific template depending on the step type you use. For example, a numeric limit test step contains an additional numeric measurement output.
The SequenceContext (or ThisContext) object contains a snapshot of the current state of TestStand execution, including references to the current sequence file, sequence, step, execution, and thread. The SequenceContext also provides access to the TestStand engine. In most cases, the code module can access all information it needs using the SequenceContext.
To use the TestStand API in the new VI, use property nodes and invoke nodes to access built-in properties and methods, respectively. You can access this quickly in the context menu for the Sequence Context reference, as shown:
For example, the code below accesses the name property of the current sequence (the sequence where we called the LabVIEW module).
To prevent memory leaks, always call the Close Reference VI on any object that is returned from a property or invoke node once you are finished using it. Do not close references that are passed into the VI, such as the SequenceContext.
Equivalent expression: ThisContext.Sequence.Name = "newName"
Unlike the expression browser, you cannot access dynamic properties, i.e. objects contained within the current object, directly through a property node. For example, there is no Main API property for the sequence class; Main is a dynamic PropertyObject contained by the sequence object. To access the dynamic PropertyObjects contained by the current object, you have two options:
Use the GetPropertyObject method to access a contained property. This method uses a lookup string to specify the location of the object using dot syntax. Since this is a method of the PropertyObject class, you first need to use the AsPropertyObject method to cast the sequence object to a PropertyObject. In the example below, we use this approach to access a particular step.
Equivalent expression: ThisContext.Sequence.Main["Action"].Name = "newStepName"
For more information, refer to the following TestStand help topics:
Refer to the following topics for advanced topics on using the TestStand API in LabVIEW:
You can access documentation on the properties and methods of the TestStand API using the context help window. You can access the full API documentation for the selected property or method by clicking the "?" icon in the Context Help window.
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.