01-21-2011 11:28 PM
I wrote a set of VIs to manipulate, plot, and save data in a four-dimensional array. The array can be extremely large, so I used the numeric type U16, which was sufficient to describe all my data at the time. Now, I also need to handle floating point numbers (SGL is good enough) in smaller 4D arrays. I could change my VIs to handle SGL, and they would coerce the U16, but that would double the size of the array and limit its ultimate size, which was the point of using U16 in the first place.
Is there any simple way to allow a VI to handle two different numeric types without actually coercing?
(FYI, my VIs include various array functions, in-place element structures, data value references, TDMS functions, and a functional global variable to pass the array between parallel loops.)
Thanks.
Solved! Go to Solution.
01-21-2011 11:35 PM
It's hard to give specific advice without knowing the exact data structure you need, particular since you say you need a 4-D array.
But you could try looking at a cluster that contains multiple arrays, or an array of clusters. A cluster will allow you to have different datatypes grouped together.
01-22-2011 12:29 AM - edited 01-22-2011 12:35 AM
In case it helps make my issue clearer, I've attached two of the VIs I would need to generalize to handle U16 or SGL 4D array. I haven't attached sub-VIs, but hopefully you can at least get an impression.
I think I recall an idea called "overloading" from C++, where a single subroutine could accept different versions of its inputs. That's what I'm hoping for here.
(Note: I have some comments and questions included inside these VIs, but those were added a long time ago and don't pertain to my present question).
01-22-2011 09:34 AM
@bracker wrote:
Is there any simple way to allow a VI to handle two different numeric types without actually coercing?
Yes and no, what you do is create a Polymorphic VI, It's a common interface which can call different sub-vi's depending on the inputs. In this case you'll make a new sub-vi with SGL as input and output and when you drop and wire the polymorphic VI it'll adapt/select to the wires attached.
If the only thing you need to do with the sub-vi is change data type it should be very fast and easy, and the result in the main code is beautiful.
/Y
01-22-2011 10:03 AM
Thanks, that is exactly what I need.