OpenG Class Template Developer's Guide

This Guide specifies how new OpenG Class Templates can be created and how a tool supporting OpenG Class Templates should function. If you are not intending to create templates by your self or if you are not writing a tool for OpenG Class Template support, then you do not need to read this document.

File Locations
Common OpenG objects are located under folder

\_OpenG.lib\openg_object

Public probes used by the common classes are located in folder

\_probes\default

Resource files and support files are located under folder

\resource\OpenG\openg_object

Class templates are located under folder

\resource\OpenG\openg_object\class_templates

Class Hierarchy
The OpenG objects follow the class hierarchy described in the picture below. All OpenG objects derive from a root class OpenG_Object.lvclass. This object provides common interfaces for all OpenG objects. Currently there is only one subclass for OpenG_Object, that is OpenG_Reference_Object.lvclass. In the future there will be a class called OpenG_Value_Object for all objects that behave similarly to LabVOOP native objects.

OpenG_Reference_Object.lvclass is a common root class for all OpenG by-reference objects. It provides common functionality and interfaces for all by-reference objects. This functionality includes locking mechanism, debugger, probe, flattening to XML etc.

File Structure
OpenG Object files follow the file structure of LabVIEW lvclass files. However additional tags are added to files to allow automation of object creation, manipulation and class diagram generation.

OpenG Tags
There tags can be divided into two main groups. The class level tags begin with “OpenG.LVClass” string and specify properties at class level. The item level tags begin with “OpenG.ClassItem” and specify properties of individual items. The OpenG tags are specified in separate document “OpenG Object Tags and Variables”.

OpenG Variables
The values of the tags can contain variables that should be interpreted by the automation process. All the variables begin with string “{$OpenG.” and end in character “}”. Like tags, variables can be divided into two classes. The class level variables begin with “{$OpenG.LVClass” and the item level variables begin with “{$OpenG.ClassItem”. The OpenG variables are specified in separate document “OpenG Object Tags and Variables”.

Creating new classes from templates
New classes can be created from OpenG class templates located in the folder

\resource\OpenG\openg_object\class_templates

The automation tools should automate the process of creating new classes based on templates.

Creating a copy of a template
The first action in the process of creating new class from a template is saving a copy of a template using scripting. The copy can be saved into the location user specifies.

Setting up Tags
The next step is to set the tags in the newly created lvclass file.

OpenG.LVClass Tags
The following class level tags need to be set in the newly created lvclass file

OpenG.LVClass.DisplayName
Set this tag to either user defined class display name or to class short name (without library name and file extension) if user has not defined a specific display name.

OpenG.LVClass.IsTemplate
Set OpenG.LVClass.IsTemplate to false (unless user is creating a new template class that’s based on an existing template class).

OpenG.LVClass.IsDerived
Set OpenG.LVClass.IsDerived tag to true. This tag specifies that the newly create class is based on an existing template class.

OpenG.LVClass.ID
Set OpenG.LVClass.ID to the qualified name of the newly created class. The qualified name is the name consisting of the library names into which the class belongs and the class name in the innermost library (MyLib.lvlib:MyClass.lvclass).

OpenG.LVClass.License.Shortname
Delete this tag or set it to user defined value. This tag specifies the name of the license used for the template.

OpenG.LVClass.Template.Path
Set OpenG.LVClass.Template.Path to point to the lvclass file of the template. This tag is used to locate the template file. However this tag is not used to identify the template file but the tag OpenG.LVClass.Template.ID is used for that purpose.

OpenG.LVClass.Template.ID
Set this tag to the value of the template class tag OpenG.LVClass.ID. This tag is used to identify which template is used for this particular class. If OpenG.LVClass.Template.Path points to a template class file but the OpenG.LVClass.Template.ID tag doesn’t match with the template OpenG.LVClass.ID tag, then that particular file is not the template for this class.

OpenG.LVClass.Template.Version
Set OpenG.LVClass.Template.Version tag to the value of the template lvclass version. The version is specified by LabVIEW and can be queried using property node.

OpenG.LVClass.Constructor.Path
Set this tag to point to the file location of the class constructor. The constructor is the first item found for which OpenG.ClassItem.Constructor flag is set to true. There should be only one constructor, however there may be multiple create methods i.e. multiple ways to create objects of the class.

OpenG.ClassItem.Update & OpenG.ClassItem.TemplateInternal
If the tag OpenG.ClassItem.TemplateInternal is true for an item in a newly created class then remove this tag and set tag OpenG.ClassItem.Update to true. For all other items set OpenG.ClassItem.Update to false or remove this tag. Items with OpenG.ClassItem.Update tag set to true should be updated from the template by the automation provider when a new version of the template is available.

Extended name format
Read the tag OpenG.LVClass.ExtendedNameFormat. This tag specifies the file name format of the items that have either a name prefix or name suffix. The name format is specified in a string that in contains OpenG variables.

Renaming files
The files with extended name format needs to be renamed in the newly created class. For each item that needs to be renamed the value of the variables in the string read from tag OpenG.LVClass.ExtendedNameFormat are evaluated and the actual name string is constructed by appending the file extension with preceding “.” to the evaluated string. The file is renamed to this evaluated string value.

For example if OpenG.LVClass.ExtendedNameFormat is the string

{$OpenG.ClassItem.CoreName}_{$OpenG.LVClass.ShortName}

the OpenG.ClassItem.CoreName tag for particular project item is string

Constructor

and the class name is

“MyLib.lvlib:MyClass.lvclass”

Then the name of a this particular VI would be evaluated to

Constructor_MyClass.vi

Relocating files
For all files with OpenG.ClassItem.DefaultFolder tag set, the file needs to be moved to this particular folder.

Modifying constructors
If the inheritance of the class is modified when new class is created the constructor needs to be modified to call the constructor of the new parent class.

For each item in a newly created class with OpenG.ClassItem.Constructor tag set to true, the block diagram needs to be searched for parent constructors. The name and path of the constructor VI that needs to be replaced can be identified by reading OpenG.LVClass.Constructor.Path tag from the parent class of the template class. This subVI calls on the block diagram are then change to calls to the VI specified by new parent class tag OpenG.LVClass.Constructor.Path.

Removing files
The template may contain files that do not belong to the newly created class. These files need to be removed from the newly created class. For each item for which OpenG.ClassItem.TemplatePrivate tag is set to true, remove the item from the new class.

Saving changes
Finally remember to save all changes made.

Renaming a class
When a class is renamed, the extended names need to be reconstructed. See 2.3 for detailed information how to determine the extended names.

Renaming an item
When an item such as a VI or a control is renamed, some care needs to be taken. If OpenG.ClassItem.CoreName tag is defined for the particular item, this CoreName should be changed as well. If the item uses extended name format, see 2.3, then the extended name needs to be re-evaluated and the actual file name should be the extended name. It’s recommended that when renaming an item, the user gives only the core name and the automation software takes care of defining the actual file name. However this is not a strict requirement.

Updating classes from templates
When there is a new version of a template available, classes that are based on this template can be updated from this new version. The following actions needs to be taken to update the class from a new version of a template.

OpenG.LVClass.Template.Version tag
Update OpenG.LVClass.Template.Version tag to the value of the template lvclass version. The version is specified by LabVIEW and can be queried using property node.

Updating items
For each item in the derived class for which OpenG.ClassItem.Update is set to true, update the item from the new version of the template. One way of updating items is the following.

Make sure that the class that needs to be updated is not in memory. Create a copy of the template with the same qualified name as the class that will be updated as described in chapter 2. We shall call this newly created class a “shadow class”. Close the shadow class and make sure it is not in memory.

For each item in the class to be updated for which OpenG.ClassItem.Update tag is set to true, copy the corresponding item from the shadow class overwriting the old item in the class to be updated.

Changing class inheritance
Constructor need to be modified when the inheritance of a class is changed. See paragraph 2.5 for detailed instructions.

Links

 * OpenG Class Templates Discussion Forum - Support, Feature Requests, Bug Reports, and Announcements