LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While Loop in Event Structure

Hi, 

when using while loop in Event structure. the front panel is Locked . can anyone help me.Capture 1.PNG

0 Kudos
Message 1 of 9
(2,549 Views)

Probably because you have the "Lock front panel until event case completes" selected (default).  This one of the reasons we state that "long" loops don't belong in event cases.  Maybe a state machine is what you need.


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 9
(2,527 Views)

So do not put a While loop in an Event structure (for exactly the reason you found out).  You also included a picture (which I can't see clearly, but know that a framed sequence changing variables I can't decipher makes no sense, especially since it is "unclocked").

 

Perhaps if you had attached the entire VI as a VI (so we could really look at it, and perhaps suggest how you could accomplish what you are trying to do), we could be more helpful.

 

What you probably need to do is to use the Event case to trigger an external VI to run, one that contains the silly Frame Sequence (though a For Loop enclosing a Case Structure, perhaps with a Wait inside, seems potentially safer).  How to trigger it?  Well, how about a Notifier?

 

Bob Schor

0 Kudos
Message 3 of 9
(2,524 Views)

As others have said, you need to learn about code arcitecture and best practices. Yes, un-checking "lock front panel until event completes" will solve the panel locking, but will probably make other things even worse. What is your programming background? It is mostly in text based languages?

 

I assume you are a relatively new and inexperienced programmer, so it would seem important to learn the basics before learning more bad habits. Sequence structures should be replaced by state machines. Nobody should ever need greedy loops that spin millions of times per second consuming all CPU just to poll a network shared variable.

 

Can you tell us a little more about this project? What are the shared variables used for? What other code/hardware is also accessing them? What are your timing requirements?

0 Kudos
Message 4 of 9
(2,504 Views)

Hi,

Thank you 

You find below the vi, can anyone help me how to solve this probleme.

Best Regard.

 

0 Kudos
Message 5 of 9
(2,489 Views)

Explain what the program is supposed to do. How does the user interact with it? What is supposed to happen? What other hardware interacts with the network shared variables and how?

0 Kudos
Message 6 of 9
(2,483 Views)

Please attach it as a zip file so that people who want to help you aren't forced to install other programs to handle more uncommon formats like .rar.

 

ZIP is built into Windows.

0 Kudos
Message 7 of 9
(2,475 Views)

Here are some ideas. Basically, value changes sets state and enables the timeout where polling occurs until the condition is met. Then the state goes back to idle and resets the shared variables.

 

This is just a very rough draft and I probably mixed up some shared variables, but it still should give you the right ideas.

0 Kudos
Message 8 of 9
(2,467 Views)

it is typically easier to test code using a simulated device and local variables instead of shared variables. Here's a quick demo. Maybe this can give you some ideas.

 

Note that the code is never stuck in a lengthy loop and state can be changed at any time, even if it is in the middle of doing something.

 

 

 

0 Kudos
Message 9 of 9
(2,459 Views)