NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

goto step in another sequence

Solved!
Go to solution

Can I kill the monitoring thread from out of the cleanup of the main sequence when there is a normal pass of the test. So I get a passed in my normal test sequence instead of 'terminated'.

0 Kudos
Message 11 of 20
(2,983 Views)

Rather than killing the thread it is better to tell the thread to exit and then wait for it to exit. One way to do this is to pass a boolean variable into the thread by reference, then in your cleanup set the boolean variable to true (which the monitoring thread checks and exits when it's true). Then in your next cleanup step wait for the thread using a TestStand Wait step, or have the sequence call step that launches the new thread set to "wait for thread at the end of the sequence".

 

Hope this helps,

-Doug

0 Kudos
Message 12 of 20
(2,969 Views)

Doug, I like this approach but how to pass the variable by reference? Will this method shut down a thread where resides an infinite loop?

0 Kudos
Message 13 of 20
(2,957 Views)

When you place a variable in the Parameters Tab of a Sequence, with it highlighted, right mouse click and you should find a setting 'by reference', select this.

Actually, I thought this was the default setting.

 

 

 

 

Regards
Ray Farmer
0 Kudos
Message 14 of 20
(2,955 Views)

How I set this parameter to true? Do I need to make a sequence call to the same thread? How to do this?

0 Kudos
Message 15 of 20
(2,952 Views)

When you call the sequence you specify a variable to pass for the parameter. In this case you might want to create a local variable called monitoringThreadShouldExit and pass that. Then when you want the monitoring thread to exit, you just do:

 

Locals.monitoringThreadShouldExit = true

 

You monitoring thread should then be checking Parameter.ShouldExit (or whatever you called the parameter) in its loop condition and not loop if it's set to true.

 

-Doug

0 Kudos
Message 16 of 20
(2,932 Views)

Doug, I tried ur method but the thread keeps running. I put a statement in my main sequence cleanup that states 'monitoringThreadShouldExit == True'. I passed that variable when I started the monitoringThread. How to debug this?

0 Kudos
Message 17 of 20
(2,920 Views)
Solution
Accepted by topic author JoVMo

Your thread needs to check the variable and stop looping to let itself complete. It depends on what your monitoring thread is doing for how best to accomplish this. Does your thread loop in a VI or DLL or in the sequence itself?

 

-Doug

0 Kudos
Message 18 of 20
(2,904 Views)

In a VI. But does the thread check the referenced parameter when its running or only at the start?

0 Kudos
Message 19 of 20
(2,899 Views)

My fault. 🙂 I used == instead of = to assign a value to the boolean. Tnx guys!

0 Kudos
Message 20 of 20
(2,883 Views)