Example Code

Getting Data from the TestStand User Interface During Sequence Execution

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

In order to get data from a User Interface (UI) into an executing sequence, you must first make the connection from the sequence to the UI. This example program shows how to make that connection using a UIMessage with our custom UI.

Description

Note: The concepts in this example are demonstrated in the TestStand shipping example Handling UI Messages in TestStand 2013 and Later.  The examples attached are provided for earlier TestStand versions and will not be updated.

 

This example demonstrates the recommended method for passing information from a UI to an executing sequence via a User Interface Message (UI Message).  A summary of the implementation is described below:

  1. The sequence file posts a UI Message, indicating that it is ready for the UI to configure the settings
  2. The UI message handler implemented in the custom User Interface executes, and enables or disables reporting based on the setting on the User Interface
  3. Once the UI message is handled, the sequence continues executing.

This method is recommended for a number of reasons:

  • Ensures that no coupling exists between the sequence file and the user interface.   Refer to the Using TestStand User Interface Messages (UI Messages) tutorial for more information on the benefits of UI messages. 
  • Ensures that the UI only modifies properties for sequences that support the modification, since the sequence must request the change.
  • Prevents possible race conditions that can occur if the properties of a running sequence file are modified, because the sequence waits for the UI message to be acknowledged by the user interface before continuing the execution

Important Concepts

Support for Multiple Interfaces: Adding functionality to an User Interface is relatively straight-forward and involves little more than modifying the source code of a pre-existing TestStand User Interface to include the extra functionality desired. This works especially well when using UI Messages, since the same Sequence code can update multiple different User Interfaces. It is up to the individual User Interface how it responds to the UI Messages sent by an executing sequence, if it even does respond. This allows us to have different User Interfaces with different functionality and usability without having to change the sequence code at all.

User Messages: Custom UI Messages (User Messages) have an event number 10000 or greater. In this example we define messages 10100 to pass the reference to the local variable to our UI.

Hardware and Software Requirements

Getting Data From the User Interface - TS4_2.zip

TestStand 4.2 or Compatible

LabVIEW 2009 or Compatible

Steps to Implement or Execute Code

To use this example follow the steps below.

  1. Download and extract the example files.
  2. Before running the example, inspect the Intermediate OI mod.seq example.  Notice that it overrides the ReportOptions callback, and posts a custom UI message. 
  3. Open the TestExec.llb, and inspect the source code.  Notice that the front panel has an Enable Reporting option, and the code (see Simple OI - Configure Events Callback.vi) contains an event handler for user messages (UI messages with an ID over 10000).  In the callback for this message, the UI enables or disables reporting.
  4. To run the example, open TestExec.exe from the example directory.  
  5. In the UI, open the Intermediate OI mod.seq sequence file, and execute it using the Single Pass or Test UUTs button.  Notice that the report is not generated if the Enable Reporting option is disabled.
  6. You may notice that the Enable Reporting option has no effect with other files.  This is due to the fact that the sequence file must send a UI message to indicate that the UI can change the setting.

Additional Information or References

TestStand Example: Handling UI Messages 

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.

Contributors