LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

data passing from consumer to producer

Hello forum,

 

I am using Producer-Consumer design pattern for data acquisition. While my producer loop acquires data, consumer loop does,analyze, display and save the data. One thing I would like to do is to pass a data from the consumer loop to producer loop. This is for a taring function, where my consumer loop would analyze the acquired data for n-point average and pass the value to produced loop where, this value is subtracted from the acquired data. How would I pass a data from Consumer to Producer?

 

Many thanks to all,

 

Zacharia

0 Kudos
Message 1 of 10
(4,144 Views)

You can use a local variable.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 2 of 10
(4,142 Views)

Does the producer loop really need to get that value back?  If the consumer loop is the one doing the analysis, should it just hold on to the tare value and use that as part of the analysis?  If you send it back to the producer, now you've just placed some of the analysis responsibility back there.

 

Other alternatives to a local variable:

 

A function global variable or action engine.

You can use a notifier to send the data back to the producer.

 

Possibly some other ideas.......

Message 3 of 10
(4,138 Views)

Some of my dual loop systems pass data one way and commands or status messages the other way.  When I need to do this I use a pair of queues, one for each direction.

 

Lynn

0 Kudos
Message 4 of 10
(4,131 Views)

@Ravens Fan wrote:

Does the producer loop really need to get that value back?  If the consumer loop is the one doing the analysis, should it just hold on to the tare value and use that as part of the analysis?  If you send it back to the producer, now you've just placed some of the analysis responsibility back there.

 

Other alternatives to a local variable:

 

A function global variable or action engine.

You can use a notifier to send the data back to the producer.

 

Possibly some other ideas.......



Yeah, exactly this crossed my mind after thinking for a while. In that way I still keep the DAQ loop free of any analysis. I assume, this is best option currently for me. Using a notifier to send the data back to producer seems a good option too, but i have no experience in using them.

 

Thank you so much!!! Ravens Fane and others!

 

 

0 Kudos
Message 5 of 10
(4,124 Views)

@johnsold wrote:

Some of my dual loop systems pass data one way and commands or status messages the other way.  When I need to do this I use a pair of queues, one for each direction.

 

Lynn


Hmmm.  I thought of this but I couldn't get it to work.  It sounded like a good idea.  It just locked up the program.  The fp panel became unresponsive.  I had to use the Abort Execution button to stop it.  Could you provide a sample of this?  Just curious.  Thanks.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 6 of 10
(4,118 Views)

I do not have a simple example available at the moment.  If you post your program whihc locks up,perhaps I could modify that or at least figure out why it behaves that way.

 

Lynn

0 Kudos
Message 7 of 10
(4,112 Views)

I will get back with you later this afternoon.  Thanks.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 8 of 10
(4,109 Views)

@MoReese wrote:

@johnsold wrote:

Some of my dual loop systems pass data one way and commands or status messages the other way.  When I need to do this I use a pair of queues, one for each direction.

 

Lynn


Hmmm.  I thought of this but I couldn't get it to work.  It sounded like a good idea.  It just locked up the program.  The fp panel became unresponsive.  I had to use the Abort Execution button to stop it.  Could you provide a sample of this?  Just curious.  Thanks.


Using the two queue method would require the producer to check the status of the queue and move on when it is empty. This ultimately turns it into a form of a polling system.

 

If the producer is using an event structure you can pass data back via a user event.

 

Also, the OP mentioned that they handle the UI and analyze the data in the consumer loop. I would recommend for the greatest felxibility and reuse that the UI actually be in its own loop separate from the analysis. The UI loop would use an event structure and the UI updates can be passed to it using user events.



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 9 of 10
(4,105 Views)

@Ravens Fan wrote:

Does the producer loop really need to get that value back?  If the consumer loop is the one doing the analysis, should it just hold on to the tare value and use that as part of the analysis?  If you send it back to the producer, now you've just placed some of the analysis responsibility back there.

 

Other alternatives to a local variable:

 

A function global variable or action engine.

You can use a notifier to send the data back to the producer.

 

Possibly some other ideas.......


Exactly what I was thinking.  Producer should do one thing, and that's gather data and send it somewhere else. 

Consumer's the place you'll want to use that tare variable.  Maybe just put it in a shift register and pass it around the loop.  You can "pull down" the left input-side of the shift register to get the last n values out of it, stuff that into an adder and divide by n to get a rolling average.

 

If you *have* to send data back into the producer... I would use a 2nd notifier to do that instead of local/global vars.

0 Kudos
Message 10 of 10
(4,094 Views)