LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

View Queue History

Is there a simple way to view the 'historical' elements of a queue? I'm using a producer/consumer loop which bascially operates like the example below (illustration purposes only):

 

Queue_Elements.PNG

 

I want to view all of the elements of the queue that have been 'de-queued' over the course of the VI's execution. At the moment I can only see the current queue status.

 

I imagine the simplest way would be to build an array based on the de-queued elements at the start but I can't seem to work a way of doing it.

 

The example above just loads an enum into the queue based on a random number between 1 and 10. Each case return a different enum and dumps it into the queue.

0 Kudos
Message 1 of 11
(4,223 Views)

No.  The queue will not maintain a "history".  If it did, it would be endlessly growing.

 

Either build an array whenever you enqueue data.  (You could use a functional global variable to store and add onto the array which would be helpful if you needed to enqueue in multiple locations.)

 

Or you could enqueue your data into one queue.  Then have an intermediary consumer loop that dequeues that data, builds and maintains an array, then re-enqueues the data in another queue that the original consumer loop will work on.

Message 2 of 11
(4,218 Views)

Creating a second queue, which enqueues ONLY, seems to work.

 

Not sure what this will do for execution efficiency though. Is it inefficient to have a second 'parallel' queue running in the same loop?

0 Kudos
Message 3 of 11
(4,211 Views)

Sorry for a dumb question, but is a functional global an "Action Engine", if so than yes, I agree with ravens. 

You could also have an event based module that is fired up and saves the queue elemtns into an array. But his may be abit of an overkill.  

0 Kudos
Message 4 of 11
(4,210 Views)

"Is it inefficient to have a second 'parallel' queue running in the same loop?"

 

Well, here I would think the worry would be how many elements you are planning to save and if you need to somehow manipulate the elements. 

I still think that AE is the way forward. 

 

 

0 Kudos
Message 5 of 11
(4,208 Views)

There could be hundreds of elements moved in and out of the queue. I'd like to be able to view them all (to get an idea of what is being dumped in and in what order). I won't need to manipulate any of these elements - it's purely just to view them.

0 Kudos
Message 6 of 11
(4,202 Views)

Well, in that case you need to make sure on how you are dealing with the queue, since if it starts becomming large enough, it will effect the execution of you VI (specially if its inside a loop). You may have to get abit more sophisticated and save the queue elements of your 2nd queue into a text file every so often (say after 100 elements or maybe more) and make room for the next batch. Remember, if you keep the data inside a queue, it will start hurting your Ram.

 

Do you need to view them during this VI's run time, or can you let the VI do its job and when finished you can then view the elements after its done.  

0 Kudos
Message 7 of 11
(4,194 Views)

@zerotolerance wrote:

Sorry for a dumb question, but is a functional global an "Action Engine", if so than yes, I agree with ravens. 

You could also have an event based module that is fired up and saves the queue elemtns into an array. But his may be abit of an overkill.  


Yes.  They are the same.  I often use the phrase "action engine" if I'm talking about something that has a bit more "action" than just storing data.

Action Engine Nugget

0 Kudos
Message 8 of 11
(4,189 Views)

a simple change to Message Queue.LVlib: Enqueue Message.vi

 

Its not perfect (elements are in timestamp order but may be processed differently) but it should give you some ideas

!0.png


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

I don't think you will want to have a boundless history if the application will be running for any length of time. I would create a seaprate lossy queue which will hold your history. Set some limit for the maximum number of elements it will hold and simply queue the data to that queue as you dequeue elements. You could place this inside of an AE and add a timestamp to the element whenever you add to the history queue.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 10 of 11
(4,150 Views)