LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event structure while loop

Solved!
Go to solution

Hello all,

 

I have programmed Labview to constatntly poll for new data from a third party driver (Datataker) inside a While loop. I also have an Event Structure inside another While loop, in parallel to the first one, take care of user actions on the GUI.

 

The issue I have is that the application does see the events (Start, Stop, etc.), happening inside its While loop, but does not poll for new data from inside the other While loop. Are the While loops suppose to execute simultaneously? There is something I am missing and help would be appreciated.

 

Thanks

 

Richard

0 Kudos
Message 1 of 8
(4,054 Views)
Solution
Accepted by topic author rcote1

Dataflow !!!!

 

Your second loop will not execute until it gets data on all wires entering it and that does not happen until the first loop is finished so they will not run in parallel

 

Also Diagram size !!  Why so big?  it makes it very difficult to follow when the diagram spans 12 screens

 

Ken

0 Kudos
Message 2 of 8
(4,045 Views)

Thank you Ken_Naylor,

 

I created 'Value' Property Nodes for the Event Structure While loop instead of wiring the data directly to the other While polling loop and now both While loops are runniong simultaneously and user Events can be handled while polling for new data.

 

Merry Christmas,

 

Richard

 

 

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

rcote1 wrote:

I created 'Value' Property Nodes for the Event Structure While loop instead of wiring the data directly to the other.


Why? local variables do the same thing and are much more efficient that value property nodes.

 

Still just ripping the code apart into two parallel segements will probably cause all kinds of other problems, such as race conditions.

 

Your code has other very serious problems. For example you irreversibly lose most data in the shift registers for most events. They need to be wired across.

 

You should look into some of the established design patterns, such as a state machine.

0 Kudos
Message 4 of 8
(3,982 Views)
I did try to wire the first loop to the second, but the second loop would not execute even when all data was available.

The reason I am creating 2 loops is because the Event Structure inside a single While loop did not properly handle the Timeout Event that I used to poll for new data. With the 2 loops architecture I continuously poll for new data while the other loop takes care of user events.
0 Kudos
Message 5 of 8
(3,948 Views)
I don't understand your first comment. If there is a wired data dependency, data is only available at the second loop once the first loop has finished.
0 Kudos
Message 6 of 8
(3,920 Views)

altenbach,

 

The reason I am using 2 While loops is because the Timeout event from my Event structure inside a single While loop in my initial design would not properly handle the polling of data, meaning half of the data would be lost and not logged. So I was told to use 2 While loops, one that handles the data polling and the other the Events. For some reason when I wire across the first loop to the second loop, the second loop( data pollig) does not execute. When I use property nodes or local variable, both loops run in parallel and all is good.

 

I did follow your recommendations and am almost completed in redesigning my application using state machine architecture. I am still using an Event Structure within one of the cases of my State Machine. Will the Events be queued until the case condition where the Event Structure is located is called, or will the Events be processed as they happen?

 

Thanks,

 

Richard

 

 

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

rcote1 wrote:Will the Events be queued until the case condition where the Event Structure is located is called, or will the Events be processed as they happen?

Events are stored in a queue.  If there is something in the event queue, the event structure will handle the next one as soon as the event structure is reached.  It only handles 1 event at a time, so you need to make sure you are processing these events in some sort of decent time.

 

If the event queue is empty when the event structure is called, then the event structure will just sit there and wait for an event to be fired, up to the timeout.


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