LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Logging output from Get Queue Status / Flush Queue

Solved!
Go to solution

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!

0 Kudos
Message 1 of 10
(5,001 Views)
To get the oldest element from a queue you should use GetQueueElement, it will give your cluster as output.
When you use GetQueueStatus you get an array of your cluster - and you should use an autoindexing loop to save the data...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(4,994 Views)
Solution
Accepted by topic author Anexe

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...


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 10
(4,975 Views)

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.

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

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:

  • Use Get Status to copy entire Queue contents, leaving Queue intact.  You now have an Array of Clusters, which you pick apart in a For Loop (for the Array elements) and an Unbundle (for the Cluster).
  • Use Flush Queue to dump (and empty) the Queue.  You again have an Array of Clusters, dealt with as above.
  • Use For Loop to dequeue each Queue element, getting Cluster that you unbundle, and continuing in loop until Queue is empty (you need to test for this).

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

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

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 10
(4,949 Views)

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

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

@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".


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 10
(4,932 Views)

Many thanks for your help guys!

 

I have now been able to accomplish my goal 🙂

0 Kudos
Message 9 of 10
(4,906 Views)

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.

CLD
0 Kudos
Message 10 of 10
(4,018 Views)