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.

Comments
TwoCentsHappy
Member
Member
on

Getting entry point error SetRTSystemSetting not located in cvirte.dll

paulmueller
Member
Member
on

Hmm... I have no idea what is happening. This example doesn't do anything with SetRTSystemSetting which is something for real-time systems.

I built the testexec.exe with CVI 8.5. It uses the TestStand engine 4.0 or later. The step types were created with an older version of CVI, but that shouldn't make any difference.

Please make sure that you have the CVI runtime engine ver. 8.5 or later.

shb
Active Participant
Active Participant
on

How do I add a GUI of a LabVIEW VI in the embedded panel?

paulmueller
Member
Member
on

shb,

To embed a LabVIEW front panel in a CVI application (as shown in the example), the GUI will need some modification to handle this. This will require some thought and a bit of work. To embed a LV panel in a CVI application, you can use a web page control and export VIs to a web server.

A more attractive option is to start with a LV-based GUI. Now, you can use LabVIEW subpanels. And create the equivalent UIMessages to load a VI in the subpanel or unload a VI from the subpanel. To load a subpanel, have the test code send a UIMessage with the path of the VI to load.

LuigiM
Member
Member
on

Why I'm not able to see any image of the article?

Luigi Magni (System Engineer - CTA)
paulmueller
Member
Member
on

Hi LuigiM,

Sorry for my late reply. I was away from my usual country for several weeks.

This example page doesn't have any images, but there is a spacing problem which makes it look like there should be images. I will fix that.

Regards,

Paul

Eugene12
Member
Member
on

Paul said:

A more attractive option is to start with a LV-based GUI. Now, you can use LabVIEW subpanels. And create the equivalent UIMessages to load a VI in the subpanel or unload a VI from the subpanel. To load a subpanel, have the test code send a UIMessage with the path of the VI to load.

Eugene says:

How do I go about having "the test code send a UIMessage..."?

paulmueller
Member
Member
on

Eugene,

Use the PostUIMessageEx method.

The example from this article uses custom step types. Custom step types may be more than you need to send a UIMessage.

1. Look at this article: http://zone.ni.com/devzone/cda/tut/p/id/4532

2. TestStand ships with a few examples that demonstrate how to send UIMessages from test code.

Look at these examples: <TestStand directory>\examples\DisplayingProgressAndStatus\

- each of these examples shows how to send a UIMessage from a CVI DLL, LabVIEW, or Visual C++ (MFC).

3. Refer to the TestStand documentation regarding UIMessages

Regards,

Paul