10-15-2024 12:14 PM
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"
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:
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...
Solved! Go to Solution.
10-15-2024 01:26 PM
10-15-2024 02:15 PM
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.
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.
10-16-2024 12:53 PM
I've found 2 different ways of achieving this:
Solution 1: Build a variant from scratch (using type string and data string) and use it with "Get LabVIEW Class Parent and Member VI Information". This is very fast but I found the mentioned VI can crash LabVIEW when used repeatedly in a fast loop. Here is the forum thread I created for this: https://forums.ni.com/t5/LabVIEW/Data-type-parsing-VI-quot-Get-LabVIEW-Class-Parent-and-Member-VI/td...
Also, the whole type descriptor of the LabVIEW class is not documented.
Solution 2: Use a private Linker method. It is a bit slower, but it seems more stable. The method not being documented either, it should be tested with more complicated cases to ensure it never misses any interface:
Regards,
Raphaël.
10-16-2024 01:19 PM
Great info thanks! I have had issues with that linker node giving inexplicable errors - it's used by Caraya which runs it on all your VIs in certain setups. But I'm already using Caraya so I think everything is ~guaranteed to not error.
10-17-2024 01:15 AM - edited 10-17-2024 01:16 AM
That node and its sibling to write that information to the VIs on disk had in the past repeatedly changes in the datatype of the cluster that is used.
And them being a private node, they did not receive the same attention as official nodes to not crash if wired with incompatible data, respectively to have mutation code update the diagram when a VI is upgraded from an earlier version.Most likely there is also no back-mutation for VIs that are backsaved to earlier version.
These nodes definitely belong in the famous LabVIEW attic. The LabVIEW developers put a lock on that door but any lock can be picked. Behind that door are wondrous things but sometimes also dangerous ones. And there are frequently rusty nails, so thread carefully!
10-18-2024 07:50 PM - edited 10-18-2024 07:54 PM
Finally got around to testing the "class control exists" algorithm.