Example Code

Enable/Disable custom menu items when logging in/out in TestStand UI

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

Overview

This example demonstrates how to add a custom menu item to the Full-Featured UI, and enable it only for users with certain privileges.

 

Description

Most menu items in the full-featured TestStand User Interface are populated dynamically when the user selects the menu item. However, you can add additional custom menu items by following these steps:

  1. Define the menu name and tags in the Edit Runtime Menu dialog, which you access by selecting Edit » Runtime Menu from the top level VI.  Alternatively, you can use the Insert Menu Items node to create the menu programmatically

    2018-03-30_132118.png
    Note: if you define item names that begin with the prefix TS_, TestStand will attempt to localize the strings using the language files.
  2. To define the behavior when the user selects the item, add a new case in the Process User Menus VI

    2018-03-30_135553.png

If the menu item should only be enabled for users with certain privileges, you can modify the User Changed Callback.vi, which executed whenever a new user logs into TestStand. This event is registered in the Configure Event Callbacks.vi. In this example, the menu is enabled only for users with the Configure privilege.

 

2018-03-30_140043.png

 

Hardware and Software Requirements

Adding Custom Run-Time Menu Items - TS2014.zip

TestStand 2014 or Compatible

LabVIEW 2015 or Compatible 

Adding Custom Run-Time Menu Items - TS2016.zip

TestStand 2016 or Compatible

LabVIEW 2016 or Compatible 

 

Steps to Implement or Execute Code

  1. Extract the attached example, and open the Build Script.lvproj project.
  2. Open the Top-Level VI.vi, and click the run button.
  3. After logging in, observe the Calibration menu is present, and clicking the Calibrate Hardware menu item launches a sample dialog.
  4. Select File » Log Out.  Observe that the Calibration menu item is now disabled.
  5. If an operator user is configured on the current station, log in as the operator.  Observe the menu is still disabled. 

 

 

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