NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I terminate TestStand without requiring user input?

I want to completely terminate TestStand and any running sequences. Engine.ShutDown seems to have a delay waiting for user input. Is there a function call that disregards this delay and immediately either kills all sequences or unloads them and kills TestStand?

I am trying to do this in C++.
0 Kudos
Message 1 of 9
(4,113 Views)
To BMas05 -
Engine.TerminateAll will instruct TestStand to attempt to stop all executions. TestStand cannot stop a thread that it does not have control of such as when a thread is unresponsive. For example, when a thread is running external code in a code module. Note that a external call can use Execution.GetTerminationMonitorStatus to determine if the execution is attempting to terminate, and when it is, the code module can return back to TestStand.

Scott Richardson (NI)
Scott Richardson
Message 2 of 9
(4,113 Views)
So if TestStand calls into CVI, there is no way to kill execution of TestStand without either waiting for the function to return (since TestStand does not have control of what happens in that call) or killing the actual TestStand process ID inside Windows?
0 Kudos
Message 3 of 9
(4,113 Views)
To BMas05 -
You are correct. Unless code modules monitor for termination, TestStand cannot control the thread. This is an OS limitation, not a TestStand limitation.

TestStand does have a way of specifying whether a termination request is escalated to a prompt to the user, or an automatically abort(termination with no cleanup steps), or just kill the threads in the execution. This setting is specified under the Station Options and the escalation can specify timeout values. Keep in mind that killing threads under a process can have negative effects where other threads hang including the main GUI. In the end the process should eventually be exited nicely, or killed if the process is unresponsive.

Scott Richardson (NI)
Scott Richardson
0 Kudos
Message 4 of 9
(4,113 Views)
If I set, under the Station Options menu, for Exiting -> When Executing time limit to 2 seconds, and the action to take to "Terminate", could I try to shut down the engine and if the currently executing thread does not complete within 2 seconds, it will attempt to terminate it?
0 Kudos
Message 5 of 9
(4,113 Views)
To BMas05 -
Yes if you set,
Setting: "Exiting"
Condition: "When Executing"
Time Limit: "2"
Action: "Terminate Execution"

On shutdown, if an execution is running for more than 2 seconds after shutdown is initiated, TestStand will attempt to terminate the execution.

Now if you wanted to escalate terminations that take too long you could additionally set,
Setting: "Exiting"
Condition: "When Terminating"
Time Limit: "4"
Action: "Abort Execution"

So now on shutdown, if an execution is terminating for more than 4 seconds after termination is initiated on shutdown, TestStand will attempt to abort the execution.

Now if you wanted to escalate aborting executions
that take too long you could additionally set,
Setting: "Exiting"
Condition: "When Aborting"
Time Limit: "6"
Action: "Kill the Execution's Thread's"

So now on shutdown, if an execution is aborting(typically unresponsive) for more than 6 seconds after abort is initiated, TestStand will attempt to kill the unresponsive thread.

Scott Richardson (NI)
Scott Richardson
0 Kudos
Message 6 of 9
(4,113 Views)
Would these settings be available to modify through the API? Or would the user have to manually enter these settings?

Also, this should probably be another topic, but if this shutdown is the only call through the TestStand API, is it still necessary to follow the 2 path process of terminating the engine? Or can I simply pass true into the shutdown function?
0 Kudos
Message 7 of 9
(4,113 Views)
To BMas05 -
Starting with TestStand 3.0, it has the following API calls:
GetTimeLimit
GetTimeLimitAction
GetTimeLimitEnabled

SetTimeLimit
SetTimeLimitAction
SetTimeLimitEnabled

Prior to TestStand 3.0 the settings would have to be done manually or via editing the testexec.ini and restarting TestStand.

I think you can call shutdown(final=true). The purpose of the 2 phase shutdown is to allow executions to properly shutdown using the timeout options we talked about, and to allow the user to cancel. All I can suggest is to try it.

Scott Richardson (NI)
Scott Richardson
0 Kudos
Message 8 of 9
(4,113 Views)
Thanks for your help Scott. I think you've given me enough info to test some things.
0 Kudos
Message 9 of 9
(4,113 Views)