Showing results for 
Search instead for 
Did you mean: 

Controls not being read inside while loop, that is inside an event case

Go to solution

I've encountered a situation with an embedded while loop not functioning as expected once it is placed inside an event case. The Stop and Exit buttons seem disabled. I've tried adding those buttons to the same event case; "Start", but that had no effect.

0 Kudos
Message 1 of 8

Hi Mike,


simple solution: don't place while loops inside event cases!


Event cases should be executed as fast as possible, and so avoid blocking other events...

Best regards,

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 2 of 8

So, the while loop is there to allow an operation reading incoming data from an instrument under test.

The while loop is waiting for settling of the reading with a threshold level of standard deviation.

A timeout or user input of "Stop" are alternate ways out of this loop.

This method is not possible within an event case?  Why not?



0 Kudos
Message 3 of 8
Accepted by topic author MikeMack747

You have the "Lock panel until the event case completes" turned on.  Which means, you press the Start button and you cannot interact with the front panel until the case is done, including the inner loop.


Generally speaking, you should not have "long" things happen inside of an Event Structure, such as loops.  Use another loop or a state machine (the state machine is to include the Event Structure, not inside of the event case) to handle the reactions.

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
Message 4 of 8

How do I unlock the front panel?

0 Kudos
Message 5 of 8

I found it, I went to "Edit Events Handled by this Case" and unchecked the "Lock panel" box.


Thank you Gerd!

0 Kudos
Message 6 of 8

@MikeMack747 wrote:

I found it, I went to "Edit Events Handled by this Case" and unchecked the "Lock panel" box.


Thank you Gerd!

FYI - generally speaking, a well-written LV application doesn't care if the front panel is locked or not because nothing in the event structure will take so long that locking the front panel matters.

(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 8

I agree, this event should trigger and data producing, and a consuming loop operating in parallel to the event.

This is not my code, it came from my coworker who now shall lose a bet 🤑

0 Kudos
Message 8 of 8