LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get LV Class Parent Name

Hi,

is there a way to get parent class name programmatically from child class that it's working in run-time vrs 2018? I tried to get it by reading the .lvclass file - in LabVIEW 2020 it seems that there is an item named "Parent Libraries" that contains the name of the parent class and the relative path to the parent lvclass file but in LabVIEW 2018 that item is missing from the file. Instead, I think they use "NI.LVClass.ParentClassLinkInfo" property which is "encrypted" and I have no idea how to get useful information from data listed there.

Lucian
CLA
0 Kudos
Message 1 of 33
(2,122 Views)

Thanks Wiebe, I know about that thread. The solution presented there does not work in run-time. I need it to work in run-time because we have a test sequencer developed in LabVIEW which is able to execute class method VIs but when dynamic dispatch VI is called and the current class does not have an implementation for that method, I needed the parent to check if it has that method implemented and call it. In the meantime I found a solution by calling 'Get Implementing VI Path' method from App -> LabVIEW Class. For some reason this seems not to work every time but could be something wrong in my code, I didn't have time to investigate in detail.

Still, since the parent is a dependency of the child, I would expect to have an easy way to get the parent name or path.

 

Lucian
CLA
Message 3 of 33
(2,010 Views)

I actually think you're solving this the wrong way.  It should never be "your job" to find out which VI in a class tree to call... that's the entire point of dynamic dispatch.

 

A better method, and one I have actually used, is to make a static "wrapper" VI in the class with the top-level dynamic dispatch VI in it, and then inside that VI do nothing except have one instance of the dynamic dispatch VI in it.  Then call that one instead when doing your call by reference.

 

 

0 Kudos
Message 4 of 33
(2,002 Views)

@Kyle97330 wrote:

I actually think you're solving this the wrong way.  It should never be "your job" to find out which VI in a class tree to call... that's the entire point of dynamic dispatch.


 It's not my job when I'm calling that method in LabVIEW but in this case, I'm calling that method from a LabVIEW executable and I am not the developer of the class being loaded so I cannot and don't want to modify it in any way. I just want to be able to call its methods. If the method requested does not exist in the class that is actually loaded, it's my job to find out what parent class has that method implemented and call it.

Lucian
CLA
0 Kudos
Message 5 of 33
(1,993 Views)

@LucianM wrote:

Thanks Wiebe, I know about that thread. The solution presented there does not work in run-time. I need it to work in run-time because we have a test sequencer developed in LabVIEW which is able to execute class method VIs but when dynamic dispatch VI is called and the current class does not have an implementation for that method, I needed the parent to check if it has that method implemented and call it.


Get Parent.PNG

You can use this during Run Time.

 

It works during development, but you'll get an annoying wait cursor when you call it.

0 Kudos
Message 6 of 33
(1,973 Views)

@Kyle97330 wrote:

I actually think you're solving this the wrong way.  It should never be "your job" to find out which VI in a class tree to call... that's the entire point of dynamic dispatch.

 

A better method, and one I have actually used, is to make a static "wrapper" VI in the class with the top-level dynamic dispatch VI in it, and then inside that VI do nothing except have one instance of the dynamic dispatch VI in it.  Then call that one instead when doing your call by reference.


It's an idea. I'm not convinced it's better.

 

Doesn't Single Responsibility Principle tell us that the class shouldn't be responsible for stuff like this?

 

I'll consider it though. It is more transparent, less hacky.

 

It feels weird that LabVIEW has no options for properly dynamically calling class members. It seems they simply forgot, haven't got to it or don't care (or know).

0 Kudos
Message 7 of 33
(1,971 Views)

I, at least, was not able to tell what issue this entire conversation is talking about, so perhaps they indeed just don't know what "proper dynamic calling" is.

0 Kudos
Message 8 of 33
(1,965 Views)

@drjdpowell wrote:

I, at least, was not able to tell what issue this entire conversation is talking about, so perhaps they indeed just don't know what "proper dynamic calling" is.


The main problem is there are two 'dynamic callings' here, causing confusion. 

 

Sometimes you want to dynamically start (VI Server, Run) a dynamic dispatch VI.

 

A way to do that is to get a reference to the exact VI and invoke the run method. So you need to check if the child implements the method, or call the parent's implementation, recursively.

 

Another solution would be to make a VI in the parent to do make the dynamic dispatch call, and call that VI with VI Server, Run method...

0 Kudos
Message 9 of 33
(1,958 Views)

What's wrong with just making a standard subVI that just calls the DD method?  No need to add this subVI to the parent class; it is naturally belongs to the calling code, not the classes being called.

 

0 Kudos
Message 10 of 33
(1,954 Views)