NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Multithread execution, and thread termination

I am fairly new to teststand and I know this is fairly complex. I'm an intermediate user of CVI, and have programmed in C for a while. So here goes...

 

I want to create two concurrent threads in teststand. One of these threads will be running a series of tests. The other will be running the same test, checking environmental conditions, in a timed loop. I want to have the thread that is checking the environmental condition terminate the other thread on a fail condition. To make matters more complicated, I want to have the thread not only terminate the "Main" thread, but do it in such a way that I am still able to execute a shutdown sequence for the hardware that is in use. Finally, I need the "monitoring" thread to have the ability to be switched on and off by the main thread, as sometimes it will need the hardware it uses.

 

I have some experience with threading, and operating systems, but am just unsure how to execute this in teststand and/or CVI.

 

Thank you in advance for all your help.

 

0 Kudos
Message 1 of 2
(3,416 Views)

Hi Crymsenn,

TestStand offers full multithreading capabilities. If you go to www.NI.com >> NI Developer Zone >> Development Library >> Measurement and Automation Software >> TestStand (or click on this link), you will see a large amount of information regarding TestStand. This site provides multiple pieces of general and specific documentation regarding TestStand as well as example code and is a great resource to use.  

In your case, there is a particular section called Multithreading. If you look and browse through the Application Notes and Tutorials section, as well as the Technical Presentations section, you will learn a great deal about multithreading and what options you have in TestStand. Below is an overall view of multithreading in TestStand but for great detail, use that TestStand site.   

In TestStand, the operator interface or sequence editor are considered processes. Each of these processes can launch multiple executions and in turn, each execution can contain multiple threads. Every execution must contain at least one thread with all threads within an execution operating independently of each other.  You must use a method of inter-process communication to share resources between these threads. 

Both executions and threads are TestStand objects and you can obtain a thread object from the Execution object. When you run a sequence, TestStand creates an Execution object and a Thread object and a new Execution window launches to show the current execution.  If you create a new thread within the current execution, a new Execution window does not appear, but the thread executes in the background.  TestStand only creates Execution windows when you start a new execution.

There is also the concept of Synchronization Step Types that you use to work with threads. See the TestStand 2.0.1 Reducing the Cost of Manufacturing Test link (found under the General section of TestStand) and toward the middle of that document, it explains about Synchronization.

Also, I would suggest browsing the examples folder for TestStand under C:\Program Files\National Instruments\TestStand 3.1\Examples. I would start off with the MultiUUT example. 

Hope this helps!

Best Regards,

Jonathan N.
National Instruments
Message 2 of 2
(3,374 Views)