NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Sharing a communication object between test sockets

Hi everyone, I am having some trouble using teststand in batch mode as it is my first time doing so. Here is my question:

 

I am creating a test sequence that uses multiple test sockets. I am using a switching matrix that is controlled over ethernet to allow me to connect different loads to the hardware under test. I only have one load, but I have several different devices that need to connect to that load for the tests to be run, and they can only be connected one at a time.

 

My approach was to initilaze the connection to the switching matrix and store the resulting object reference as a global variable, which allows me to send commands to the switch matrix from any sub-sequence. I then created another sub sequence for the load tests called "External Load Tests". In this step, the load is connected to the hardware via the switching matrix, and tests are run. I am using batch mode, so I put a lock on the "External Load Tests" sub sequence so that only one thread can enter at a time.

 

This sequence works if there is only one active test socket. If there is more that one, the first thread will get inside the external "External Load Tests" step and try to send a command to the switch matrix using the object reference that I mentioned. However, when this happens, the step hangs indefinitely until the other threads are manually stopped. It seams like the thread isnt being given access to the switch matrix object, becuase usually if there is an error the switch matrix driver throws an exception, but in this case it just hangs. 

 

Any ideas on how I can fix this? I don't have a lot of experience with multi threading, so any advice would be greatly appreciated.

 

Thanks!

 

 

0 Kudos
Message 1 of 4
(2,824 Views)

Did you also lock the part which initializes the switch and stores the reference with "one thread only" ? According to your description, that seems to be missing. 

Did you allready check, if the reference does't get corrupted from the time when it's written to the time when it is read and used ?

0 Kudos
Message 2 of 4
(2,804 Views)

Actually I found a solution to this yesterday. It turns out the lock works the way I thought it would if I have the model set to run in unsynchronized batch mode. I had previously set it to parallel batch mode. I'm not sure why the lock doesnt work the same way in parallel mode Smiley Happy 

0 Kudos
Message 3 of 4
(2,794 Views)

For the batch model you could use a serialized batch synchronization section rather than a lock. A lock should also work though, it just doesn't guarantee that all threads get to the section before any of them continue and doesn't guarantee the order like batch synchronization does. Typically you should use all default settings for the batch model (other than perhaps number of sockets). Which setting did you change? The 'Default Batch Synchronization' setting? You should typically leave this as "Don't Synchronize". Setting this to Parallel makes it synchronize at every step which requires all sockets to get to each step before any of them to continue. This is not the behavior that people typically want. In most cases you should use the default of "Don't Synchronize" and then set synchronization manually in your sequence where you want it, either using the step synchronization settings, or the batch synchronization step types, or other synchronization step types such as locks.

 

Hope this helps,

-Doug

0 Kudos
Message 4 of 4
(2,787 Views)