From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with VI containing 2 event structures

Hello,

 

I am having trouble with a VI i have made.

The VI contains two event structures that will run one after the other.

I am using first event structure to set a controls position on the front panel on the Pane Mouse Down event.

When all controls have placed the For Loop exits and the VI moves onto the While Loop.

I am using the second event structure to launch a sub VI when a mouse down event is detected on one of the controls placed in the first loop.

 

The problem that i am seeing is a mouse down event is detected once but then not again?

 

If i run the While Loop part of the code on its own by placing the For loop in a disabled structure then it works as I expect.

 

Can anyone tell me what I am doing wrong?

 

Thanks for your time,

 

Iain 

 

0 Kudos
Message 1 of 4
(2,064 Views)

Read Caveats and Recommendations when Using Events in LabVIEW - LabVIEW 2016 Help.

 

Having multiple event structures in a VI is almost always a bad idea unless you know what you are doing.

You have events that are set to lock the front panel until the event completes.  But your first event structure can never be reached again to handle events once you completed the first part of your code.

 

Reorganize your VI architecture so there is only 1 loop and 1 event structure.  A state machine architecture is what I'm seeing in your future.

 

It also seems like you have event cases not assigned to anything, where the some of the items in the selector at the top are blank.  But that might be an artifact that when I imported your VI snippet, it was looking for subVI's that I don't' have.

Message 2 of 4
(2,046 Views)

Hello RavensFan,

 

thanks for replying!

I have taken your advice and dumped everything into a state machine......

everything is now running as expected although i now have a load of case structures but hey-ho.

 

I only ever intended the For Loop to run once when the VI was first run to configure where the user wanted to place his/her controls then write the position data to a file.

 

I would quite like to know/find out why what i was attempting didn't work!

0 Kudos
Message 3 of 4
(1,996 Views)

I don't completely understand what you were trying to do, so I can't explain the exact cause of your problem.  Especially since there were some event cases that weren't connected to a control.  I'd suggest you run your original code with highlight execution turned on and watch how the data flows.

 

What I do know is that in your original code, you had key down events registered, and set to lock the front panel.  So when it got past that part of the VI, any later press of a key would trigger an event and lock the front panel, but you could never get back to the first event to handle the event and thus unlock the front panel.  So I would expect your VI would seem to lock up hard.  However, you didn't seem to describe that situation.

0 Kudos
Message 4 of 4
(1,991 Views)