LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

wait function and while loop

A case structure inside a while loop is excuting a wait function. Another code is inside the while loop (but outside the case structure) executing another algortihm. How can I have the code outside the case structure to keep running even if the wait function is executing? Right now, everything stops when the wait function is on.

 

0 Kudos
Message 1 of 8
(3,626 Views)

Data flow dictates that a loop cannot iterate until EVERYTHING in it has completed.  So if you really want these to run in parallel, then they need to be in seperate loops.  This also opens up the issue of how these loops are to communicate with each other (Action Engine, queueu, notifier, global variables, User Events, etc).


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 8
(3,615 Views)

LabVIEW operations follow dataflow rules.

 

If the code that you want to operate at the same time as the case structure doesn't require any data from the case structure AND doesn't supply data to the case structure, then it will operate at the same time (parallel).

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 3 of 8
(3,612 Views)

@crossrulz wrote:

Data flow dictates that a loop cannot iterate until EVERYTHING in it has completed.  So if you really want these to run in parallel, then they need to be in seperate loops.  This also opens up the issue of how these loops are to communicate with each other (Action Engine, queueu, notifier, global variables, User Events, etc).


I guess you're taking it to the next level in assuming he wants the code to loop along side the case structure code. I think he might just want the code to not take up time before/after the Wait and instead do what it needs to do at the same time.

 

@Syntyche, All of the code will keep the While loop from looping again until both the case structure and your other code have finished (if you keep them both in the same loop). If this is okay, then just follow what I said above. Otherwise, if you have other code that needs to keep communicating with the user interface for example, you will need another While loop in parallel with the one you mentioned.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 4 of 8
(3,607 Views)

Apparently you did not clarify enough.  Maybe an example would help.  If you could post your code of what you have now and then clarify exactly what you want, we could help you a little better.


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 5 of 8
(3,603 Views)

Thanks for the answers.

Yes, the code outside the case structure is getting an updated data after the waitsec function (and other functions within that case structure) so I am assuming I will have to use the parallel while loops then. Can you please link me to any example of using while loops in parallel?

The speed cluster is getting updated values such as the base, range, period...

 

0 Kudos
Message 6 of 8
(3,582 Views)

You probably want something like a Producer-Consumer architecture. This is basically a producer loop (user events, data acquisition, or similar) that enqueues data which then gets dequeue'd by the consumer loop.

LabVIEW ships with an architecture template called Queued Message Handler. This is a producer consumer architecture with an even structure in the producer loop that sends messages to the consumer loop to handle. The producer loop should never be slowed down by processes, but the consumer can take longer as it goes through the queue one by one.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 7 of 8
(3,568 Views)

Sounds good. I will look in details into this. Thank you!

Message 8 of 8
(3,555 Views)