LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to develop multiple producer - multiple consumer

Solved!
Go to solution

Hi there,

 

here is my current dataflow scheme:

 

Sensors

FPGA Front Panel (preprocessed data, multiple channels)

Multiple analyses with non-uniform sampling - in parallel for loops

Data FIFO with data from all analyses

Processing results into file once every second

 

The thing is that now I need is to have a structure that stores last values of analysis similarly to FPGA front panel, so that it can be accessed from multiple parallel consumers (triggers, displaying etc.). I hoped that there is something like FIFO which works for last values only and is accessible from multiple resources.

 

One idea I came up with is duplicating the FIFO and using a "publisher" loop, which reads this second FIFO with all values inside and updates a global variable (GV) every 10 ms. It can be accessed by multiple consumers. The problems:

 

one more separate loop to a program, which is dedicated to this single task

one more FIFO 

changes in variable are periodic, not instantaneous, causing unwanted delays

writing a complete GV even though only one element changed

i simply feel that using GV for this purpose is "bad" 

 

Other idea is to implement GV update inside the "write FIFO after analysis" step, which would solve duplicating the FIFO and using separate loop, but the thing is that writing FIFO is in a time-critical loop and updating GV might slow it down.

 

Any ideas?

0 Kudos
Message 1 of 4
(2,154 Views)

What are your performance requirements?

 

How much data is it in total?

0 Kudos
Message 2 of 4
(2,133 Views)

@Thomas444 wrote:

I hoped that there is something like FIFO which works for last values only and is accessible from multiple resources.


A single element queue, combined with lossy enqueue to write, and peak to read?

A normal global?

A channel wire?

 

I'd not use a GV, because I don't particularly like their disadvantages (the ones they have in common with normal Globals), but I would not discard them for their speed.

 

Optimize when needed...

0 Kudos
Message 3 of 4
(2,116 Views)
Solution
Accepted by topic author Thomas444

Hi Thomas,

 

as wiebe mentioned there are multiple approaches to publish data as "latest data":

-Single Element Queue (basically a Queue with buffersize=1 and whenever you read an element, you directly write it back into the queue)

-FGV - Functional Global Variable

-Global Variable

-Shared Variable

-Notifier

-local variable

...

 

All in all your structure sounds like you should be using a Queued Message Handler design pattern. If you do so, you can simply implement a "Request latest value"-Message that will have a response with the latest value of the loop you requested the value from. This way you will have more control about who accesses the data at what time, but its also much more effort than just unsing some kind of global variable.

 

I hope this helps, if theres something unclear or you have further questions, just let me know!

 

Cheers,
Jan Göbel

Staff Technical Support Engineer

0 Kudos
Message 4 of 4
(2,090 Views)