LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I create a dialog box with a visible timeout counter?

Solved!
Go to solution

I have a dialog box that may pop up when no one is at the monitor.  I would like to display a countdown timer in the dialog box that lets the operator know that he/she has so many seconds to make a decision before the program moves forward.  Is there a way to make the dialog box update while it is displayed?  Do I have to make this a sub VI or is there an easier way?  Any suggestions?

0 Kudos
Message 1 of 11
(5,681 Views)

Just have a loop and your time indicator inside the loop. Be sure to use a small delay in the loop so you don't make a Greedy Loop .

0 Kudos
Message 2 of 11
(5,649 Views)

Thanks for the response, but I don't think I'm explaining myself very well.

 

The problem is more with the dialog box not updating.  The timer is in a loop and runs in the background but you can't see the timer run while the box is open.  I want the dialog box to say something like: "program will do X in Y seconds if the continue button is not clicked"  I would like the Y to be a number that counts down to zero.

 

Hopefully this clarifies my question a little. 

0 Kudos
Message 3 of 11
(5,641 Views)

It will be easyer to help you if you show us how you have implemented it.

 

Ben64

0 Kudos
Message 4 of 11
(5,637 Views)
Solution
Accepted by topic author NateN

To the best of my knowledge, you won't be able to modify the built in dialog boxes to show a timer.  This may actually be possible but I doubt it's easy.

 

In my opinion, you will have to use a subvi and display the front panel when called.  Arrange the front panel to visually look like the dialog box you want to appear, with a numeric indicator.  Feed the timeout value into the subvi (this will allow you to decide when to exit the while loop).  Use the "Tick Count (ms)" inside and outside the while loop.  The one outside will mark the time at which the subvi was called.  Subtracting the two will give the change in time (how long the subvi has been running in ms).  You can subtract this number from the timeout value, and wire this to the numeric indicator.  This will provide the effect of a countdown.

 

If this value becomes less than zero, exit the while loop.  Likewise, if the operator performs certain tasks, exit the while loop.  On a side note, you can add a button to suspend the countdown.  This will be useful if the operator gets to the screen with 2 seconds left.

 

 

Message 5 of 11
(5,634 Views)

While I was working up a quick example pjr1121 explained how to do it. That means I can just attach the example with no explanation Smiley Happy

=====================
LabVIEW 2012


Message 6 of 11
(5,625 Views)

Steve, watch for the greedy loop! A refresh rate of 250ms will be sufficient in that case.

 

Ben64

Message 7 of 11
(5,619 Views)

Thanks for the help.  I was already marching down the subVI path, I was just hoping for a simpler solution.

0 Kudos
Message 8 of 11
(5,614 Views)

@ben64 wrote:

Steve, watch for the greedy loop! A refresh rate of 250ms will be sufficient in that case.

 

Ben64


Good catch, you are absolutely right! I fully intended to put that in there too. With all these cores and memory and gigahertz I didn't even notice and spaced it.

 

One more thing. This will block the loop it is called from. If that is a problem just put the dialog VI in another loop and use a notifier to execute it.

=====================
LabVIEW 2012


0 Kudos
Message 9 of 11
(5,608 Views)

As an alternative solution, you could put the timer in the button of the dialog box. It is a simpler solution, but I doubt it would serve your purpose. Use a Two/Three Button Dialog.vi and wire the text for the buttons with the button name appended by the timer. So you could have an OK button that says OK (10) when it starts and counts down OK (9), OK (8), ...

 

Just a thought.

Prashanth N
National Instruments
0 Kudos
Message 10 of 11
(5,601 Views)