Example Code

Creating a Custom TestStand Data Type Using the TestStand API

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • Teststand

Code and Documents

Attachment

Description

Overview

This example creates a new TestStand data type programmatically using the TestStand API. The example allows you to choose whether to store the type in the MyTypes.ini type palette, or in the current sequence file.

Description

This example shows how to access the TypeUsageList for a type palette file such as MyTypes.ini, or for the current Sequence file.  The TypeUsageList is an object which contains all data and step types referenced by a particular file.  The following methods are used by the example:

 

To access the TypeUsageList for a type palette

 

  1. use Engine.GetTypePaletteFileList() method to retrieve the list of INI Files current loaded by TestStand. This method returns an array of PropertyObjectFile objects
  2. Use the For Each step type to loop over each PropertyObjectFile in the list, and check the name using the PropertyObjectFile.DisplayName property.  

To access the TypeUsageList for a Sequence File

 

  1. Cast the SequenceFile reference to the more generic class propertyObjectFile using the SequenceFile.asPropertyObjectFile method

Once the example has stored the PropertyObjectFile reference to the destination for the type, it retrieves the TypeUsageList object from the property PropertyObjectFile.TypeUsageList. The TypeUsageList class provides methods and properties to operate type definitions.


The type object itself is created in the same way as any other PropertyObject, using the Engine.NewPropertyObject method and populates this container using the PropertyObject.SetValString and PropertyObject.SetValNumber methods with the PropOption_InsertIfMissnig flag to create the fields.  The value you set for each field is the default value for the data type.

To insert the new PropertyObject into the Sequence File or Type Palette as a data type, use the TypeUsageList.InsertType method, then save the changes using the PropertyObjectFile.IncChangeCount and PropertyObjectFile.SaveIfModified.

Hardware and Software Requirements

Create Data Type Using TestStand API - TS2012.seq

TestStand 2012 SP1 or Compatible

Create Data Type Using TestStand API - TS3_1.seq

TestStand 3.1 or Compatible

 

Steps to Implement or Execute Code

  1. Open the example file, and run the MainSequence using Execute » MainSequence
  2. Follow the instructions in the message dialogs

 

Additional Information or References

TestStand API Reference: TypeUsageList

Al B.
Staff Software Engineer - TestStand
CTA/CLD

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.