Jump to content

using timer to exit


kodon1

Recommended Posts

Hi,

 

I have a task which I'm struggling to complete.

I have a GUI with a 'Cancel' button which causes to GUI to close.

 

I want to add a functionality where the GUI will also be closed if after 30 sec automatically.

 

I thought that the right programming approach is to force a press on 'Cancel' button from within the code.

I used the val(sgnl) property but it didn't work well - it just pressed on the button regardless what was the input T or F to the property.

 

I tried to use an event with some dummy indicator that should operate the event upon value change, but it also didn't work...

 

I implemented the timer inside a for loop, which also might be wrong.

 

anyhow, I'd be happy to get a couple of suggestions how to make it work.

 

thanks

Link to comment

Hi Ned,

 

thanks for the reply.

Just to add a little more details...

 

how will this event be called? can I attach an event to a timer?

I mean what will invoke this event?

 

also - there are other activities that take place in the GUI - there is also an OK button which under some conditions can also

close the GUI, and if OK is pressed it should restart the timer to 30 sec again.

 

with that additional information, could this solution still hold?

 

thanks

Link to comment

The easiest way is as ned said, shown in the top image.

 

post-7534-0-93429500-1420628211.png

 

If you can't use a 30-second timeout because you need to handle other things during those 30 seconds, the lower loop will evaluate whether 30 seconds has elapsed every 0.025 seconds.  You'll need to pass the "reset timer' command back into the Timeout event using a Shift Register.

 

Maybe post your VI?

 

Are you really using LabVIEW 2015?

Link to comment

Hi jcarmody,

 

tx for your reply.

 

I'll try to put a snap of the subVI for a better description.

 

I'll try to use your suggestion and see what comes out of it. 

 

If I didn't mention before, I already have an event that controls the 2 other buttons in the vi. so I think that I can just add another one...

I'll post it here in a few hours.

 

thanks

Link to comment

If I didn't mention before, I already have an event that controls the 2 other buttons in the vi. so I think that I can just add another one...

It is generally best to have only one event structure in a VI.  It isn't required by any means but having multiple event structures can make understanding the code more difficult, and can make bugs if certain behavior isn't avoided.  Once you code is posted it should be no problem describing the best approach.

Link to comment

It is generally best to have only one event structure in a VI. [...]

 

Just to be clear, I showed two Event structures just to show the two approaches.  Pick whichever one suits your application, although it sounds like the upper one isn't applicable with the other events you need to handle.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.