LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Store last n number of arrays

I am collecting an array of 34 elements. I want to store the most recent n number of arrays, where n is defined by the user and can be changed during a run.

 Currently what I do is something like the following: build an array until the buffer is the size you want, then use replace array subset to overwrite the oldest element. This works fine, but if the user changes the buffer size, it will send me back to the case where I use build array (false case). Now my data will be out of wack.

 

Suggestions? I thought about a lossy queue but you can't change the buffer size during run time can you?

 

 

 

0 Kudos
Message 1 of 9
(4,436 Views)

Your code shows no mechanism for the user to change the buffer size. How is the user supposed to change the buffer size?

0 Kudos
Message 2 of 9
(4,418 Views)

@smercurio_fc wrote:

Your code shows no mechanism for the user to change the buffer size. How is the user supposed to change the buffer size?


This is just an example where I chose number to buffer to be a constant of 5. Ultimately that would be a control where the value would be set. I threw this example together real quick because I can't post my code. I don't think I let anything else important fall by the wayside. Let me know if I did.

0 Kudos
Message 3 of 9
(4,415 Views)

Hmmmm. no the max number of elements in a queue is only set if Obtain Queue is called AND the queue does not exist.  In theory you could close the queue with Force distruction T then re-obtain the queue with a different number of max elements and simply re-enqueue the elements from the close operation in a auto indexed loop.

Thought I'd Try --- works pretty slick

 

 

ReSizeQue.png

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 9
(4,409 Views)

Obviously you want a queue of "Data Array [32]" I simplified to a queue of scalar to avoid headaches in the example


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 9
(4,402 Views)

Getting back to the original code: it doesn't work because it's flawed, or rather incomplete. When you first run the code, the top shift register is guaranteed to have zero as the value. Even if you change the 5 to a control it won't matter. The top shift register will always have zero. I'm not sure why you're using a separate shift register for the counter. All you need to do is to use the size of the 2D array to determine what you need to do. If you stick with the arrays your functional global will need to be more complicated. For instance, if you decrease the buffer size you can't just replace the last row. You also need to resize the 2D array. You also need to shift the rows "up" so you have a moving buffer.

Message 6 of 9
(4,388 Views)

As an ASIDE

 

Probe the queue   Smiley Mad Number of elements enqueued is "0"-- No, I don't like the probe bug!!!! NOT ONE BIT!!!


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 9
(4,381 Views)

 


@for(imstuck) wrote:

 

Suggestions? I thought about a lossy queue but you can't change the buffer size during run time can you?

 

 

 


Vote for this IDEA

 

That property COULD be exposed


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 9
(4,371 Views)

Just on a side note, there is also the Collector express VI.

Message 9 of 9
(4,358 Views)