Jump to content
News about the LabVIEW Wiki! Read more... ×
zack13532

Polymorphic VIs that Pop Up

Recommended Posts

Hi all, I'm somewhat new to Labview so excuse any ineptitude that may arise. I have a program that is centered around an array of Devices - they are various different object types that descend from an abstract Device class. I'm trying to make a VI that can call the correct method VI for a given device in this main list (in an object oriented way, of course). So far this has been fine for most VIs, but now I'm trying to make an overridden VI in each class that opens when called, like a dialog box. As of right now, calling the "Display Info.vi" (the VI in question) on a given device opens the Display Info VI from the Device class, which is basically just a blank, unimplemented VI and therefore useless. Are there some settings I need to check to enforce polymorphic behavior on this VI? Thank you for any info you can provide!

Share this post


Link to post
Share on other sites

You're not looking for polymorphic as I understand your question. The parent class should have a dynamic dispatch VI and the child class should have an override VI that is the pop-up.

Share this post


Link to post
Share on other sites

That's currently how I have it set up, the Device class has a dynamic dispatch VI called Display Info and the child classes (the classes that will actually have real objects) override it with a Display Info VI that pops up. The correct VI pops up if I drag the Display Info VI from one of the child classes to the block diagram and wire in a control of that specific type. But if I get a Device object from an array that could be from any of the child classes and wire it into the Display Info VI from the Device class, the Display Info from the Device class is the one that pops up (when the device/object in question is actually a child type). The Display Info from the Device class is just the basic new VI layout because I didn't plan on actually having any objects that were specifically Device type.

Share this post


Link to post
Share on other sites

Two suggestions:

Probe the input wire.

If you double-click the "Display Info" VI in-situ does it bring up a dialog asking you to choose an implementation?

Share this post


Link to post
Share on other sites

Oh it's working now! I realized my mistake was actually very silly - I was trying to access an uninitialized index of the array.

Thanks for your help anyway!

Share this post


Link to post
Share on other sites

Quick clarification: in LabVIEW, the term "polymorphic" isn't dynamic, and doesn't really apply here. "Dynamic dispatch" is more appropriate - polymorphism in LabVIEW is something different.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site, you agree to our Terms of Use.