03-26-2013 04:18 PM
I am using circular buffer as provided here to store 2D array of DBL data.
Is there a way to have multiple buffer of same type? Need three circular buffer of DBL type to acquire and save data to its respective circular buffers.
Reason to store the data separate from each module is to use the respective buffer during analysis.
Any suggestions, thanks.
03-26-2013 04:30 PM
I would advise copying the code to have 3 different VIs to hold the circular buffers.
03-26-2013 05:32 PM
I haven't looked at the VIs there, but there is another way to have a circular buffer - create a queue of a fixed size and use the lossy enqueue function to add data to it. You would create N buffers simply by creating N queues. To read the current data from the buffer, you would use the queue status function with T wired to the return elements input.
03-26-2013 05:49 PM
How will the read pointer increment when using lossy enqueue implementation?
There are three threads that reads the circular buffer data and when all three has read then increment the read pointer.
03-26-2013 06:08 PM
Read pointer? Do you want to keep the data after it was read? If not, a simple Dequeue Element would work.
03-26-2013 06:30 PM
I believe so, I am acquiring data for all channels(16) and saving to buffer. When the buffer is full to some value then it is passed to another thread to process.
In the process loop it also gets the list box entries as selected by user. If there are three channels in list box say ch0, ch4 and ch0
The buffer data needs to be iterate untill the end of list box items have reached. Ch0 occurs twice so the data for the same timestamp needs to be written twice in data structure for its respective row. Data structure is a array where each array index coresponds to list box row.
Please let me know if there is a better approach to get circular buffer without read pointer for this and not miss any data point.
thanks.
03-26-2013 06:42 PM - edited 03-26-2013 06:44 PM
tst suggestion is good. You can create as many number of queues depending on your need and for reading just use the Queue status instead of dequeue. When you do this way you don't loose the element when you read and also you can read all the elements in 1 shot instead of doing dequeue until you reach empty. Also since its a lossy enqueue you don't have to worry about memory leak.
03-27-2013 02:24 AM - edited 03-27-2013 02:25 AM
If you don't want to miss data, then don't use a circular buffer. You can use a regular queue for each channel. Just enqueue the data on one end and dequeue (or flush, if you want a single read) on the other end. There are probably some queue examples in the example finder (Help>>Find Examples), so you should look at those.
03-27-2013 06:21 AM - edited 03-27-2013 06:21 AM
This is sounding more and more like what you really want is a Producer/Consumer architecture with many consumers. Use a different queue for each consumer.
03-27-2013 11:28 AM
Using the lossy queue as circular buffer did not work.
Just wondering if use of crcular buffer (the NI example made for array) over queue is better or just use of normal queues?