LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple levels polymorphic

I have 3 groups of operation, for example, Acc, Harmonic, MinMax.  Under such group, they have trigger, read, and write.  I have 3 polymorphic: one for acc, one for harmonic, and one for minmax.  If I I want to make the 3 polymorphic into 1, is there a way to preserve the groups?  In other word, is there a way to make a multiple levels polymorphic with group and subgroup.  Thanks!

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 5
(2,839 Views)

LVOOP. Instead of the polymorphic subVIs, you'll have a child for each class/type.

With several inheritance layers and compositions (a class that contains diffrent classes), you are pretty flexible.

 

Felix

0 Kudos
Message 2 of 5
(2,829 Views)

Can you give me an example?  Also, how do you manage that, since the polymorphic was in a lvproj, would I have to create a class without that lvproj?  What is the best way to managa this?

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 3 of 5
(2,820 Views)

Classes need to be in a lvproj.

 

The basic idea is:

* ParentClass has a method foo() with MustOverride=true

* ParentClass is 'abstract', which isn't really supported by LVOOP, but you should never instanciate it. So porpably just throw an error if ParentClass.foo() is called.

* The child classes A, B, C must now create an override method for foo()

 

Now you can drop the method foo on the BD. Dynamic dispatching will check at runtime which class you wire to it. So if you wire B to it, it calls B.foo().

 

I suggest you give it a try if it suits your needs and which problems you encounter.

 

The power of the OOP concept is, you can extend your classes in two ways. The one is using inheritance, so you can create a class K that is a child of B. K can call some of the methods of B (by default), override some of the methods of B and add some more methods.

The second extension would be to place other classes in the class private data cluster (composition). So A could contain X and Y while B could containe X and Z. This is called a composition. Classes A and B will now implement some of it's functionality be calling X (so they share methods different than inheritance). Also note, that it could be at run-time determined if A contains X and Y or X and Z. This concept is called a delegation.

 

It's a bit difficult to suggest you all in more detail without a understanding of the purpose of your code.

 

Felix

Message 4 of 5
(2,796 Views)

The class solution sounds great, but it is a bit too much for what I want to do, since I just want to do subgrouping within a polymorphic VI.  I did more searching, and I found that using a colon in menu name of the polymorphic VI will accomplish that. 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 5 of 5
(2,780 Views)