Example Code

Embedded Dynamic Panels in User Interface Application

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

  • Other
  • Teststand

Code and Documents

Attachment

Overview

The following describes the objective of and how to use the dynamic user interface example. The dynamic user interface example is a user solution that allows certain flexibility in dynamically changing the appearance and behavior of a user interface without changing the source code of the user interface.

When implementing TestStand solutions in large corporations, a common problem is that a single user interface application does not have the functionality and flexibility to fit the needs of every group within the company. Different groups can feel frustrated about the final standard functionality they get out of their single standard corporate user interface.

 

Description

This example demonstrates a method for creating a single dynamic user interface, illustrating the best practices that were explained previously in this article. It is a modification of the Simple CVI user interface that ships with TestStand under <TestStand>\UserInterfaces\Simple\CVI (or <TestStand>\UserInterfaces\NI\CVI prior to TestStand 2012). The example allows the addition of GUI functionality on a per-test basis. That is, it provides common functionality such as executing sequences and tracing executions, but provides a space on the user interface front panel so that users can embed their own GUI panels, without modifying the user interface source code. This enhancement provides a layer of modularity, resulting in an expandable, more maintainable test system.

 

The modified user interface source code is denoted with:

// Added for Dynamic TestStand User Interface example

 

And the .uir panel was modified by moving the original report control down to make space for the embedded panel.

Implementation

Since a user interface is often distributed to target machines as an executable, and the test developers do not have access to the user interface source code, a solution is sometimes needed to allow the test developers to customize the GUI of the user interface without modifying its source code. This example modifies the simple CVI user interface so that it processes three custom UI Messages: Attach Panel, Call Function and Detach Panel. For more information on UI Messages, refer to UIMessages in the TestStand Help file. To simplify use, the examples include three custom steps types that correspond to each of the custom UI Messages.

 

When test developers create a test sequence, they can create a DLL with a GUI, along with functions to manipulate that GUI. A custom step type, Attach Panel, is used within a sequence to specify the appropriate DLL and UIR to use in the test. When the sequence is executed the Attach Panel step embeds the GUI as a dynamic panel of the user interface.

 

The functions used to manipulate the GUI are specified using the Call Function step type. It should be called whenever the developer requires a GUI update. The functions called by the Call Function step type must have the following prototype.

    int functionName(int panel, CAObjHandle seqContext)

 

The Call Function step passes the sequence context to the called functions, allowing the function to share data between the current execution and the called function. Finally, when testing is done, the Detach Panel step type is used to unload the panel and release the DLL.

 

This solution allows every test sequence to have a different GUI that meets the needs of that test, and since the GUI is controlled through UI Messages (Attach Panel, Call Function, Detach Panel), the original method of communication between the TS Engine and the user interface is not affected. The best part is that the test developer does not need to know how the user interface works. He only has to develop a GUI with the appropriate functions to manipulate it and then embed the GUI in the user interface front panel using the included step types. For example, if a certain test requires a graph display, the test developer can create a DLL with a GUI that shows a graph control. He can then create all the necessary functions in the DLL required to update, manipulate, and clear the graph. When the test runs in the Dynamic User Interface example, this newly created GUI will be attached to the main panel of the user interface GUI, merging their functionality.

 

Hardware and Software Requirements

TestStand 2012(or compatible)

CVI 2012 (or compatible)

 

Steps to Implement or Execute Code

The attached zip file contains the modified user interface plus three example sequences:

  • Custom Serial Number panel
  • Custom Graph Panel
  • Custom Yields Panel

To run these examples perform the following steps:

  1. Unzip the contents of DynamicUserInterface 2012 NIVerified.zip into a new directory.
  2. One of the created subdirectories of your directory is DynamicUIStepTypes. Copy this directory to <TestStand Public>\Components\StepTypes\ (or to <TestStand>\Components\User\StepTypes\ if using TestStand 2012 or earlier). This directory contains code for three custom step types used in this example.
  3. Run the included simple user interface (testexec.exe).
  4. From the simple user interface open one of the sequence files included in the examples mentioned above. The examples are unzipped into a directory called ExampleDynamicPanels.
  5. Run MainSequence of the example you open by selecting Execute»Test UUTs.

 

Note: The step types for this example are defined in each of the example sequence files. However, if you want the step types to be available in all sequence files, simply copy install_DynamicUIStepTypes.ini that you can find in the unzipped DynamicUIStepTypes subdirectory, and place it in your <TestStand Public>\Components \TypePalettes\ directory (or <TestStand>\Cfg\TypePalettes\ if using TestStand 2012 or earlier). Upon launching your sequence editor this type palette will be loaded automatically and will be renamed to DynamicUIStepTypes.ini.

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

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