Example Code

Disabling Entry Point Buttons When Executions are Active in a TestStand User Interface

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

  • LabVIEW
  • Teststand

Code and Documents

Attachment

Description

Overview

This example shows how the full featured UI example can be modified to prevent the user from accidentally executing an execution multiple times, in the case that it takes some time for the execution to start. 

 

Description

In order to manage the enabled state of the Entry Point and Run Sequence buttons, code is added to the startExecution and EndExecution event callbacks, which are executed when a TestStand execution starts or ends, respectively.  Each callback provides a reference to the execution which triggered the event, which can be used to track what executions are running

 

  1. In StartExecution callback, disable the buttons, and record the new execution using the ExecutionID property.  
  2. In EndExecution callback, remove the ExecutionID for the ending execution from the list.  If the list is now empty, re-enable the buttons

Note: the legacy examples do not store a list of executions; the buttons are always disabled/enabled when the callback is executed.

 

 

Hardware and Software Requirements

 Disable Entry Point Buttons (LabVIEW) - TS2019

TestStand  2019 or Compatible

LabVIEW 2020 or Compatible

 

 Disable Entry Point Buttons (LabVIEW) - TS2016

TestStand  2016 or Compatible

LabVIEW 2015 or Compatible

 

 

Steps to Implement or Execute Code

LabVIEW Implementation 

The callback VIs are registered in the Register Event Callbacks.vi:

 

  1. The StartExecution callback is already defined in the Full Featured UI, so the existing callback, StartExecution Callback.vi, is modified to enable the buttons using the Enabled property of the button control
  2. A new callback is registered for the EndExecution event.  In this callback, EndExecution callback.vi, the example adds the code to enable the buttons if no executions are running

 

C# Implementation 

The callback methods are registered in the InitializeComponent using a delegate:

 

this.axApplicationMgr.StartExecution += new NationalInstruments.TestStand.Interop.UI.Ax._ApplicationMgrEvents_StartExecutionEventHandler(this.axApplicationMgr_StartExecution);

this.axApplicationMgr.EndExecution += new NationalInstruments.TestStand.Interop.UI.Ax._ApplicationMgrEvents_EndExecutionEventHandler(this.axApplicationMgr_StartExecution);

 

In the event handler methods, the button Enabled property is set to false in the StartExecution callback, and true in the endExecution callback. 

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.

Comments
imran079
Member
Member
on

Can you please share the same in Labwindows CVI

ShockHouse
Member
Member
on

This does not work in TestStand for the first execution. Any execution after that works. But the first one disables it, and then something reenables it during execution. Sometimes it does it on its own, sometimes if you pause it after a few seconds it will reenable it (only the first time). Same behavior in 2019 or 2023 Q4.

Contributors