10-17-2023 09:04 AM
Hello,
I had a general question about the "wait" function. If I have a case structure or while loop within another while loop, how can you make the "wait" only apply to the sub-loop, rather than making the entire loop wait? I know there is probably a super easy solution, but I can not figure it out. I have been using an "elapsed time" function to solve this problem.
10-17-2023 10:04 AM
I would not recommend using loops within loops. Use a state machine instead. You can place the wait function inside a certain case with the state machine.
10-17-2023 10:22 AM
@Dfturner42 wrote:
Hello,
I had a general question about the "wait" function. If I have a case structure or while loop within another while loop, how can you make the "wait" only apply to the sub-loop, rather than making the entire loop wait? I know there is probably a super easy solution, but I can not figure it out. I have been using an "elapsed time" function to solve this problem.
You can't. You're using the wrong design. What are you trying to do?
10-17-2023 10:56 AM
@Dfturner42 wrote:
I have been using an "elapsed time" function to solve this problem.
You can use that to "wait for" (check if time is passed) a time (aka polling), but not to "wait" (stall execution).
Structures (well, more accurately structure frames) will wait until everything executing in it is done. Always...
10-17-2023 02:23 PM
@Dfturner42 wrote:
If I have a case structure or while loop within another while loop, how can you make the "wait" only apply to the sub-loop, rather than making the entire loop wait?
Remember the Three Laws of Data Flow. The Second Law says a structure runs until everything inside it has run. So the Wait in the sub-loop means that the sub-loop "waits" as instructed. Anything that contains this sub-loop also has to wait, as it is also obeying the same Second Law, and cannot exit until its inner loop (with the Wait function) finishes.
Note that any other structure that does not "depend" on the inner "Loop With a Wait" is free to run (in parallel) as a result of the Third Law, but that's another lesson.
Bob Schor
10-18-2023 02:57 AM
@Bob_Schor wrote:
@Dfturner42 wrote:
If I have a case structure or while loop within another while loop, how can you make the "wait" only apply to the sub-loop, rather than making the entire loop wait?
Remember the Three Laws of Data Flow. The Second Law says a structure runs until everything inside it has run.
Sorry, but no!
It's nitpicky, but formally not correct. A structure frame runs until everything inside it has run!
Flat sequences are structures too...
10-18-2023 07:34 AM
Until I read the Spoiler, I didn't realize the subtlety of your "nitpicking". You are, of course, correct, though I (personally) view Frame Sequences as "sequential structures" (Frames) (my bad!), and something to be avoided (except for FPGA code).
Bob Schor
10-18-2023 08:36 AM
@Bob_Schor wrote:
Until I read the Spoiler, I didn't realize the subtlety of your "nitpicking". You are, of course, correct, though I (personally) view Frame Sequences as "sequential structures" (Frames) (my bad!), and something to be avoided (except for FPGA code).
Bob Schor
I agree, but they're still structures!
In general there's very little you can say about anything in LabVIEW without any reservation.
10-18-2023 08:51 AM
If you see a Flat sequence as an array of structures it still holds. 🙂
10-18-2023 09:50 AM
@Yamaeda wrote:
If you see a Flat sequence as an array of structures it still holds. 🙂
Sure.
To be fair, even in LV's class structure a flat sequence isn't a structure (or even a node, until you ask for nodes, and they are still returned in an array of nodes 😲).
The norm is to consider a flat sequence as a (single) structure.