Launching a Floating .NET Form in TestStand
Overview
In many cases it may be desirable to have a floating form during a TestStand execution. This form may be used for user updates, or other custom interaction with the user more than what is available through the default TestStand Sequence Editor interface. This example program shows the recommended way to implement such a feature.
Downloads
Filename: floating_dotnet_panel.zip
Requirements: View
Introduction:
In this example we implement a progress bar to show the current progress as updated by an executing sequence file. When we begin our sequence, our floating .NET user interface (UI) form is launched in its own thread, calling a method of an object created from a .NET assembly. Throughout execution, our sequence occasionally sends a Custom UIMessage that contains a numeric indicating the completed percent of execution and a string indicating arbitrary extra information about the executing sequence.
This simple example's MainSequence Main Step Group simply loops through two steps 100 times. The first step of each iteration simulates the time it would take to execute actions in a testing sequence and increments a progress variable in its Post-Expression. The second step in the loop sends a UIMessage containing the up-to-date progress. The floating form handles the event fired by the UIMessage, updating its progress bar with the new percentage.

Numeric and String Data Showing Execution Progress
Note: Included in the attached download is the C# source project for the .NET assembly. See the related links section for this example using application development environments other than Microsoft Visual Studio and programming languages other than C#.
Important Concepts:
Support for Multiple Interfaces: Adding functionality to an Operator Interface is relatively straight-forward and involves little more than modifying the source code of a pre-existing TestStand Operator Interface to include the extra functionality desired. This works especially well when using UIMessages, since the same Sequence code can update multiple different Operator Interfaces. It is up to the individual Operator Interface how it responds to the UIMessages sent by an executing sequence, if it even does respond. This allows us to have different Operator Interfaces with different functionality and usability without having to change the sequence code at all.
This method of abstraction works quite well with open-source Operator Interfaces. What about when we use the Sequence Editor? We cannot edit the source of this interface to include UI elements for our own customer functionality, so a floating form is a good way to work around this. This floating form should still follow the best practices for Operator Interface modifications, since it is still part of the Operator Interface layer. This example show how to implement a floating form in such a way that it responds to the same UIMessages that you would send to an open-source Operator Interface to update a progress bar. We check the ApplicationIsEditor property, and only launch the floating form if a Sequence Editor is the interface being used for execution.
Multi-Threading in TestStand: We launch the floating .NET form in its own thread so that it can run without blocking the execution of our sequence.
User Messages: Custom UIMessages (User Messages) have an event number 10000 or greater. In this example we define message 10200 to be a progress update and 10201 to be the end of our sequence, signifying that our floating form to terminate and close.
Application Manager Reference Passing: Our form needs a reference to the Application Manager in order to register for and handle User Message Events. We use the GetInternalOption method to get the Sequence Editor's Application Manager reference. See the Developer Zone Example: Test Stand: Effectively using the Sequence Context in LabVIEW for more information on passing TestStand references into external environments.
Related Links:
Developer Zone Example: Launching a Floating LabVIEW Panel in TestStand
Developer Zone Example: Launching a Floating CVI User Interface in TestStand
Requirements
Filename: floating_dotnet_panel.zip
Software Requirements
Application Software: NI TestStand Development System 4.0
Language(s): C#
Reader Comments | Submit a comment »
Legal
This example program (this "program") was developed by a National Instruments ("NI") Applications Engineer. Although technical support of this program may be made available by National Instruments, this program may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this program with each new revision of related products and drivers. THIS EXAMPLE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
