LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple enqueue

Solved!
Go to solution

Hi all,

 

I've seen people mentioning on the forums that they do this, but no examples. 

 

How to create a generic VI which will accept any element type and allow enqueue of multiple elements in a For loop?

 

Cheers,

 

Battler.

0 Kudos
Message 1 of 6
(5,166 Views)
You need to have a separate VI for each queue data type (ie an Enqueue Multiple Elements (string) will not accept a Queue of Enums refnum)
0 Kudos
Message 2 of 6
(5,151 Views)
or you can flatten your data type to a string, or better yet, convert to variant... but on the receiving side, you must know what to do with the data.  Meaning, that once you receive this 'universal' data, you must somehome identify what it is, and what to do with it.  But I use this method frequently for passing data between standalone processes.

Paul
0 Kudos
Message 3 of 6
(5,148 Views)

Why not pass the datatype with the variant data?

0 Kudos
Message 4 of 6
(5,137 Views)

However you choose to solve that particular issue.  I usually pass a cluster of two elements.  As you alluded to, something that identifies the data and the data itself. 

But it seems your on it... So good luck.


Paul
0 Kudos
Message 5 of 6
(5,134 Views)
Solution
Accepted by topic author battler.

Hi Battler,

 

I played around before with such a vi but determined in the end that it wasnt worth the while. I did what was suggested above by using a queue with a variant data type. You then need to convert the variant back to the known data type. I personally didnt think it was worth the bother and looks untidy on the queue recieving end. I now just use a standard vi that adds multiple states to a queue. I change the queue refnum to a refnum with the correct data type and change the state array to have the typedef data type of the queue. I then save this vi specifically for this queue. Only takes a minute but is a lot neater. With the variant version you could easily send the wrong type of data without knowing until runtime. You cannot do this if you have saved the vi specifically to handle the typedef State data, you will get a coercion dot.

 

Enqueue multiple states.png

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 6 of 6
(5,127 Views)