LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get Variant with type of class dynamically

I'm trying to do some introspection on class hierarchies, specifically I need a way to get the parent interfaces of a class without having the class on the block diagram at compile time (eg I only know it's a LV Object). I'm pretty sure I can do this with some VI server ops on the class project items, however I know from experience those are very slow. I found this VI "<vi.lib>\Utility\Data Type\Get LabVIEW Class Parent And Member VI Information.vi"

avogadro5_0-1729011658792.png

This is tantalizingly fast, however the challenge I'm having is it operates on the type of the variant input rather than the value. This is fun to wrap your head around initially since class wires have a type in their value, but the crux of it is this VI only operates on the class of the wire that was converted to variant. If I just take a LV Object that contains some arbitrary class data, the type of the Variant is always just LV Object with no parent or interfaces. In order to use this normally you need to have the class wire on the block diagram and convert it to a Variant, which is not what I want.

 

I just tried this with no luck, the ctl datatype is the cluster inside the ctl not the overall class:

avogadro5_2-1729012298505.png

 

I could maybe get this from a control in a VI that has the correct type, but to do that well I'd need a guaranteed VI name that will always exist and have the proper control in a standard spot which seems flimsy.

 

Has anyone had any luck "synthesizing" a Variant with a type of any class in memory? Or just knows a fast way to check parent interfaces given a class name or value...

 

0 Kudos
Message 1 of 3
(76 Views)
Use an Attribute of a void Variant?

"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 3
(50 Views)

I realized it's a bit hard to understand what I'm asking so I attached a sample project. Given a LabVIEW Object containing "Class 1" I need to get its parent interfaces.

avogadro5_0-1729019537154.png

The issue is that I can't use the "Get Class Parent and Member VI" unless the type of the variant is the class I want info about.

 

I did a benchmark and the Variant VI was over 3000 times faster than the VI server nodes, which I included in the other frame of the disable structure. The only issue is getting the right Variant at runtime.

 

0 Kudos
Message 3 of 3
(39 Views)