From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I detect if a TestStand execution has been terminated?

Solved!
Go to solution

We have written a custom GUI that interfaces with TestStand to invoke and control the execution of sequence files.  During an execution, the operator can click on a STOP button which causes the following code to be executed:

 

        this.myExecutionViewMgr.GetCommand(CommandKinds.CommandKind_Terminate).Execute(true);

 

This works OK and the TestStand execution is terminated.  However, the EndExecution event handler is not telling me that the execution was terminated.  Here's what our code looks like:

 

        void EndExecutionEventHandler(object sender, EndExecutionEvent ev)

        {

            // This line ALWAYS returns PASSED or FAILED

            this.Status = ev.exec.ResultStatus;

 

            // The error object doesn't occur when I terminate 

            PropertyObject errorObj = ev.exec.ErrorObject;

            if (errorObj.Exists("Occurred", 0) && errorObj.GetValBoolean("Occurred", 0))

            {

                string errorCode = errorObj.GetValNumber("Error.Code", 0).ToString();

                string errorText = errorObj.GetValString("Error.Msg", 0);

                MessageBox.Show(errorCode.ToString() + " - " + errorText);

            }

        }

 

Is there a way to identify if an execution was terminated, aborted, etc?

0 Kudos
Message 1 of 4
(4,924 Views)
You can check it from your "UIMessageEvent" event from your Application Manager , usually when you terminate the execution it will throw an event

UIMessageCodes.UIMsg_TerminatingExecution.

 

if (e.uiMsg.Event == UIMessageCodes.UIMsg_TerminatingExecution)

{

      //This is giving you the idea that the execution was terminated.

 

}

else if  (e.uiMsg.Event == UIMessageCodes.UIMsg_AbortingExecution)

{

      //This is giving you the idea that the execution was aborted.

}

Message Edited by -mbda- on 05-13-2010 08:34 AM
0 Kudos
Message 2 of 4
(4,915 Views)
Solution
Accepted by topic author tlaford

You can also use Execution.GetStates and look at the termination state to determine if it was terminated.

 

-Doug

Message 3 of 4
(4,904 Views)

I changed my EndExecutionEvent Handler method to the code below and it works great!

 

       void EndExecutionEventHandler(object sender, EndExecutionEvent ev)

        {

            this.Status = ev.exec.ResultStatus;

 

            ExecutionRunStates runState;

            ExecutionTerminationStates termState;

            ev.exec.GetStates(out runState, out termState);

            if (termState != ExecutionTerminationStates.ExecTermState_Normal)

            {

                this.Status = "ABORTED";

            }

        }

0 Kudos
Message 4 of 4
(4,895 Views)