NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Customizing OI to add step progress bar

Hello custom RTOI experts!  I am attempting to make a customization to the full-featured LabVIEW RTOI (for TestStand 3.0) in order to provide the seemingly simple feature of a step completion progress bar on the execution page of the tab control.  Let me explain a little behind the concept I'm going for.  There are some steps in my sequences that take a relatively long time (15 minutes or so).  During this period, a requirement of mine is to have a progress bar that gets updates every so often such that by the time the step would ordinary complete, the progress bar is at 100%.  Initial attempts involved a separate VI that managed the progress bars, but having yet another window is not the ideal UI design...  Instead, I was hoping to integrate this functionality into the RTOI so that each time a new step begins executing, additional custom data (the expected step duration) is (optionally) sent to the RTOI providing the progress update portion of the RTOI code the necessary data.
 
Is there any sample code out there that performs some similar task so that I can get a better feel for how the pieces fit together?  In particular, there are a few things that are befuddling me:
 
1) What is a good way to store this custom information (step duration) in the sequence file?  Should I modify the basic step types to add a new duration field which can be optionally set to something greater than the default, 0?
2) How should the step duration get passed to the RTOI?  My current thought is to override the PreStep engine callback to send the custom duration field in a custom UIMessage, but that may be partly because I'm not familiar enough with the structure of the data is that is that is accessible via the sequence context...
3) How do I link the progress bar data to the actual execution page that is currently being viewed.  Up to 4 executions can be running using the parallel model or the batch model in my sequences, so something would clearly need to be done so that when execution 1 is visible, the associated progress bar is shown, etc...  I'm assuming I can trap on some event when the user clicks on an execution in the list bar, but there is no similar code in the out-of-box RTOI - all that appears to be managed automatically by linking the controls to the execution manager.
 
Thanks for any pointers or code samples (or even suggested reading) that anyone can give.
0 Kudos
Message 1 of 8
(5,917 Views)
Rob,

you already answered your question in your post!
The solution is: UIMessage.
To use this technique, you have to call "PostUIMessageEx" from the thread-class from the TestStand API. Here is the eventcode, you should use:
UIMsg_ProgressPercent–(Value: 11) TestStand step modules post this message to the user interface to notify it to update its progress indicator associated with an execution.
Since TestStand has no chance to know, how much % of your application/step/sequence is already finished, you have to post this message on your own. If you pass 0 as numeric value with this posting, you can see "0%" if you use an OI with a progressbar (full featured and Sequence Editor); if you pass 50 as numeric value, the progressbar will be half-filled.
So everytime you want to change the progress, you will have to call the PostUIMessageEx-command with eventcode ProgressPercent with the appropriate value..... You can do this from codemodules as well. But take care that you have access to the "thread"-class within your modul (maybe by passing the SequenceContext!).

hope this helps,
Norbert B.

Message Edited by Norbert B on 08-28-2007 08:32 AM

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 2 of 8
(5,900 Views)
Thanks for the response.
I may indeed want to use the ProgressPercent message, but I'm not so sure just yet.  I did not want to leave the responsibility of sending UIMessages up to the VIs and other code modules called by the sequence - I was hoping for a simple solution to provide a new field (ExpectedDuration) that can be set for any given step.  In this way, the RTOI can manage updating the progress simply by counting seconds.  Perhaps there is some timer callback that can be leveraged to perform this function?
 
What I have so far is as follows: I have a new step type called PassFailTestWithDuration.  It is a copy of the PassFailTest step type with the addition of a ExpectedDuration property and a new PreStep which calls the PostUIMessageEx with a custom event (10001).  The expected duration and the RunState.TestSockets.MyIndex both get passed as parameters.  Inside the RTOI, I have added a UserMessage callback VI which stores the data in the appropriate slot of a global (indexed by socket index).  (The global array is implemented as what I've heard called an action engine - there are init, read, and write actions that it can perform on data stored in the VI, and it is set as non-reentrant so that race conditions cannot occur).  Each entry in the global array has 2 fields - the expected duration, and the current elapsed time.  My idea was to continually update the current elapsed time for all active executions and simply show a progress bar for the "active" execution by displaying its elapsed time/expected duration in each necessary event...
 
I think my main question now is - how do you determine the RunState.TestSocket.MyIndex of the active execution in the execution manager (or application manager)?  It seems like such an obvious thing to want to know, but I don't see it anywhere.
 
Thanks again for any hints you can provide!
0 Kudos
Message 3 of 8
(5,881 Views)
Rob,

i have to point out one major disadvantage from your approach:
Since the "update" of the percentage-done is done by a different process than the actual execution, the percentage-done could be way off the real %.....

Nevertheless, you can of course do something like this. Each step can send an UIMessage as either PreSubstep (within a module, which can be shared by many different steptypes if designed in a clever way) or by a PreExpression (TS 4.x and above).
Since you already made your first experience with custom UIMessages, you can just continue to improve your approach. I dont know what parameter of PostUIMessageEx you are currently using, but you can send more than one parameter at once (depends on the "receiver"). So maybe you want to pass the TestSocket-index (since i believe you need this only for display-reasons) as string and the expected time as numeric value. Or you pass the SequenceContext as ActiveX-param and then retrieve the variables you are interested in in the receiver by using "get property value".

hope this helps,
Norbert
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 8
(5,865 Views)

Thanks again for the feedback.  Regarding the lack of accuracy inherent in this design, I think I can deal with this.  The purpose behind this whole exercise is just to provide the user some indication that something is going on, and that it'll probably take about "x" amount of time (and "y" is how many seconds have elapsed since the step began).  Many of the tests that prompted this mod are very well defined.  (So we know within a few seconds how long they will take before they even start.)

Anyway, out of curiosity, could you elaborate on your note about sharing substeps amongst step types?  I have begun implementing this using a PreStep action to send off the UIMessage - but if there is a way to implement this once and have all the necessary step types inherit this code, that would be ideal.  I am running TestStand 3.0, so if there is some new step type inheritence feature in a  newer version I may not be able to leverage it.

Thanks,

Rob

0 Kudos
Message 5 of 8
(5,856 Views)
Rob,

currently, you have two parameters you want to pass to UI per step. These are always the same, independend of the steptype.
So i would create one module which takes those parameters and then either create an UIMessage for each parameter or, as already said, pass them in one UIMessage. This mainly depends on (maybe) future expansions of your applications where you can e.g. pass 20+ parameters....
If you have defined (and implemented) an appropriate module, you can then insert that module in every kind of step you want (new steptype-definitions!) as Prestep-Substep. There you have to decide what the parameters shoulod look like (e.g. local variable vs. static value). Just select the parameters in a way that suits to your current steptype. And there you go: one quite "all-round-functionality" for UI-updates in your application.

hope this helps,
Norbert
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 8
(5,852 Views)
Oh, I see what you mean.  I thought you were saying that there was some way to implement this without adding a PreStep substep to every step type necessary.  In any case, it doesn't matter much.  I don't even think I will bother creating a separate module to handle sending the message - I will just make the PreStep itself a call to the PostUIMessageEx function using the ActiveX adapter.  (I am btw just sending both peices of info in one message and boxing one in the string field.)  Now I just need to figure out a good way implement a timer callback for updating the elapsed time each second, but this is a question for the LabVIEW forum...  Thanks for the pointers, - Rob
0 Kudos
Message 7 of 8
(5,843 Views)

Check out these Developer Zone Examples for using UIMessages to realize a progress bar in an Asyncronous Panel/Form during TestStand execution. These examples include the code/concepts that we recommend using to modify an Operator Interface to include modifications such as progress bars.

 

Developer Zone Example: Launching a Floating LabVIEW Panel in TestStand

Developer Zone Example: Launching a Floating .NET Form in TestStand

Developer Zone Example: Launching a Floating CVI User Interface in TestStand 

 



Evan Prothro
RF Systems Engineer | NI

Message 8 of 8
(5,283 Views)