LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a parent method of a parent (OOP)

Solved!
Go to solution
Highlighted

Good morning, 

 

I'm pretty new to OOP in LabView (but I've already do it with other langages). I'm trying to do these classes in my project but I'm facing a problem, I can call the methods of the class "Voie" from her daughter Voie_AI_PT but when I try to call a method from a "grandchild", the method doesn't return anything (and I don't have any errors shown). Anyway, as soon as I try to call from above a parent method, I can't get a result and I don't know why.

Class diagrammClass diagramm

 

Here is the inheritance of my classes:

 

Inheritance of classesInheritance of classes

 

And here is the scope of my method (which is the same for others). All my classes have public methods, I've tried with protected too but nothing changed.

 

Scope of the mother classScope of the mother class

 

I'm working on LabView 17.

 

Thank you for your help

0 Kudos
Message 1 of 9
(210 Views)
Highlighted

Are you using the Call parent method or a direct call to the grandparents function? 

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 9
(200 Views)
Highlighted

I directly call the grand parent function, like this:

call.png

My grandparent class is made like this: 

get id.png

0 Kudos
Message 3 of 9
(197 Views)
Highlighted

Hmm, that should work, and does so for me:

ClassTest.png

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
Message 4 of 9
(179 Views)
Highlighted

Oh, how or where can I check to resolve this ? Could it comes from the inheritance or a parameter I added or removed ? I chosed this inheritance parameters from my grandparent but I tried others things without success.

properties class.png ?

 

 

0 Kudos
Message 5 of 9
(169 Views)
Highlighted

Do your accessors have Dynamic dispatch on the terminals? 

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 9
(163 Views)
Highlighted

Yes and all the childs have dynamic dispatch too (here is the ID getter from grandparent)

 

dynamic accessors.png

0 Kudos
Message 7 of 9
(159 Views)

If you have the same method implemented in a child class, then calling the dynamic dispatch with the child object like you're showing will use the child implementation (even if you drop a grandparent node).

 

You could make 'Lire ID.vi' static dispatch (if you always want the grandparent to provide the value) or you can just not override it in children (but you can't always control middle classes in some arbitrary inheritance hierarchy).

 

The icon will update in the case that you're showing if a child class's method is being used, but the icons seem very similar so I can't tell if that's happening or not.

 

Also, you can use Context Help to see which VI will be called. Since you have a block diagram constant on the block diagram, it will give the "lowest" child that suits the hierarchy.

Message 8 of 9
(151 Views)
Highlighted
Solution
Accepted by MartialWasTaken

I found where the problem came from, it has nothing to do with inheritance. I just badly used my constructors in my first grand child so the grandparent data where sent in void.

 

Without you I would have searched in parameters instead of my code, thanks a lot for your help !

Message 9 of 9
(148 Views)