09-21-2017 01:44 AM
Hi
I have a sequence which search for connected devices on a network (Ethernet). The found IP addresses are stored in a array. If the array is not empty I jump into a for-loop which loops for the number of found IP addresses.
I this for-loop I jump into my test sequence "MainTest" and pass as reference the IP address and get as reference the Pass/Fail back.
Now, If I configure the sequence call "MainTest" as "Execution Option" - "none" and the "Wait" synchronization as "Wait for:" - "Time Interval" and run the test sequentiell everything works fine. I get the correct report and Pass/Fail at the end.
If I configure now the sequence call "MainTest" as "Execution Option" - "Use New Thread" and the "Wait" synchronization as "Wait for:" - "Thread" and run the test with working UUT's (no fault), the test itself works in parallel. I can set breakpoints wherever I like in the subsequences of "MainTest" I get of all tests a green Pass. Only the test "MainTest" an the wohle test-run shows all the times fail. Also the report contain no details (measurements) of the sequence "MainTest" only "Status Failed".
Why I do get a Fail when all UUT's are working with sequence in "Use New Thread"? Why the details of the "MainTest" does not listed in the report? What do I wrong or do I have to live with that?
Many thanks for help
Peter
Solved! Go to Solution.
09-21-2017 08:34 AM - edited 09-21-2017 08:37 AM
I see two potential problems with what you are doing:
1) You are launching multiple threads in a loop, but only waiting for the last one outside of the loop. Thus you will only really be waiting for the last thread to finish and only getting the result on the wait step for that thread. Instead you need to store references to each thread you are creating in an array of Object References (e.g. Locals.Threads[]). Then, in the advanced section of the sequence call settings you need to tell TestStand to store the thread references in that array with an expression like the following: Locals.Threads[Locals.ForVariable]. Then for the wait step, you will need to put that in its own loop and use the option to wait for a thread by 'object reference' and give it each thread with the expression: Locals.Threads[Locals.ForVariable]. Once you do that you will be waiting for all of the threads and getting all of their results into the report.
2) The second issue is that it's possible what you are doing isn't actually safe to run in multiple threads in parallel (which could be why you are getting failures). If you are sharing instruments for example, one thread could be changing the state of the instrument out from the others. You can use synchronization step types like the Lock step type to define sections of your sequence which require exclusive access to your instrument(s) if needed, though that will reduce the amount of the sequence that's really being run in parallel.
Hope this helps,
-Doug
09-26-2017 08:14 AM
Dear Doug
many thanks for your input! I have tried your solution.
1) Call and wait by reference
- If I put the wait in the same for-loop as the sequence call, I get for each call a pass or fail in the report depends on result. But only the pass /fail of the top sequence MainTest. No result from the subsequences. In this case the calls are sequential and not parallel.
- If I do an extra for-loop (see attached picture), it's like at the beginning. It is parallel, but no report entries and test always fail.
2) I have no hardware connected which is shared. I only make cmd.exe calls which starts different PuTTY plink.exe to do ssh access over Ethernet. So this should not be the problem.
Do you have any other idea what I can try / what I make wrong?
Best regards
Peter
09-26-2017 08:29 AM
Your Wait step needs to have the Result Recording enabled.
09-26-2017 09:05 AM
Dear Ray
that was it!!!! Now I get the report of each UUT in parallel.
Many thanks Ray and Doug for your help.
Peter