Dynamic Step Template Insertion in TestStand
Overview
This example demonstrates how to dynamically insert a step into the Templates List using properties and methods available in the TestStand API. See the Insertion Palette Pane entry in the NI TestStand Help for general information about the Templates List.
Downloads
Filename: dynamic_template_insertion.seq
Introduction
There may be a case where you would like to dynamically insert steps within a sequence file into the Templates List, to be reused at a later time. This example sequence file uses a Statement step, with an expression that calls methods and properties available in the TestStand API. Using these methods and properties, we are able to obtain a reference to the Templates List file, insert a step, then refresh the Templates List window in order to display the changes.
Note: In the Templates List object we are Inserting a clone of the desired step, not the actual step within the sequence file itself. This will result in the behavior we desire: the step template will remain in the Templates List even after unloading the sequence file, opening a new sequence file, or even deleting the original step.
Important Concepts
Inheritance: The TestStand API is organized with an object-oriented architecture. This means that we are working with classes and objects. Within an object-oriented architecture, one of the ways that classes are related to each other is Inheritance (“is a” relationship). Refer to the NI TestStand API Reference Poster for an overall picture of the TestStand API, including inheritance.
The TemplatesFile is a PropertyObjectFile. We use the AsPropertyObjectFile method to return a reference to the underlying PropertyObjectFile that represents the TemplatesFile. The purpose of doing this is so that we have access to the properties and methods that are defined by the PropertyObjectFile class. We do the same for our step object, so that we can use the Clone method defined by the PropertyObject class.
Related Links
TestStand 4.1 Help: InsertionPalette
Developer Zone Tutorial: NI TestStand Type Management Best Practices
Reader Comments | Submit a comment »
Legal
This example program (this "program") was developed by a National Instruments ("NI") Applications Engineer. Although technical support of this program may be made available by National Instruments, this program may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this program with each new revision of related products and drivers. THIS EXAMPLE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
