LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating polymorphic VIs

Is there any way I can create a true polymorphic VI?
0 Kudos
Message 1 of 9
(4,051 Views)
What do you understand by "true polymorphic"?
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 2 of 9
(4,045 Views)
Like Becktho mentions your question is a little vauge in your meaning.  But I think I know what your hinting at.  As LabVIEW is coded now the possibility of a true polymorphic VI cannot be realized.  When creating a sub VI you *have* to assign a numeric representation to the controls and indictators ahead of time.
 
I would agree that it would be nice to have "adapt to input" controls and indicators for this purpose... the only work around I have found for this (after much hair pulling/ searching/ reading) is as close to a polymorphic template as I could get it to (please someone provide a better solution if one is available!).
 
1> Create a standard polymorphic VI
2> Create a VI containing the main code you would like executed and set the inputs/ outputs to one of the larger representations (such as extended)
3> Create a bunch of template VIs which call the VI in step 2 as a subvi
 
Note: These template VIs all look exactly the same except for their input and output types.
 
This approach, like everything, has its good and bad points.  Some of the good is you can create a template up front, copy it to a new location, and modify the code in Main Code VI and you have a new polymorphic VI ready to go (you have to use it at least once so the LLB will relink the modified VI).  Another good point is since the wrapper VIs are small it has some good space savings.  The only bad thing about it (that I know of) is the type casting.
 
See example below.  I know this is not exactly what you wanted but I tried something like this a couple of weeks ago and this is as close as I got... This polymorphic VI just adds two inputs.  For the example I added support (natively) for extended and two additional template VIs for double and single.
 
The other inputs are easy to add.  Edit one of the existing template VIs buy changing its representation to what you need, save it under a new name, add it to the library as a new option.
 
Hope this helps!
 
Message 3 of 9
(4,031 Views)

Chaos good on you !!! Smiley Very Happy

this is exactly what I need!!!

How did you create the pollymorphic top level? (Add Two Numbers.vi)

0 Kudos
Message 4 of 9
(4,022 Views)

I'm not sure that it's so impossible. It would be a pain, and I'm not sure that it would be ultimately worth the effort. But you can create a VI using variant type inputs. Inside the VI you would then have to parse the variant data to determine what its LV datatype is and then handle it appropriately. I remember seeing some code once that did that, but I don't remember where...

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 5 of 9
(4,018 Views)
You need the Professional version of LabVIEW in order to create polymorphic VIs.
0 Kudos
Message 6 of 9
(4,014 Views)

Got the profesional version!

What do I do next?

0 Kudos
Message 7 of 9
(4,001 Views)
There's a pretty good explanation of the steps in the on-line help. You start be selecting New... and picking Other Document Types>Polymorphic VI. You'll get a dialog box with an Add button that allows you to browse to the different VIs that will be part of the top-level polymorphic VI.
Message 8 of 9
(3,998 Views)

Works like a charm!

Thanks a lot guysSmiley Very Happy

0 Kudos
Message 9 of 9
(3,973 Views)