LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sum functions (two inputs) for sibling classes with a dynamic dispatch input: the static input keeps the type of the parent class !

Solved!
Go to solution

Let's assume in an hypothetical example that I have a parent class (number) with two children classes (real and complex).

I would like to define a sum function for these classes, using dynamic dispatch.

Both real and complex would have its own sum method (VI) that would perform different operations, as real and complex numbers are different beasts.

 

If I understood correctly, the normal way to do this in OOP is for each of these methods to have one dynamic dispatch input, and a static input of its own type.

Problem: Labview won't let me do this !

I first define a dummy dynamic-dispatch input method for the parent class number, but only the first input can be dynamic-dispatched so the second one is statically typed as number.

Then, when I create override methods in my two children classes real and complex, the second (static) input stays as number (the type of the parent class). This is not right, because then I cannot access the private data of the child class of type real or complex that will be wired to the second (static) input.


What is the usual solution to this (usual) problem ?

 

0 Kudos
Message 1 of 4
(2,299 Views)

@calvintiger wrote:

...
What is the usual solution to this (usual) problem ?

 


 

Use a variant as the input/output?

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 4
(2,286 Views)
Solution
Accepted by topic author calvintiger

I think in LVOOP you only use a dynamic terminal or a static terminal for the object terminal.

 

You can have multiple other terminals, but all the dynamic VI's ( methods with same name) must have the same API ( Terminals ). 


So you have to figure out your preferred method to pass, use multiple terminals, not used by each method, or use a cluster that contains all the numbers to be passed in  ( real or complex, both not used in each method) or you could try a variant, as mentioned.

 

 

-------
Mark Ramsdale
-------
0 Kudos
Message 3 of 4
(2,276 Views)

Thanks to all for your answers.

It made me think: wouldn't it be simpler to use a "to more specific class" node ?

0 Kudos
Message 4 of 4
(2,264 Views)