Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Producing one set of data to multiple consumers

Hi all,

 

I am trying to use the producer/consumer architecture in my program.  My producer loop is a analog input acquisition loop.  I would like to enqueue the acquired data for 3 separate consumers.  The first consumer loop would write the data to a file, the second consumer would send the data to the front panel, and the third consumer would send an analog output based on the data. 

 

It seems to me that if any of the consumer dequeue the data, the other consumers would have nothing left to dequeue.  I want them to get the same data at the same time.  Do I really have to create 3 queues and enqueue the same data to 3 separate queues?  Is there a better way?  Thanks!

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 12
(4,329 Views)

I think this Discussion Forum post may have your answer. Evans response is what I was originally thinking.

National Instruments
RIO Embedded Hardware PSE

CompactRIO Developers Guide
0 Kudos
Message 2 of 12
(4,305 Views)

Hi,

 

My question is a bit different.  The post that you pointed me to address the problem when a master would send a messsage to a particular slave, while multiple slaves aare listening and could take the message, so that the particular slave does not get the message.  My question is that when the master send a message, I want all the slave to be able to get the same message and dequeue the same data without creating multiple queues. 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 3 of 12
(4,303 Views)

Hi,

 

Once you take information out of the queue you can no longer access that data. Thats why I was originally thinking of the preview function because you could access the data and make sure that everyone sees the same thing. This works, but its hard to synchronize. You could try using something like rendevous to make sure the vi's meetup, but even then, it would be hard to make everything synchronous. I also thought that you could possibly use global variables, write to them from the master and read to it from the slaves, because all of the slaves could access it at the same time, but even then you would have to make sure they were at the same rate, and that would eliminate the need of having multiple slaves. So there is no other good way that I can think of to enqueue information so that three different slaves could see it besides using three different queues.


Regards,

National Instruments
RIO Embedded Hardware PSE

CompactRIO Developers Guide
Message 4 of 12
(4,286 Views)

When I do three seqerate queue, I run out of memory sometimes, since each element is a decent size 2d array.  So there is no way to get around this?  Thanks!

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 5 of 12
(4,265 Views)

Hello,

 

Is there a way of getting around uing three different consumer loops? If they need information at the same time, does that mean they are looping at the same rate? Is there a possibility that you could use just one loop?

National Instruments
RIO Embedded Hardware PSE

CompactRIO Developers Guide
0 Kudos
Message 6 of 12
(4,256 Views)

I would like splits out each function into multiple loops, because I would like them to run at different rate, and I would like my program to be more cohesive (grouping similiar function to the same location of code).  I am not sure is that the right way to do it though.  Let me know what you think.  Thanks!

 

 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 7 of 12
(4,227 Views)

Hello,

 

I guess I am a little confused by why you want the loops to run at different rates, but you want the data updated at the same time.  Could you describe what you are doing in your code or submit a screenshot of what you are doing? Also, creating a seperate loop just because code is different is not always a good way to seperate code. Often a subvi is sufficient to group sections of code.

National Instruments
RIO Embedded Hardware PSE

CompactRIO Developers Guide
0 Kudos
Message 8 of 12
(4,210 Views)
hmm, I have one loop that needs to happen ASAP.  I have one loop that needs to log data once every 3 hours.  I have one loop that need to display data at a reasonable rate.  I thought having loops of different rate would work well. 
------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 9 of 12
(4,208 Views)

Hello,

 

Thanks for providing the additional information about your code. I am still not sure, if you have three loops running at different rates, why you would like to ensure they get the data at the same time. The loops would be moving at different rates and therefore you could not gurantee that they dequeue the information at the same rate even if they arrived at the same time. It still appears that using three queues would be the best solution, and then dequeing the information for each loop when it is needed by the loop, or you could have 2 of the loops use the preview queue function and receive the information that way while the last loop dequeues the information. All of the loops would get the same information, just one loop would dequeueing the information.

National Instruments
RIO Embedded Hardware PSE

CompactRIO Developers Guide
0 Kudos
Message 10 of 12
(4,195 Views)