Example Code

Programmatically Create Enumeration Variable in TestStand

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

  • LabVIEW
  • Teststand

Code and Documents

Attachment

Download All

Description

This example shows you how to programmatically create an enumeration variable using the TestStand API.

 

How to Use

1. You should create a property object with value type Container using the NewPropertyObject Method:
1rtaImage.png

2. Then define a name for the property object and the number of elements it will contain using the Name Property and SetNumElements Method:
2rtaImage.png
3. After, you can populate the property object, each element in the container should have two sub properties: EnumeratorName and EnumeratorValue that you can add using the NewSubPropery and SetValString and SetValNumber respectively methods:
3rtaImage.png
4. You should create also a new data type using the NewDatatType method and name it using Name Property:4rtaImage.png

5. By default, the data type is empty, to populate it you can use the Update enumerators method passing the reference of the created container:

5rtaImage.png
6. Finally, you can insert the enum data type in the type usage list of the current sequence file using the InsertType method, use the IncChange Count method required to indicate to the sequence editor or user interface that the file was modified and the SaveFileIfModified method to save the changes in the sequence file.
6rtaImage.png
7. To create a instance of the enum data type you can use the NewSubProperty method, for example to create a local variable:
7rtaImage.png
Note: The LabVIEW (2019) code described in this document is provided as attachment.

Additional Information

​​​​​​If you are interested in creating a data type refer to Using the TestStand API to create a Data Type.

 

Related Links

 

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

Comments
GeekGrok
Member
Member
on

Clear and detailed explanation on creating an enumerated data type. Nice work!

vrv
Member
Member
on

Nice. Is it possible to update the Enum type without delete and create again?

Mr._Jim
Active Participant
Active Participant
on

For anyone interested, I have posted a version of this example using TestStand Expressions here:

https://forums.ni.com/t5/NI-TestStand/How-to-create-new-enum-data-types-with-teststand-API-Is-anyone...