05-16-2020 08:31 AM
Hi,
when using while loop in Event structure. the front panel is Locked . can anyone help me.
05-16-2020 09:30 AM
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.
05-16-2020 09:34 AM
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
05-16-2020 10:50 AM - edited 05-16-2020 11:13 AM
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?
05-16-2020 11:43 AM
Hi,
Thank you
You find below the vi, can anyone help me how to solve this probleme.
Best Regard.
05-16-2020 11:52 AM
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?
05-16-2020 12:08 PM
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.
05-16-2020 12:39 PM
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.
05-16-2020 01:33 PM - edited 05-16-2020 01:34 PM
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.