08-17-2016 12:26 PM
Is there a way I can complete an enqueue on a 1D array, instead of only one element?
Solved! Go to Solution.
08-17-2016 12:31 PM
Sure you can. You need to define the element data type as array.
https://zone.ni.com/reference/en-XX/help/371361H-01/glang/create_queue/
08-17-2016 12:43 PM - edited 08-17-2016 12:44 PM
Yes the Queue "data type" can be any data type, array, or even a cluster containing several different data types.
08-17-2016 12:48 PM
@udka wrote:Sure you can. You need to define the element data type as array.
https://zone.ni.com/reference/en-XX/help/371361H-01/glang/create_queue/
Yepper!
I cannot think of anything you can not transfer via a queue save a reference from one porcess context to another or across a network.
Ben
08-17-2016 12:50 PM
@RTSLVU wrote:Yes the Queue "data type" can be any data type, array, or even a cluster containing several different data types.
I have even transfered clusters that contained queues via a queue.
Ben
08-17-2016 01:10 PM
@AndreaD wrote:Is there a way I can complete an enqueue on a 1D array, instead of only one element?
The answers above are all correct, but I'm thinking there is a different way to interpret your question in which you have an array of elements, but want to cycle through and put each of them into the queue, where the queue is otherwise a scalar. In that case, wrap your enqueue in a For Loop so it auto-indexes on the 1-D array.
08-17-2016 01:17 PM
The other option is to use a FOR loop to dequeue multiple elements. If I need to go this route, I typically have a timeout and stop the loop when there is a timeout.
08-17-2016 01:24 PM
@crossrulz wrote:The other option is to use a FOR loop to dequeue multiple elements. If I need to go this route, I typically have a timeout and stop the loop when there is a timeout.
Use a Preview Queue and wire the number of elements in the queue to the N terminal of the For loop. No TO required.
Ben
08-17-2016 01:27 PM
Now you're talking the other direction where you are trying to dequeue an array of elements into a 1-D array from a queue of scalars.
In this case, instead of preview and dequeue, you might as well use Flush Queue.
08-17-2016 01:39 PM
Kudos for generating a "Sanity Check" User event in my head Bill.
I do have one reservation and that is "in-placeness". Provided we dequeue and do not branch wires the element removed from the queue is effective transfered "in-place". It is like the queue just trasfers the pointer from where it was queued to were is dequeued. But if we Flush, I wonder if the returned array is actuall an array of the same pointers or if the data gets copied to creat the array of returned elements. Something tell me that LV can keep track of thing and work inplace as long as we are connected to the queue operations but when we get an array back from the flush and pass that array to a sub-VI... Can LV keep track of those buffers?
Just thinking out loud.
Ben