08-20-2013 09:59 AM
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):
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.
08-20-2013 10:03 AM
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.
08-20-2013 10:11 AM
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?
08-20-2013 10:11 AM
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.
08-20-2013 10:15 AM - edited 08-20-2013 10:16 AM
"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.
08-20-2013 10:18 AM
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.
08-20-2013 10:24 AM - edited 08-20-2013 10:25 AM
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.
08-20-2013 10:29 AM
@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.
08-20-2013 10:34 AM
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
08-20-2013 05:04 PM
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.