NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I access variables across threads.

I am calling a custom callback from TestStand which is kicked off by the user clicking on a User Interface button.   I am running in Batch Mode and would like to get the index of the execution the user is viewing at the time he/she clicked on the button.   I have tried it seems like every RunState variable and TestStand API with no success.  How are you supposed to get information from parallel threads in TestStand?

 

 

0 Kudos
Message 1 of 8
(4,994 Views)

Is there a reason you cannot use a StationGlobals?  This seems like a pretty good use case.  The other option is UIMessages.  But those are generally for the User Interface.

 

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 8
(4,993 Views)

I am using StationGlobals to store information about each TestSocket.   The problem is I would like to know from a UI point of view what Test Socket he/she is currently on when the callback is invoked.   I haven't found any good way to do that.   As far as UIMessages, I havn't look,into that feature yet.

 

 

0 Kudos
Message 3 of 8
(4,990 Views)

You should use a UIMessage then.  Here is a doc on it: http://zone.ni.com/devzone/cda/tut/p/id/4532

 

There is a bunch of other info on NIs website if you search for it.  Basically, when you go into the custom callback you can post a UIMessage and then catch it in your UI.  You can pass information along with the message (i.e. the testsocket info).  Then you can display it on your UI or do whatever you need to with it.

 

Hope this helps you some.  Let me know if you have any questions.

 

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 4 of 8
(4,988 Views)

I have discovered that I was doing an execution entry point instead of a normal callback.  This would explain why I could not access other variables from other threads. 

 

I would like to abandon this aproach and try a normal callback in TestStand as a result of the user clicking on Terminate.

The problem with this is with callbacks like PostUUT.  It dosn't seem to be called immediatly.  I need immediately because I want to immediatly shut off power to that particular UUT in batch mode.   Alternatively experimenting with the <Cleanup> of the sequence.  It seems this does not get called at all during a Terminate.

 

Can anyone offer any suggestions?

0 Kudos
Message 5 of 8
(4,965 Views)
So in this scenario you would be testing multiple items in a batch, and when a user clicks on a button, you want all of the tests to terminate immediately? Do you want this to be a button that is always visible, such as a kill switch? Or is it just visable durring one particular step?
Richard S -- National Instruments -- (former) Applications Engineer -- Data Acquisition with TestStand
0 Kudos
Message 6 of 8
(4,925 Views)

TestStand Already provides a Terminate function.  This is what you get when you Left mouse click on the TestSocket Execution Icon them immediately right-mouse click and select Terminate.   I tie into this fuctionality with my customized Operator Interface in C# I put a call back on the Terminate button click. 

I would like for this event to notify me on the specific TestSocket Thread that is being executed for some critical things to take place before the Thread is actually terminated.

 

This is the events I would like to take place:

1) User runs test sequence in batch mode.

2) Thread run normally.

3) User decides he/she wishes to stop testing on 1 or all UUTs.

4) User Clicks on either Terminate single or Terminate all.

5) Software point of view a Callback occurs allowing for critical processing to occur before actual thread is stopped.

6) Thread or Threads is/are stopped.

 

All this takes place in TestStand 4.0 now except for step 5.   I customized the Operators User Interface to do an execution callback into the model before the thread is fully terminated.  This call works asynchronously as desired.  It calls the execution entry point into my BatchModel as desired.  If I present a popup asking for the TestSocket he/she is wishing to terminate then I can do this processing to the UUT as desired.   However is his/her response does not agree with what was selected on the Operator Interface GUI then my stuff runs on 1 TestSocket and yet another TestSocket is actually stopped.

0 Kudos
Message 7 of 8
(4,914 Views)
You can implement a termination monitor inside of your VB.net. Just periodically call to see if TestStand has terminated using the TS API, and when it has stop your VB you can take whatever actions are necessary to cleanup your code.
Richard S -- National Instruments -- (former) Applications Engineer -- Data Acquisition with TestStand
0 Kudos
Message 8 of 8
(4,877 Views)