08-04-2018 12:37 PM
I have two while loops:
1) Loop 1 contains multiple variables that reading from multiple sensors.
2) Loop 2 is a state machine that uses the variables from loop 1 to determine how it should proceed. For example, if variable 1 from Loop 1 is above x value -> do this. The variables are getting update constantly.
I was using notifiers when there were only a few variables, but now I have more than 10.
Thank you!
08-04-2018 12:50 PM
@ShinyBidoof wrote:
I have two while loops:
1) Loop 1 contains multiple variables that reading from multiple sensors.
2) Loop 2 is a state machine that uses the variables from loop 1 to determine how it should proceed. For example, if variable 1 from Loop 1 is above x value -> do this. The variables are getting update constantly.
I was using notifiers when there were only a few variables, but now I have more than 10.
Can you explain what you mean by "variables"? ... by "constantly"? (these are very ambiguous terms, especially in LabVIEW)
It would help to see some code.
Whenever you have more than a few of something, it helps to carry them as arrays as soon as possible.
08-06-2018 07:11 AM
Arrays and Clusters are your friends when dealing with multiple of something. Based on your description, I do think the array is the best route to go.
Alternatives to the Notifier are Tag Channels and Global Variables.
08-06-2018 08:06 AM - edited 08-06-2018 08:08 AM
@altenbach @crossrulz I didn’t know I could queue arrays. I think that’s what I’m looking for. Basically, I just have a while loop that reads sensor info every second and feeds the readings to my state machine loop. I don’t have the program or Labview on my personal computer. I’ll give it a try later today when I have access to it.
Thanks!
08-06-2018 08:44 AM
You can queue anything you want, including arrays.
If the consumer loop (the state machine) needs the most recent value, you can make the queue a single element queue, and do a lossy enqueuer in the producer. That prevents values queueing up in the queue. If not (you need to process all values), two loops might only complicate things. A read\process\write or input\process\output scenario seems more to the point then. The input, process and write and be paralyzed in the same loop with two shift registers (or feedback nodes) if needed.
08-06-2018 09:02 AM
wiebe@CARYA wrote:
If the consumer loop (the state machine) needs the most recent value, you can make the queue a single element queue, and do a lossy enqueuer in the producer. That prevents values queueing up in the queue.
Or just use a Notifier, which just holds the latest update.
08-06-2018 09:31 AM
@crossrulz wrote:
wiebe@CARYA wrote:
If the consumer loop (the state machine) needs the most recent value, you can make the queue a single element queue, and do a lossy enqueuer in the producer. That prevents values queueing up in the queue.
Or just use a Notifier, which just holds the latest update.
Are there benefits to using a Notifier? I'd say maybe the one advantage is that it does exactly what is required and nothing more, while a queue can do (potentially) more. But besides that, why not use a queue?
I personally am familiar with queues, and don't see the reason for existence of notifiers (probably because this personally bias). It's just easier for me to always use a queue.
08-06-2018 09:46 AM
wiebe@CARYA wrote:
Are there benefits to using a Notifier?
Notifiers are broadcast, so you can send a single Notification to many places.
08-06-2018 10:33 AM
@crossrulz wrote:
wiebe@CARYA wrote:
Are there benefits to using a Notifier?
Notifiers are broadcast, so you can send a single Notification to many places.
Ah, ok. Like using the preview in a single element queue . Guess the notifier is a better fit...
I'd never use a naked queue (or notifier) anymore. As long as everything is nicely wrapped in a class, it's easy to convert from one to the other.