This is another article in a series showing some of my favorite OpenG VIs — “The OpenG VIs that I couldn’t live without“. In this article, I’m going to show a very useful VI, Array of VData to VCluster, that is used for converting arrays into a clusters. The benefit of using this function, is that, unlike the Array to Cluster primitive, it defers type checking to run-time.
Here’s a short, 5 minute video showing how to use this function:
If you want to give this VI a try, you can obtain it using VI Package Manager (VIPM). Simply select the OpenG LabVIEW Data Tools (oglib_lvdata) package from within VIPM. Once installed, this will add a new functions palette at OpenG>>OpenG LabVIEW Data Tools. (See here for a quick guide on how to install OpenG on VIPM.)
Monkey brid fish!
What sort of performance hit (time and/or memory), if any, do we get using the OpenG vCluster VIs over the primatives?
I haven’t done any profiling of the OpenG Array of VData to VCluster function, but I’m sure that the Array to Cluster primitive is pretty fast. This operation concatenates the array type descriptors together and concatenates the array element data. If the primitive is used, the type descriptor portion can be done at edit-time and only the array elements data need to be concatenated at run-time.
The source code is all there, so if you want to know more, take a look. If you discover anything interesting, feel free to post back your results.
In recent version of LabVIEW you can even do without the local:
See on LAVA.
Ton
Ton: Thanks for the tip. One thing to consider before trying to use this feature is that the backwards type propagation from the indicator terminal into the Variant to Data function will not pass through structures. And, since It is a best practice to always wrap subVIs in an error case structure and to put the indicator terminals outside the case structure, there aren’t really any practical ways to utilize this feature — I always use a local variable (or typedef constant) to set the data type of the Variant to Data function.