NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Aborting sequences programatically

I need to abort all sequences when the operator presses the emergency stop button in my TestStand operator interface.
Calling the AbortAll method does not abort the sequences immediately, instead the execution waits for the step that's executing to return and if it doesn't return after certain timeout it displays a dialog box where the ser can select to kill all threads.

That is what I need to do but immediately. I can't wait for a step to return, and I can't rely on the operators to select kill all threads from the dialog box.

Does anyone have any suggestions?

Thanks in advance,

Marcela.
0 Kudos
Message 1 of 5
(4,664 Views)
Hi,

In Station Options under the Time Limits tab you can switch off the time limits for when Aborting.

First select the Settings for control, then select Time Limit settings control to When Aborting.

You can then switch off the Set a Time Limit for this Operation control.

Do this for both Normal Execution and Exiting.

This may not be the total solution.

From the Programmer Help manual.

Execution.Abort()

Purpose

Aborts the execution.

Remarks

Cleanup step groups do not execute as part of the abort process.

The execution might not terminate immediately. If a call to a step module is active, the execution waits for that step module to return.

So this does suggest its going to wait anyway.
When using the Execution.AbortAll(). This doesn'
t say its waits so maybe it will meet your requirements.

The default Operators Interface execution panel the Abort button calls the Execution.Abort() method. Adding an additional button that calls the Execution.AbortAll() method should do the trick.

Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 2 of 5
(4,664 Views)
In the LabVIEW VIs that I write, I add InitializeTerminationMonitor, GetMonitorStatus, and CloseTerminationMonitor. I only add these to steps that I know might take a while to return and might want to terminate as soon as possible. I find it a lot cleaner than killing all threads.
0 Kudos
Message 3 of 5
(4,664 Views)
Hi Marcela,

This is actually a very common situation. Whenever you invoke any of the Abort or Terminate methods that TestStand provides, TestStand will NOT execute the steps that follow the one that is currently being executed. However, there's no way for TestStand to cleanly stop any external code being executed. Therefore, TestStand waits for the steps' code modules to finish (thus, "AbortAll" will NOT work either).

It's true that you can set a time limit for when an execution is terminating or aborting. When the time expires you can configure TestStand not to prompt the user for an action but instead to "Kill the Execution's Threads" (You can do this at the "Time Limits" tab at Configure > Station Options). However, it's definitely not very clean to "kill" the running threads because you might leave your computer at an unknown state and this could cause further problems. So, leave this as your last option.

The proper and clean way to handle this is as Dennis suggests. Include these 2 Execution methods inside your code modules (written in any programming language):
-InitTerminationMonitor
-GetTerminationMonitorStatus

In LabVIEW there is one VI per Execution Method (with the same names) and one last VI that you'll need to use: CloseTerminationMonitor.vi

The TestStand programmer's help explain very well how to use these methods. Basically, when your external code is in some kind of loop, you'll need to periodically (i.e. inside your loop) call the Execution.GetTerminationMonitorStatus from which you'll receive a boolean value. If True, then you should add some code that will get out of that loop and terminate executing your external module. In other words, you should handle the clean termination of your module Inside that module. The only additional code that you are adding is to monitor whether the user terminated or aborted the sequence execution.

Hopefully this will clarify how TestStand handles the termination/abortion of a sequence and how to properly terminate your external code modules.

Let me know if you have further questions.

Regards,

Carlos Leon
Message 4 of 5
(4,664 Views)
Thank you very much
0 Kudos
Message 5 of 5
(4,664 Views)