Example Code

LabVIEW Class Provider Shell: Implement Plugin Mechanism for LabVIEW Class

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW 2019 SP1

Code and Documents

Attachment

Description

This library implements a plugin mechanism for LabVIEW Class. It loads LabVIEW classes from a disk path and converts them to the parent class.

 

1 API

 

1.1 Key API

 

LoadLvClasses.vim loads LabVIEW classes from a disk path and converts them to the parent class.

 

  • Path specifies the absolute path to the classes to load. Note: Folders that start with _ or . will be ignored.
  • ClassType specifies the target class type to load. Those classes that are children of the ClassType will be loaded, and the returned classes will be converted to ClassType.
  • milliseconds to wait specifies the time, in milliseconds, that the function waits for loading the classes. The default is -1, indicating to wait until done.
  • error in describes error conditions that occur before this node runs.
  • Loaded Classes return the loaded classes.
  • error out contains error information.

photo.jpg

 

1.2 Utilities

 

The following utilities provide tools to obtain corresponding LabVIEW class information.

 

  • Get LV Class ParentName.vim
  • Get LV Class Version.vim
  • Get LV Class Hierarchy.vim
  • Get LV Class Description.vim

photo.jpg

 

2 Example

 

The Calculator Example provided by the library demonstrates the plugin mechanism of LabVIEW Class Provider. The math functions of this calculator are loaded dynamically as plugins. Therefore, the calculator has very good scalability.

 

photo.jpg

 

 

3 Distribution Consideration

 

This library supports the following forms of code distribution,

 

1. The shell class is distributed as source code (*.lvclass, *.llb).
2. The shell class is distributed as a packed library (*.lvlibp).

 

In both situations, the plugin classes can be distributed as source code, packed library, or a mix of both. Notice that the plugin classes must inherit the shell class, whether as source code or as packed library. In the usual situation, the shell class is often distributed as a packed library (*.lvlibp), so that the shell functions are fixed and uncontaminated. And after the shell is released the plugins can be freely designed by different developers.

 

 

 

 

How to Use

Download the attachment, and use VI Package Manager to install the library.

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors