04-06-2016 10:30 AM
Hello,
i am running a batch model with 4 testsockets.
In my testplan there is a for loop with 10 loops.
Currently when running the testplan it happens that the four testsockets just execute the forloop as fast as possible and dont care about the other three testsockets.
How can i change the for loop so that for each loop the test sockets must wait for all testsockets are finished with the last loop before starting the next loop?
Current idea is to create an array with size = number of testsocks.
This array is initialized with 0s
After the for loop is ended i set the variable to 1
before next loop i check if all four are set to 1
Somethig like:
Clear StationGlobals.Finished[ ] = 0,0,0,0
for
#Wait for StationGlobals.Finished[0..3] == 1 (if yes then clear them and continue)
Execute Test
#Set StationGlobals.Finished[TestSockets.MyIndex] = 1)
end loop
How can this be done better?
Thx
04-06-2016 10:59 AM
There are likely several approaches that you could implement that would utilize built-in TestStand features to accomplish your stated goal. One such approach (attached) would be to use a Rendezvous step to ensure all TestSockets must rendezvous at the end of the loop before continuing.
Please let us know if this covers your stated goals.
-Jeff
04-06-2016 10:59 AM
Use a rendezvous step right before end loop. Easy peasy.
04-06-2016 11:34 AM
I don't think a rendezvous would be the first choice in this case.
If you are running in batch, you can just set Step Properties>>Synchronization>>Batch Synchronization to Parallel (or Serial) to force a rendezvous at any step. No need to create an actual Rendezvous and it should still work even if a socket is disabled, errors out, or is terminated.
04-07-2016 02:39 AM
Thanks you. This works.
What if i want to use a second Rendevouz?
Do i have to execute another "Create Rendevouz" with a new Name OR can i just put a second "Operation: Rendevouz" teststep with the already created Name at another position?
##########################
Create Rendevouz "Loop"
forloop1
do something
Rendevouz1
end
forloop2
do something
Rendevouz2
end
##########################
04-07-2016 08:01 AM
you could try to surround the loops with Batch Synchronization
04-07-2016 08:05 AM
I changed my mind and am siding with James on this one. I wouldn't use the rendezvous step. Batch Synchronization is much safer. Why? Because you are using the existing batch threads and you don't need to explicitly create a rendezvous. Here is a screenshot on how to set the synchronization for a step. Just do it on your For step. Check out the attachment. NOTE: this only works if you are using the Batch Model.
Hope this helps,
04-07-2016 08:16 AM
As jiggawax said paralell will work but you may have another option.
do you want to do those loops in parallel on each test socket... or do you rather have Test socket 1 do all the loops.. then Test socket 2 do all the loops as a sequence. Testand will wait to all test sockets to finish looping to continue..
you can use the batch synchronization and use "
Depending on you application you have many options now on the table...
04-07-2016 08:17 AM
You do not need to execute a second "Create Rendezvous" to ensure that your scenario will work; you can simply use a second "Operation: Rendezvous" step in the second loop that references the originally created Rendezvous. However, after testing the general Rendezvous approach further, it is not immune to the following corner cases: when a test socket is disabled, errors out, or is terminated (as stated above by James_Grey). Because the "Create Rendezvous" requires a 'Number of Threads Per Rendezvous' expression, the above mentioned scenarios can cause a deadlock (if your Rendezvous does not use a timeout).
The approach mentioned by James_Grey is likely a better approach because Batch Syncronization is more immune to the above stated corner cases. Attached is an example of this approach.
-Jeff