LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2 Event Structures handling the same event

Hello,

 

There is something I don't understand about event structures, and hope someone will answer my question:

 

Look at the attached file "Untitled5.vi" (LV2012).

 

There are 2 event structures that handle the same event, one in case "0", and the other in case "1".

Although the event structure in case "1" is never used it locks the front panel after triggering an event.

You can play with the constant in case "1" to disable/enable the event structure, and see the difference.

 

What is going on there?

 

Thank you,

Amir.

 

 

 

 

 

 

 

 

0 Kudos
Message 1 of 5
(2,675 Views)

Amir_Y wrote:

There are 2 event structures that handle the same event, one in case "0", and the other in case "1".

Although the event structure in case "1" is never used it locks the front panel after triggering an event.

You can play with the constant in case "1" to disable/enable the event structure, and see the difference.

 

What is going on there?


This is one of those reasons we say not to have multiple event structures in a VI.

 

What is happening in your case is the "Lock panel until event case completes" is set.  So as soon as the button is pressed, then event is triggered.  Each event structure has it's own event queue.  So each one can respond to it separately.  But since your case 1 can't be reached, it will never handle the event.  Going back to that setting earlier, the panel will be locked until the event case is complete.  If the event case is never even ran, then the panel will be forever locked.  Very common problem.


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
0 Kudos
Message 2 of 5
(2,665 Views)

It's also important to understand that static events are registered when the VI they're in goes into run mode (meaning not that it's actually running, but that it's not idle). From that point on, their queue will accept events when they occur. Dynamically registered events start enqueuing when the register for event node is executed.

 

I wouldn't say that two event structures in a single VI are necessarily bad, but it can be tricky, so you have to know what you're doing. Jack Dunaway's presentation on events from NIWeek 2013 is highly recommended for understanding many of the finer details of how events work. The details for downloading it can be found here - http://lavag.org/topic/17040-niweek-2013-videos/


___________________
Try to take over the world!
Message 3 of 5
(2,574 Views)

Multiple event structures in the same VI, even listening for the same event, are perfectly fine and often useful (example).

 

You simply need to make sure all event structures are ready to fire at all times. Don't hide them inside case structures or have them contain interactive code.

 

See also my old comment here or here.

 

 

Message 4 of 5
(2,551 Views)

Christian,

 

     Having multiple Event loops all stopping on the same Stop button is ingenious!  I will often wire a Stop to a While loop that I need to stop, and use a Stop Event to stop the Event loop, but hadn't taken "the next step" ...

0 Kudos
Message 5 of 5
(2,541 Views)