NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get my Teststand report to only show the step data for the last iteration of a DoWhile loop ONLY?

Solved!
Go to solution

Okay so I have a DoWhile loop with one numeric value test.  The loop will run 10 times.  I only want the pass/fail status of the numeric value test from the last iteration of the loop to show up in the report.  I don't care about the other iterations.  Please help!  Thanks in advance 😄  I think this can be accomplished with the ModifyReportEntry callback and some fancy logic...

0 Kudos
Message 1 of 13
(8,294 Views)

Try PreviousStep.Result.Status to obtain the result at the end of while loop and print it to report. Can also try with NameOf() property, I suppose havent tried.

 

*************************************************
CLD
*************************************************
0 Kudos
Message 2 of 13
(8,286 Views)

No, that won't really help.  I need a way to only record the very last iteration.  I don't want to have previous iteration data show up in the report.  Because the step name and comment of step will not change per iteration, there has to be a way to delete the undesired "extra" containers from the Locals.ResultList that were generated during the looping.

0 Kudos
Message 3 of 13
(8,282 Views)

Have you tried SequenceFilePostResultListEntry to filter results.

 

Add this callback and then have an If statement that searches for the name(s) of the steps you want to filter.  Set the parameter "DiscardResult" to true.  The tricky part will be getting your loop counter...  Also, this will probably only work for a non-deterministic loop (which you said it runs 10 times).

0 Kudos
Message 4 of 13
(8,279 Views)

Yes, that is what I am trying now...using that callback and trying to find some logic to identify when the last iteration of a loop is and delete from the result list all other data containers but the last from the loop.  It is tricky...this feels like a lot of people would like to have this option NI should make it a loop property option to only record data from last loop iteration 🙂

0 Kudos
Message 5 of 13
(8,272 Views)

If you know the loop count then why would you ever need to use callbacks?  Just loop 1 less times with the step set to not record.  Then make a copy of the step outside the loop and call it once more with setting to record.

 

Seems simple.

 

However, I believe you aren't really giving us enough information to help you-

 

Why can't you use the Looping that is built into the step?  This allows you to just record the last iteration.

Will the while loop terminate of a condition is met?  If so then the number of loops is undetermined at edit time.  In which case you will have to do a different algorithm.

Can you describe what will cause the loop to terminate.  There may be a better solution.  Also, do you have more than just one step inside the While loop?

 

Regards,

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

It would be simple if you always had a set iteration count.  I am sorry I did not give a better description, I am new to the forum and was just describing a general case.  What do you mean by"Why can't you use the Looping that is built into the step?  This allows you to just record the last iteration."  Is there a place to select this?  I can't find it...

 

I want to be able to record only the last set of data from every test step in a loop regardless of what loop I choose to use.  I want some kind of algorithm that is robust enough to handle this.  Was thinking I could just identify in the result list when the same step name comes up and see which one has a higher index in the result list array then delete the one with the lower index.  That would work in theory as long as I dont use the same step name anywhere else in my main sequence.

0 Kudos
Message 7 of 13
(8,266 Views)

Here is my thoughts.

 

Right after you exit the loop add a Statement Step:

 

In this statement, you could then delete entries from the Locals.ResultList[ ] based on some condition.  Assuming you have a COUNT of the # of times you went through the loop, and make sure you are ONLY recording the Numeric Limit step in the loop.  That is remove the Record Results on the While, Do, and End statements, or any other statements you don't want in the report.

 

1.) Get Current Size of Locals.ResultList[].  So if you had 20 entries and you ran through the loop 5 times. You would want to remove entries 18,17,16,15.  Entry 19 is the ONE you want to keep!  Again I assume that is the last entry you captured, is the one you want.

 

2.) Delete Entries from Locals.ResultList.  Size is <# of Loops - 1 >, the starting index would be 15.

  You would want to delete 4 entries, starting at Entry 15.  Use the Array functions to accomplish this.

 

The above logic is not verified.... Good luck!

 

PH

 

 

0 Kudos
Message 8 of 13
(8,258 Views)

Turn of Record Results for the desired step at edit-time.

 

At run-time, use an Statement step immediately before it to turn on reporting for the desired step on the last iteration of the loop (assuming you aren't using the data from the step to determine the exit condition of the loop.)

 

Be aware that turning on reporting will persist to edit-time so you'll need to disable it after it gets enable or the next time you run the step will record results on every iteration.

CTA, CLA, MTFBWY
0 Kudos
Message 9 of 13
(8,254 Views)
Solution
Accepted by topic author queenlooners

Thanks for your feedback everyone.  I ended up modifying the reportgen_txt.seq to identify when my test step was in a loop (by setting an additional result in the individual steps of my loop-step comment to say "Record Last of Loop.".  Once this flag is found in the ResultList I pass to reportgen_txt, I loop through all the ResultList entries and if the current entry has the same name and the "Record Last of Loop." as a previous entry, I delete the previous entry and store the current.  This way all I have to do is set a flag in my test sequence and if, when debugging, I want to see all data for all iterations, I just remove the flag.

 

The reportgen_txt.seq is found:

C:\Program Files\National Instruments\TestStand 2010\Components\Models\TestStandModels

 

I am not worried about time constants on my report generation and I am not limited to a strict memory constraint so this seemed the best way for me to get what I needed accomplished.  I'm sure there are better ways but this seemed simpler than setting report gen to be disabled then enabled...

Message 10 of 13
(8,220 Views)