LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Holding parallel loops until a certain state is reached - what is best practice?

I can think of a few ways to make this work, but none of them seem particularly elegant: 

 

If my program consists of a state machine, and several parallel While loops outside of that state machine, how can I ensure that those While loops don't start until I've passed completely through the "initialization" state of my machine? 

 

I feel like wiring an event structure up to the front of all of the other loops is a really inelegant way to get them to wait. It seems better to wire an error, or something, out of the initialization state and over to each loop so they wait on that terminal - but then I'd have to wire that terminal up for every single state and etc. 

 

Is there a better way?

0 Kudos
Message 1 of 13
(3,174 Views)

Use a notifier. Have all of your parallel loops wait on the notifier and have the state machine generate the notification once its initialization is complete.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 13
(3,166 Views)

There are also Occurrences.  Not as robust as a notifier, but very simple to use.

0 Kudos
Message 3 of 13
(3,163 Views)

A large percentage of my parallel loops tend to be Queued Message Handlers.  So I just send a message to those loops when I am ready for them to start doing whatever they were made to do.


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 4 of 13
(3,159 Views)

And then there is the rendezvous...

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 5 of 13
(3,144 Views)

@Ben wrote:

And then there is the rendezvous...


Somehow, I just knew it was going to be Ben to mention those...


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 6 of 13
(3,125 Views)

And then there are Channels Wires

Omar
0 Kudos
Message 7 of 13
(3,119 Views)

Spoiler
@crossrulz wrote:

@Ben wrote:

And then there is the rendezvous...


Somehow, I just knew it was going to be Ben to mention those...


A wise man fool goes into his store house Palettes and brings forth treasures functions both old and new.

 

 

 

Smiley Wink

 

Ben

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 13
(3,115 Views)

Thanks for the replies everyone - a question: By "notifier," do you mean triggering an event via property node? I am doing that right now to trigger events out of my main loop but it feels kind of hack-y. 

 

I have a boolean essentially called "condition met" which is set to T or F via property node (signaling), and the event structure picks it up and does it's thing. The downside to this is the event fires whenever the node is used, even if it's F → F or T → T, and really i'd like it to fire whenever the variable is *changed*. 

 

I am using a bunch of case structures to work around this now, but milliseconds matter in this loop and I don't have any idea if evaluating them is taking time - so I'd really appreciate knowing if there's a faster way to do these checks and fire/not fire events programmatically.

0 Kudos
Message 9 of 13
(3,086 Views)

No, I mean a notifier. You can find them on the synchronization palette with queues. A notifier is similar to a queue. The difference is that a notifier will only contain a single value. New notifications will overwrite the current one. Another key difference is that you can broadcast a notification. Notifiers can have multiple listeners.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 10 of 13
(3,079 Views)