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!
5 replies to this topic
#1
Posted 11 June 2012 - 03:15 PM
#2
Posted 11 June 2012 - 03:37 PM
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.
Tim
"If this was easy our kids would be doing it." - Coworker
"If this was easy our kids would be doing it." - Coworker
#3
Posted 11 June 2012 - 04:08 PM
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.
#4
Posted 11 June 2012 - 06:18 PM
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?
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?
#5
Posted 11 June 2012 - 08:54 PM
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!
Thanks for your help anyway!
#6
Posted 12 June 2012 - 02:50 PM
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.












