LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can a Producer loop work with multiple consumer loops?

Hi NI Community,

 

I'm building a program to collect data, save data as the program is running, and process data. I'm trying to see if I could have 1 Producer loop that sends queue data to 2 or more consumer loops where each consumer loop does a different task. Is this possible? If so, what is the best way to implement it?

 

For example:

 

Producer loop collects data -> Consumer loop 1 receives data and save TDMS

                                             -> Consumer loop 2 receives data and do basic data processing and display on the screen

 

Thank you!

 

0 Kudos
Message 1 of 4
(1,758 Views)

Hi Victor,

 


@victor55 wrote:

I'm trying to see if I could have 1 Producer loop that sends queue data to 2 or more consumer loops where each consumer loop does a different task. Is this possible?


Yes.

Use two queues!

(Or a queue for data saving and a notifier for UI display…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(1,748 Views)

Another option is to use User Events.  You just have your consumer loops register for the event and each one will get a copy of the event.  It is a little more extendable than multiple queues.


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 3 of 4
(1,706 Views)

I had a colleague who generated 10" videos, 24 at a time, continuously for 2 hours, needless to say consuming huge amount of disk space.  Trouble was, just after he generated an AVI, he determined (through other sensors) whether it was worth keeping (about 1% were kept).  To prevent a Hard Drive Embolism, he had a separate routine that he passed the file names of the "files to be deleted", but it just wasn't fast enough.

 

I suggested a Producer/Consumer, which at least let the DeleteMe routine run in parallel with all of the Writers.  Still not fast enough.  So I said "Send the Queue to four DeleteMe Routines", which did the work in parallel, roughly 3-4 times faster.  Then I convinced him to change the algorithm -- instead of "Save First, Decide if Useful, then Discard as needed", try "Acquire, Decide if Interesting, and if so, Start Saving" -- since these were Videos, we could use IMAQdx's Buffers to save, say, 1" of data before the "Event Start" signal was detected, so could Have our Cake and Save It, Too.

 

Bob Schor

0 Kudos
Message 4 of 4
(1,690 Views)