04-06-2016 03:49 AM - edited 04-06-2016 04:05 AM
Hey Everyone,
I am trying to create program that will record all data within a queue after a certain number / time limit is met.
However, when trying to save the output from the Flush Queue / Get Queue Status, I am unsure of how to proceed. My original input is a cluster of 4 elements.
The output states that it is 'an array of clusters of 4 elements'...
My original approach was to: Change the array to a cluster (of 8 elements) -> Unbundle each element into another cluster of 4 elements -> Merging each specific element to get a single stream of each of the 4 original elements.
Therefore resulting in: 1 array -> 1 cluster -> 8 clusters -> 4 data streams, each stream representing one of my original input elements (my goal).
However, this seems like a long drawn out process and I cant help but feel I am overlooking a much simpler way to do this.
I now wish to find out if this is the only way I can save each of the indivudual 4 elements in the original 'array of clusters of 4 elements' produced from the Flush Queue / Get Queue Status?
Furthermore, is there a way to save/log ALL the data directly from the Flush Queue / Get Queue Status output (skipping the data slicing/splitting process)?
Thanks!
Solved! Go to Solution.
04-06-2016 04:02 AM
04-06-2016 05:09 AM
What you really want to do is use Dequeue Element inside of a FOR loop. Inside of the loop, you unbundle your cluster and wire the values out. Let the FOR loop do the autoindexing and you will have a different array for each item in your cluster.
Check out the example I did here: http://forums.ni.com/t5/LabVIEW/TDMS-File-starts-recording-data-at-20Hz-but-after-a-short-time/m-p/3...
04-06-2016 07:20 AM
Thank you both for your quick replies and suggestions!
I will try and implement the suggestion by crossrulz 🙂
I aim to provide my results as soon as is possible.
04-06-2016 07:54 AM
One question is whether you want to take a "snapshot" of the Queue contents (preserving the data on the Queue) or want to "dump" the Queue and output its values. You have the following basic choices, all of which will work:
If data are still coming in to the Queue, the last method might produce a different result than the first two, since the first two are "snapshots" of "the Queue as it is at this instant", while the last could start with 5 elements on the Queue and have another two be added while the Dequeue is in progress.
"You Pays Your Money and You Takes Your Choice".
Bob Schor
04-06-2016 08:25 AM
@Bob_Schor wrote:If data are still coming in to the Queue, the last method might produce a different result than the first two, since the first two are "snapshots" of "the Queue as it is at this instant", while the last could start with 5 elements on the Queue and have another two be added while the Dequeue is in progress.
That is exactly why I use a FOR loop so that you can limit how many elements you dequeue at a time.
And I try to avoid Flush Queue since it actually deallocates the full queue data from memory. Which means that putting data into the queue will force an allocation of memory. This can lead to some fragmented memory and, at the least, slow downs due to the forcing to allocate memory.
04-06-2016 09:00 AM
Crossrulz, I was not aware that Flush deallocated memory for the Queue (not obvious from the Help). Thus this method is definitely not optimal except, perhaps, when you know the Queue has stopped (with stuff still in there), not an obvious scenario.
Bob Schor
04-06-2016 09:21 AM
@Bob_Schor wrote:Crossrulz, I was not aware that Flush deallocated memory for the Queue (not obvious from the Help).
As I was told when I found that out (about 1.5 years ago now) "That is why the trashcan is in the icon".
04-07-2016 04:33 AM
Many thanks for your help guys!
I have now been able to accomplish my goal 🙂
05-02-2018 01:14 PM
Respected All,
We can use flush queue and log the data instead of dequing only one elements at a time. this will free up memory more quickly.
PFA for the proof of concept i have successfully logged and retried all data.