NI Home > Community > NI Discussion Forums

NI TestStand

Showing results for 
Search instead for 
Do you mean 
Reply
Member
q-bertsuit
Posts: 74
0 Kudos
Accepted Solution

How can you see the progress when using a ForEach loop?

Hi,

 

I have an array with about 100 containers in it. My main thread uses a ForEach loop with an inner case structure with six possibilities. My previous program had all the steps in a very long list, executing them one by one. I find this new approach is much nicer to look at, and easier to change, but there isn't really any way of telling how far along the test is (unless you know it by heart). In the long list approach, you could see all the Done/Passed outcomes and how many remained, now there is no way of telling.

 

Any tips on making some kind of progress indication? 

 

 

Trusted Enthusiast
Norbert_B
Posts: 4,648
0 Kudos

Re: How can you see the progress when using a ForEach loop?

This depends on the UI you are using. NI Sequence Editor and the Full-Featured UIs coming with TestStand include a status bar. On the right side, there is a pane for "Progress Indication". This is e.g. used in the process of generation of the report (standard NI Process Models).

 

You can send a progress information using UIMsg_ProgressPercent. Just send the loop count divided by the maximum number of loops multiplied by 100 (so you get the % of the actual iteration). You will send this information using PostUIMessageEx at the beginning or end of your iteration. This function is part of the TestStand API and is supplied by the Thread class.

 

hope this helps,

Norbert

 

PS: My hint regarding the value to send presumes that the sequence contains the loop only. If you add stuff in front or after it, you might want to recalculate the % value...

----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Member
q-bertsuit
Posts: 74
0 Kudos

Re: How can you see the progress when using a ForEach loop?

Thank you for your answer.

 

I haven't really played with the API before. I tried adding a function at the end of my loop and inserting this " ThisContext.RunState.Thread.PostUIMessageEx(UIMsg_ProgressPercent, ThisContext.RunState.NumStepsExecuted, "", "", 0) "

 

Just to see if it works. What values should I give the last three parameters?

 

I couldn't find the "Progress Indication" pane, maybe I don't have this feature.

 

Thanks again!

Trusted Enthusiast
Norbert_B
Posts: 4,648

Re: How can you see the progress when using a ForEach loop?

As ObjectReference parameter, you should use 'Nothing'. The last parameter (synchronuous?) you can choose true or false. Please refer to the documentation of PostUIMessageEx for further information.

 

The numeric parameter should range between 0-100. Since it is "Progress Percent", this makes sense, does it? :smileywink:

 

The status bar has several panes, one e.g. displaying the logged in user or the used process model. The pane on the right most side will display the Progress Percent if used in your sequence.

The default reporting, as already stated, includes this feature. So if you have a sequence with e.g. 500 steps, the reporting "will have a visible progress" in that pane (with less than 100 steps, it is most often too fast to see). Remember that NI Sequence Editor and the Full Featured User Interfaces do have this feature, the Simple UI does not have it.

 

Norbert

----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Member
q-bertsuit
Posts: 74
0 Kudos

Re: How can you see the progress when using a ForEach loop?

Thanks, I got it working now! Cheers :smileyhappy:

Member
q-bertsuit
Posts: 74
0 Kudos

Re: How can you see the progress when using a ForEach loop?

I got it working now! Thanks alot :smileyhappy: