LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I register for the timeout Event dynamically

Solved!
Go to solution

hello,

 

I found this example:

http://zone.ni.com/reference/en-XX/help/371361K-01/lvhowto/dynamic_modifying_reg/

 

I want to do the same thing, except that it's not the mouse move event that I want to toggle (register/unregister) but the timeout event.

 

The timeout is in the drop down list of events I can register for, but it is greyed out.

 

How can I do this?

 

thanks

0 Kudos
Message 1 of 18
(3,887 Views)

Use a shift register to hold what your timeout should be.  Use -1 for never time out.  Wire the value in the shift register to the timeout input on the Event Structure.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 18
(3,885 Views)

I was able for forceably change the dynamic event registration to "Timeout" despite being grayed out, but the code didn't work.  The timeout event never occurs.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 3 of 18
(3,851 Views)

That doesn't work.

 

When I set the value to -1, the event runs into a dead lock, because the shift register cannot be updated without a running loop, but in order to run the loop, the shift register has to change the value.

 

I have two buttons to start/stop the timeout.

Two numeric outputs to display the current timeout time and the loop iterations (to check if the timeout is running).

 

timeout event dead lock.png

 

Why is this so complicated?

Why is it not possible to register for the timeout dynamically like other events?

Why is the timeout listed in the drop down list but greyed out?

0 Kudos
Message 4 of 18
(3,790 Views)

You are probably creating your own deadlock here...

 

Here is a small piece of code that works just fine for setting dynamically the timeout like crossrulz mentioned.

 

Dyn Timeout.png

 

Regards,

Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.

Message 5 of 18
(3,781 Views)

Eric, thanks for trying to help me.

Please take a look at the image in my previous post.

The timeout event structure is in its own loop.

 

I'm not interested in a solution that has both timeout and other events within the same loop.

They should run in parallel.

 

 

0 Kudos
Message 6 of 18
(3,765 Views)

@max_ wrote:

Eric, thanks for trying to help me.

Please take a look at the image in my previous post.

The timeout event structure is in its own loop.

 

I'm not interested in a solution that has both timeout and other events within the same loop.

They should run in parallel.

 

 


Sorrry, it is a solution, and not even a bad one 🙂

I would request your single timeout event,  if you (just) need a timed structure, use a timed structure !

 

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 7 of 18
(3,753 Views)

I'm sorry I had not seen the 2nd loop. Then what you have is a design issue. We traditionnally avoid using several event structures in parallel loops unless they properly handshake, and registering/unregistering events is certainly not a proper handshake 🙂

 

You will probably be better off using a queue communication with a selectable timeout on the Dequeue function. This will allow you to execute code based on messages sent from your "UI" event structure. And you will be able to send data with this instead of using variables.

If you can explain more what you're trying to do I could give you a more thorough insight.

 

--Eric

Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.

0 Kudos
Message 8 of 18
(3,741 Views)

and registering/unregistering events is certainly not a proper handshake

 

Why is this not a proper way to do it?

I followed a tutorial from NI as you can see in the first post. Now I'm trying to apply that tutorial and suddenly it's not proper.

I chose this design because it'S pretty much exactly the same as in the tutorial.

I want to have a timeout running under certain conditions and not under others.

0 Kudos
Message 9 of 18
(3,734 Views)

Use a User Event to send the new timeout time (either -1 to "unregister" or some other value to "register") from the first loop to the second loop, as shown below. I still have no idea why you would want to do this, but it will work fine.

 

Send Timeout through User Event.png

 

 

Message 10 of 18
(3,727 Views)