Jump to content
Francois Normandin

Inheritance hierarchy

Recommended Posts

I'm trying to get the class hierarchy of many lvclass files that are not loaded in memory (some kind of plugin architecture).

However, I could not find a way to do it without using VI scripting.

It's simple to get the answer if I drop the object constants on the block diagram,

post-10515-1217969183.png?width=400

.

My goal is to read the directories, find all lvclass files and extract their hierarchy. Using "To More Specific Class" to compare to existing classes prior to code distribution and monitoring errors is okay, but I don't know if the user has added/cloned a new class to extend functionalities. Actually, it's a feature of the code I'm developing (cloning and editing a template class). When reading a lvclass file using "Get LV Class Default Value.vi", I end up with the generic LV Object and cannot detect hierarchy because I cannot typecast. (not knowing what is the object type I need to typecast)

The snapshot above is a temporary VI that I create using scripting and it works fine. But I found it executes in about 50ms and I need to loop it (n^2) where n is the number of classes it detects. For 8 classes detected, it takes more than 3 seconds... Is there a simpler way to achieve this?

Here's the code (sorry: LV 8.6 already!) :thumbup:

Download File:post-10515-1217971233.zip

Share this post


Link to post
Share on other sites

I'm not an 8.x user, so I don't have any experience with this, but here are a couple of guesses:

  1. Give each class a method returning its name. Then, use the call parent implementation node on the class you loaded and you will get the name of its parent.
  2. Hack the lvclass file. The parent seems to be in there, but its data is binary.

Share this post


Link to post
Share on other sites

QUOTE (Yair @ Aug 6 2008, 01:44 PM)


  1. Hack the lvclass file. The parent seems to be in there, but its data is binary.

I thought it was in that file. I'll give it a shot.

thanks

EDIT:

lvclass is an XML file, however its properties are not text. I think this is the one I need to sort out:

<Property Name="NI.LVClass.ParentClassLinkInfo" Type="Bin">#'#!!1!!!!)!"1!&!!!-!%!!!@````]!!!!"!!%!!!!Q!!!!!1Z198*F<H1O<(: D<'&T=Q"16%AQ!!!!&!!"!!)!$F"B=G6O>#ZM>G.M98.T!!!!!!</Property>

:wacko: I'll spend a nice evening tonight...

Share this post


Link to post
Share on other sites

Here's a VI that will give the top-down inheritance hierarchy of a .lvclass file. It reads the linkage information from the file on disk, so there's no VI Server or scripting code (although I do use a private method to get the linkage info, so the VI is password-protected). I tested the VI in 8.5 and 8.6 and it seems to work.

Hope this helps,

-D

Share this post


Link to post
Share on other sites

QUOTE (Darren @ Aug 6 2008, 04:35 PM)

Here's a VI that will give the top-down inheritance hierarchy of a .lvclass file. It reads the linkage information from the file on disk, so there's no VI Server or scripting code (although I do use a private method to get the linkage info, so the VI is password-protected). I tested the VI in 8.5 and 8.6 and it seems to work.

Hope this helps,

-D

Works like a charm.

I'll echo Chris: "How do you find the time during NI Week?" :thumbup:

Share this post


Link to post
Share on other sites

QUOTE (normandinf @ Aug 6 2008, 04:15 PM)

I'll echo Chris: "How do you find the time during NI Week?" :thumbup:

My week was very heavily front-loaded due to all the prep work for the Tuesday keynote. I've still got stuff going on today and tomorrow, but the hardest stuff is over (for me, anyway).

-D

Share this post


Link to post
Share on other sites

It looks like my attachment to this thread was lost during the LAVA site redesign. Here it is again (saved in LabVIEW 8.6).

-D

I've seen a couple of these VI's which return the class hierarchy floating around but in all cases they are locked. Where is this VI coming from? Does anyone know what it is actually doing? I really can't use a VI that is locked unless it comes with LabVIEW or is released by NI in some form.

~Jon

Share this post


Link to post
Share on other sites

I've seen a couple of these VI's which return the class hierarchy floating around but in all cases they are locked. Where is this VI coming from? Does anyone know what it is actually doing? I really can't use a VI that is locked unless it comes with LabVIEW or is released by NI in some form.

The VI uses a private VI Server method that can read linkage information from the .lvclass file on disk. As a general rule, we (that is, LabVIEW R&D) password-protect any VIs that contain private functionality when we post them on public forums.

-D

Share this post


Link to post
Share on other sites

The VI uses a private VI Server method that can read linkage information from the .lvclass file on disk. As a general rule, we (that is, LabVIEW R&D) password-protect any VIs that contain private functionality when we post them on public forums.

-D

Will this VI be part of LV2010 or is it allready in LV2009? -on 8.6 for now...

Share this post


Link to post
Share on other sites

Will this VI be part of LV2010 or is it allready in LV2009? -on 8.6 for now...

To my knowledge, this VI does not ship with LabVIEW. I wrote it myself for this thread back in '08, and it's been sitting in my "VI_Utils" folder on my computer ever since. :)

-D

Share this post


Link to post
Share on other sites

To my knowledge, this VI does not ship with LabVIEW. I wrote it myself for this thread back in '08, and it's been sitting in my "VI_Utils" folder on my computer ever since. smile.gif

-D

Darren,

I find myself creating decendent classes quite often and have wanted to automate the creation of these (using vi scripiting.) Do you have any fancy private VI's that would assist me in doing this?

~Jon

Share this post


Link to post
Share on other sites

I find myself creating decendent classes quite often and have wanted to automate the creation of these (using vi scripiting.) Do you have any fancy private VI's that would assist me in doing this?

There is a private property of the LVClassLibrary class called "ParentClass" that lets you set the parent of a given LV Class. I asked the architect of LV Classes about this property, and he said:

"The ParentClass property should have been public all along. It is public in LV 2010."

So I see no reason not to share it. Here's a VI saved in 8.6 that contains the applicable property nodes.

-D

ParentClass Property.vi

Share this post


Link to post
Share on other sites

There is a private property of the LVClassLibrary class called "ParentClass" that lets you set the parent of a given LV Class. I asked the architect of LV Classes about this property, and he said:

"The ParentClass property should have been public all along. It is public in LV 2010."

So I see no reason not to share it. Here's a VI saved in 8.6 that contains the applicable property nodes.

-D

Great, now I can upgrade the LVClass API in CR to its latest version without infringing some taboo. ;)

Share this post


Link to post
Share on other sites

How is the LVClass object reference generated for this property node?

Best regards, Chris

Share this post


Link to post
Share on other sites

How is the LVClass object reference generated for this property node?

Here's the easiest way I can think of:

post-4441-127592710998_thumb.png

-D

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.