NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I see the While loop iteration count in TestStand?

I have a sequence I am developing that has a While loop. I have other conditions in a Statement that can stop the While loop. However if neither of those conditions ever occur I want to stop the loop after a TBD number of iterations. I know I can assign a variable and check the count of it incrementing it every time the loop iterates. However I am sure that TestStand is keeping count of the times it iterates on its own. I cannot seem to find where that counter is. Does anyone know how I would access the While loop iteration counter in TestStand? Thanks in advance for any help.

0 Kudos
Message 1 of 6
(6,380 Views)

Why would it need to keep track of iteration count if you don't tell it to? Just populate a Local and use that or alternatively use a For loop with a custom condition.

0 Kudos
Message 2 of 6
(6,379 Views)

That is what I am doing. I just thought that with everything else it keeps track of, without being told too, it would track this for some reason I am not thinking of.

0 Kudos
Message 3 of 6
(6,377 Views)

So one more thing to add. I would like only the last iteration of the while loop to be reported. I have it structured so the while loop will stop on a pass or an iteration limit. Is there a way that I can have TestStand ignore previous failed iterations and just report the last which is a pass? The only other way I can think to do this is to take my VIs and combine them into one VI and loop on that until it passes not reporting on every iteration. I have found the RunState.SequenceFailed variable that I can set to false at the beginning of the iteration but the previous failed steps are still in the report. Thanks again for any insight into this problem.

0 Kudos
Message 4 of 6
(6,374 Views)

I did double-check the TS container for a While step (it's a hidden property which holds configuration information for the step) and there isn't a hidden iteration counter. If you want concise visibility, maybe switching to a For loop would help?

 

As for reporting, you can have the step(s) set to always report and then programmatically remove entries from Locals.ResultList as necessary (or maybe clone it before entering the loop and then replace it as appropriate. If that's too much hassle, set the steps to not report and then on the last iteration change the property programmatically.

0 Kudos
Message 5 of 6
(6,371 Views)

asbo - Thanks for looking into this. I did see the hidden property for the While loop and saw the configuration properties. I did not see the counter either that is why I made the post. That is now fixed by just iterating and checking a variable count.

 

I like what you have posted about reporting. I will look into that as well. Another way to do this, because I like small modular VIs, is to take those steps and make them into a sub-sequence with looping enabled. From there I can choose to report every iteration or not. Thanks again for your help.

0 Kudos
Message 6 of 6
(6,369 Views)