LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic dispatch not calling child classes

Solved!
Go to solution

I am trying my first efforts at OOP with a simple HAL architecture. I am working in LV2018 SP1.

 

Top level: Instrument.class

  • Class data is a VISA resource and two Win32 handles - all have accessors
  • has Config.vi and Reset.vi which are set as must-override in the class properties (these are empty placeholders)

 

Second level: I2C Interface.class

  • Inherits from Instrument.class
  • Class data has some I2C-specific values (pull-ups, clock speed) - all have accessors
  • has Config.vi and Reset.vi which are set as must-override in the class properties (these are empty placeholders)

 

Third level: Aardvark.class

  • Inherits from I2C Interface.class
  • Class data has a Win32 handle - has accessors
  • has fully-fleshed-out Config.vi and Reset.vi functions

 

In my application, I:

  • Take an Aardvark class and change it to I2C Instrument (using To More Specific Class.vi)
  • Call I2C Interface.class:Reset.vi (which should dynamically dispatch to Aardvark.class:Reset.vi)
  • Call I2C Interface.class:Config.vi (which should dynamically dispatch to Aardvark.class:Config.vi)

If I double-click on I2C Intstrument.class:Reset.vi and I2C Instrument.class:Config.vi, I get the Select Implementation windows with the down-arrow and the correct child class functions visible and selectable. This leads me to believe that the dynamic dispatch is configured correctly.

 

When I breakpoint the Aardvark.class:Reset.vi and Aardvark.class:Config.vi classes and run, they are never executed.

 

When I breakpoint I2C Instrument.class:Reset.vi and I2C Instrument.class:Config.vi and run, these classes execute. Dynamic dispatch is not occurring.

 

I have tried both loading the Aardvark class from disk (Get LV Class Default Value) and by using a class constant directly on the block diagram. Neither method seems to allow dynamic dispatch to happen.

 

What might I be missing here? I have attached my source distribution to this message and would appreciate some guidance. 

 

 

 

 

0 Kudos
Message 1 of 3
(1,924 Views)
Solution
Accepted by topic author Madmanguruman

You're missing a shift register.  Writing to the Local variable doesn't do anything because it doesn't loop back around and change the input object.

 

Do this:

Shift register.png

Message 2 of 3
(1,907 Views)

So obvious. I keep forgetting that LV OOP is by-value and not by-reference, and I keep thinking of the classes as referenced objects and not "actual" objects. Thanks for the tip.

0 Kudos
Message 3 of 3
(1,865 Views)