LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using nested Event Structures

Hi ,
I wanna clarify whether using nested event structures in a vi is good Labview programming ?
I have a vi which has two event structures nested,assuming it has two buttons GO1 and GO2.
The outer event structure handles event triggered by GO1 and inner event structure handles Go2.
The outer structure does fine by handling the button click on GO1,the problem is inability of inner
event structure to handle click on GO2 button.
I'm also attaching a sample.vi for reference.It would be great if you could help me
solve this issue.Thanks in advance.

Regards,
Nalin
0 Kudos
Message 1 of 5
(4,111 Views)
Hi Nalin

Never - really NEVER nest event structures. The inner structures will never be handled. I can't look at your vi but if you configure your event structure to handle the event fired by your GO1 this would work. But if you have a nested event structure, you first would have to configure an event which than waits until the nested structure is handled.

One event structure can handle several events. So you could set one event structure (which has to be placed in a while-loop) to catch the events fired by both of your buttons.

There is another thread discussing event structures. Just have a look at it.

Hope this helps.

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 2 of 5
(4,099 Views)
You should not use two event stuctures in 1 vi. or an event structure inside another event stucture, not only is it bad programming lots of times it will not perform the way you think it is going to. If you only have two buttons like you mention above then there is no need to have 2 event str. just use 1 and have an event for each. you can do this by right clicking on the event structure and selecting ad event case. If you need more help with this please be more specific as to what you want and i will help you.



Joe.
"NOTHING IS EVER EASY"
Message 3 of 5
(4,098 Views)
You can actually make this work, but like the others, I don't recommend it.

To make your VI work. Right click on the "GO1" structure and select "Edit Events.....". At the bottom of the dialog, there is a checkbox that reads "Lock Front Panel until the event case for this event completes". With this checked, all front panel objects are locked until the GO1 event completes. This is what is causing the GO2 button not to work. Uncheck this and your application will work as you want it to.

If your intent is to have GO2 disabled until you click GO1, try the attached VI. It uses property nodes to disable the GO2 button until you click the GO1.

Another thing that you have setup that doesn't look necessary is the Timeout event, especially set to 1ms. The basic idea of the Event Structure is to not have to constantly poll for front panel events. If you just deleted the timeout event cases and removed the 1ms constant, your application would just well, but would just sit and wait for you to click a button.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 4 of 5
(4,087 Views)
Thank you all for the help.
It helped me clear regarding nesting event structures.
Thanks once again.

Nalin
0 Kudos
Message 5 of 5
(4,060 Views)