LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dr. Damien's Development - Working With LabVIEW Classes

LabVIEW classes were introduced in LabVIEW 8.2 and have been steadily improved at each release. LabVIEW 2010 allows users to create properties for the class. This is one of quite a few features designed to make development of LabVIEW classes much easier. Let's look at some of them.

 

Icon Handling

 

When developing LabVIEW objects, you will be creating an enormous number of icons to match the large number of small VIs you will be creating. To help this, one of the first things you need to do when creating an object is to change the object icon to your default “boilerplate” icon. Any VIs created for this object using methods described below will use this icon as the starting point, making creating the final icon much easier. The new icon editor, helps, as well. The “boilerplate” image, by default, will be on a separate layer from the rest of your icon, making multiple changes fairly easy and safe. Your base image will usually be untouched. If you have several base images you would like to use, you can save them as templates and they are a click away from being your base image.

 

The glyphs feature of the new editor also speeds icon creation. Typing a keyword in the filter box usually brings up one or two options. If not, Google image search, especially if limited to icons, can find many more. You can add to your glyph library by placing these new icons in the glyph directories. You can find where this directory is by choosing Tools»List Glyphs and Icon Templates while in the icon editor. Give your new glyphs descriptive names, since the search function keys off the names. Do not forget to periodically get updates to the glyph library. Select Tools»Synchronize with ni.com Icon Library to do this.

 

Note that the new icon editor can be modified and replaced. It is an unlocked VI. If this interests you, check out this thread on the LAVA forum.

 

Creating Accessors

 

Most classes end up with a accessor function to read and write most of the data members. LabVIEW automates the creation of these accessor functions. Right click on the object in the project and select New»VI for Data Member Access.... This will bring up a dialog from which you can select the data members you wish to create accessors for, what type of accessors these will be (read, write, or both) and static/dynamic dispatching. In LabVIEW 2010, notice the new checkbox — Make available through Property Nodes. Clicking this allows you to access your new methods through LabVIEW property nodes, which can be a huge space saver. Wire your class into a property node and the accessor methods will show up as properties.

 

Classes created prior to LabVIEW 2010 can be updated so they support properties. Right click the class in the project and select New»Property Definition Folder. Name it appropriately and drag the appropriate accessor VIs into it. The property will be named for the folder, not the VIs.

 

Code generation for the accessor methods uses templates which can be replaced by those of your choosing, allowing you to save a lot of time if you do not like the standard templates. See Darren’s Nugget on the topic for details. Make sure you store these templates in another location so they can be refreshed if you reinstall or upgrade LabVIEW.



Do you have any tips you would like to share?

Message 1 of 3
(3,181 Views)

Hey Dr. Damien,

 

Nice tidbit.  I have been working with these for a little while and think they are incredibly useful.  That being said, it is not clear to me that there is a way to write a description for the given property such that when you hover over the node you will see the description while developing - have I missed something?  Is there a way to do this? 

 

Peace, Matt

0 Kudos
Message 2 of 3
(2,946 Views)

Anything you put in the VI documentation will show up in the context help window.  However, I don't think there is a way to get hover help on the node itself.  I will make further inquiries.  You may want to consider asking for this on the LabVIEW Idea Exchange.

0 Kudos
Message 3 of 3
(2,902 Views)