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.
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.
05-13-2010 06:23 AM
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?
Solved! Go to Solution.
05-13-2010 08:33 AM - edited 05-13-2010 08:34 AM
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.
}
05-13-2010 10:15 AM
You can also use Execution.GetStates and look at the termination state to determine if it was terminated.
-Doug
05-13-2010 10:50 AM
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";
}
}