05-08-2013 04:00 PM
Your pseudo code there very much describes a polymorphic VI. A polymorphic VI can choose which VI to run based on the data type on the connector.
05-08-2013 04:48 PM - edited 05-08-2013 04:48 PM
A polymoprhpic VI as I understand it is just a group of VI's.
I can make a lot of generalizations in the source code
I.E. Float Array, Int Array (reguardles of size) will all invoke the same method (with a conversion for floats). Wouldn't a polymorphic VI mean writing a case for every single data type?
05-08-2013 04:52 PM
Yes, a polymorphic VIs is a stack of standard VIs, and yes, a polymorphic VI will require a VI for each datatype - just like your pseudo-code requires a case for every data type. LabVIEW will automatically convert numeric datatypes for you, though, so you can wire an array of ints to a VI that accepts an array of floats (or vice versa) without having a VI to handle that specific array type.
05-08-2013 04:57 PM
But it doesn't.
I can use the same case for all arrays, or all ints. Thanks to the && operator, so another question would that exist in Labview? I guess with a dynamic input it would.
05-08-2013 05:03 PM
Valarauca wrote:
I can use the same case for all arrays, or all ints. Thanks to the && operator, so another question would that exist in Labview? I guess with a dynamic input it would.
Sorry, no idea what you're trying to say here. I've been writing a lot of C lately but not Java, and to me && is just AND (that operates on values, not bitwise). Does it mean something else in Java? What do you mean by a "dynamic input"?
05-08-2013 05:05 PM
That's what it is.
I can use the same case for all array times, and integer types. I don't know how to do this in LabView.
05-08-2013 05:08 PM
Or sorry not bitwise and
|| or very sorry for that.
05-08-2013 05:12 PM
In that case I have no idea why you mentioned the && operator, I don't see it anywhere in your pseudo-code.
Again, LabVIEW will handle numeric conversions for you automatically. Personally what I would do is create a single VI for the temperature conversion that takes a floating point as an input, and outputs a floating point value. Voila, done! It will handle any numeric type - the conversion is automatic. If you need to handle an array, just wrap it in a for loop at that point in the code.
Instead of trying to make LabVIEW work like Java, accept that it's a different programming language with its own set of advantages and disadvantages that sometimes require different approaches to writing an algorithm.