LabVIEW Class Tools

Table of Contents

LabVIEW classes are powerful but complicated. Use these tools while working with LabVIEW classes.

What’s a LabVIEW Class?

A LabVIEW Class (file extension .lvclass) is a LabVIEW Library with an embedded private data cluster* and special override capabilities. Under the hood, classes are XML files that reference VIs and Controls on disk.

*As of LabVIEW 2020, there are two types of classes: Classes & Interfaces

Classes:

  • Only allow single inheritance
  • Contain a private data cluster
  • Can inherit from multiple Interfaces

Interfaces:

  • Do not have a private data cluster
  • Forces children to override dynamically dipatched VIs (by default)
  • Can inherit from multiple Interfaces

Class terminals on the connector pane have an additional terminal option to “Dynamically Dispatched” which is a fancy term that means to ‘Enable Override’ allowing the inherited class to override the VI’s behaviour.

Class Inheritance

Like many other object oriented languages, LabVIEW classes can inherit from one parent Class and/or multiple parent Interfaces, illistrated here:

Class Hiearchy

In the example above, the ‘Self’ Class inherits from the ‘Parent 1’ Class as well as the ‘Interface 1’ Interface. The ‘Child 1’ & ‘Child 2’ Classes both inherit from the ‘Self’ Class (however, ‘Child 2’ also inherits from the ‘Interface 1’ Interface).

Changing a LabVIEW Class’s inheritance is done through the class’s ‘Inheritance’ property page. To change inheritance, press ‘Change Parent Class’, select the Class from the tree and press ‘Inherit From selected’.

Class Properties - Inheritance

Class Properties - Change Inheritance

This means that all parent dynamically dispatched methods are for overrideable by the child.

Classes in Memory

LabVIEW doesn’t have a built-in function to list all LabVIEW Classes (*.lvclass) in memory that works on both the Development & Run-Time Environments. The built-in methods use VI Scripting which is only available in the Development Environment. This function loads all VIs & Controls in memory and parses the qualified LabVIEW Class filenames programmatically.

Classes in Memory

Download VI

Class Inheritance

Similarly, LabVIEW does not have built-in method to determine a Class’s parent and child inheritances that works in the Run-Time Environment. The follow VI determines the class inheritance hierarchy given an array of class names.

Note: All named classes must be in memory (i.e. class constants on the block diagram). The Development Environment will automatically load all project classes but the Run-Time Engine require the class constants to be somewhere the block diagram.

Class Inheritance

Download VI

Class Get Parent & Children

Again, LabVIEW does not have a built-in way to return the parent and child classes in memory given the qualified class name (*.lvclass). This example combines the examples above to return a class’s parent and children compatible in the Run-Time Environment.

Class Children

Download VI

For example, enter ‘Self.lvclass’ to get the parent and children classes:

Class Hiearchy

Results

Class Children Results