12-12-2013 05:45 AM
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
Solved! Go to Solution.
12-12-2013 06:03 AM
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
12-12-2013 05:44 PM
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
12-12-2013 06:50 PM
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.
12-13-2013 04:34 AM
12-13-2013 11:53 AM
12-21-2013 07:55 AM
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
12-23-2013 06:05 AM
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.