LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I build a producer/consumer VI with multiple consumers?

Solved!
Go to solution

I’m studying for the CLD using this document as a base:

 

Certified LabVIEW Developer (CLD) Certification and Exam Overview

 

One of the requirements in that document has me stumped:

 

6. Select a producer/consumer (events) design pattern to respond to user interface events in the producer loop and defer the processing of the event to one or more consumer loops

 

I start with LabVIEW's producer/consumer (events) template and give it two consumer loops. However, each event only gets to one of the two loops, not both, as you can see in my attached example VI 1_producer_2_consumers.vi.

 

I would try LabVIEW notifiers, but I read that a notifer is not guaranteed to reach the consumer loops because they are not queued. I would try user-defined user events which might work, but they are not part of the CLD.

 

What’s the way to complete requirement 6 above?

0 Kudos
Message 1 of 8
(13,194 Views)

I honestly don't know why that requirement is there for the CLD.  The idea of having multiple consumers is that each consumer has its own task to perform.  Once consumer could be writing to a database while another consumer is updating the GUI.  Remember that a queue is a FIFO.  Once a data point is dequeued, it is no longer in the queue.  This is why we like to say that a queue is for Many to One communication.  In short, each consumer should have its own queue.


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
Message 2 of 8
(13,186 Views)
Solution
Accepted by topic author bmihura

@bmihura wrote:

 

 However, each event only gets to one of the two loops, not both, as you can see in my attached example VI 1_producer_2_consumers.vi.

 



you must have a 'queue' for each consumer and you were not properly stopping the loops with user interface (using error handling inefficiently, you will get dinged for it on the CLD)...

 

Spoiler
1_producer_2_consumersMOD_BD.png

 

Message 3 of 8
(13,171 Views)

apok,

 

Good points, and your approach works fine. The error "handling" in my VI was directly from LabVIEW's File >> New... templates; they sacrificed efficiency for simplicity.

 

Having two queues in your VI makes the diagram cluttered; but that may be the best way to do it. I was looking for some sort of queuing option on the LabVIEW notifier or the like; I didn't find it.

0 Kudos
Message 4 of 8
(13,160 Views)

@bmihura wrote:

apok,

 

Good points, and your approach works fine. The error "handling" in my VI was directly from LabVIEW's File >> New... templates; they sacrificed efficiency for simplicity.

 

Having two queues in your VI makes the diagram cluttered; but that may be the best way to do it. I was looking for some sort of queuing option on the LabVIEW notifier or the like; I didn't find it.


If you're worried about multiple queues looking untidy, you can always bundle them and unbundle the appropriate queue at the aprropriate place...

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 5 of 8
(13,155 Views)

a really cool tool for a CLD'r to have under their belt is "the labview style book" by blume

Message 6 of 8
(13,152 Views)

@bmihura wrote:

 

Having two queues in your VI makes the diagram cluttered....


is this better?

Spoiler
1_producer_2_consumersMOD_BD.png
0 Kudos
Message 7 of 8
(13,102 Views)

@apok wrote:

@bmihura wrote:

 

Having two queues in your VI makes the diagram cluttered....


is this better?


Ah, that's beautiful, I'll use those ideas. And I just ordered Peter Blume's book you recommended. Knowing him, which I do, it'll be great!

0 Kudos
Message 8 of 8
(13,091 Views)