LabVIEW Walkthrough: Modifying a System Definition File

NI VeriStand 2018 Help

Edition Date: May 2018

Part Number: 372846M-01

»View Product Info
Download Help (Windows Only)

Parent Topic: Programming with System Definition API in LabVIEW

You can use LabVIEW to access the NI VeriStand System Definition .NET API and programmatically control operation of the System Explorer window.

Note  Creating and communicating with .NET objects in LabVIEW requires the .NET CLR 4.0 that installs with LabVIEW. You must use a .NET 2.0 configuration file if you want to load .NET 2.0 mixed-mode assemblies.

The following sections provide an example of using the System Definition API to remove a CAN port from a system definition file and add a new one with an associated XNET database, CAN cluster, and incoming frame. As you follow the example, notice that the hierarchy of classes reflect the hierarchy of nodes that appear in the System Explorer window, shown as follows.

Part 1: Opening the File and Finding the First Target

The initial part of this example code programmatically opens an existing system definition file and begins navigating the nodes that all system definitions contain.


Open an existing .nivssdf file from disk by initializing a new instance of the SystemDefinition class.


Find the first target in the system definition file by:
  1. Obtaining the references to the following items in the system definition file, in descending order:
    1. The root-level item (via Root property)
    2. The Targets section (via GetTargets method)
    3. All targets under the Targets section (returned by GetTargetList method as an array of references)
  2. Indexing the first element from the array of target references.
Tip  Instead of using multiple cascading Property and Invoke Nodes, you can use dottable properties, a shorthand method for accessing some references.

Note that the SystemDefinition constructor, used to open the existing system definition file in step 1, is overloaded.

SystemDefinition(String) SystemDefinition(String, String, String, String, String, String, String)
Opens an existing system definition file. Creates a new system definition file with specified configuration options.

Related Links

SystemDefinition Constructor

Part 2: Navigating the System Definition Hierarchy to Add and Remove CAN Ports

After obtaining a reference to the target in the system definition file, the remainder of the example code navigates the nodes that appear under the target


Continue using Invoke Nodes to traverse the hierarchy of nodes under the Targets section until reaching the CAN section under the first chassis. Obtain an array of references to all CAN ports in that section.
Tip  Instead of traversing the hierarchy of System Definition API classes, you can find and return a reference for a specific node.


Remove the first CAN port from the CAN section.


Associate an existing XNET database with a new CAN port by initializing new instances of the Database and CANPort classes. Notice how the CANPort constructor contains a LinkedDatabase parameter that requires you to specify the XNET database associated with the port.


Traverse the hierarchy of sections that will appear under the new CAN port to get the Single-Point section. Add a new signal-based frame associated with the XNET database from step 5, to the Single-Point section.


Add the new CAN port to the CAN section of the system definition file.


Save the system definition file to disk.

Related Links

Programming with the System Definition API in LabVIEW

Navigating the System Definition API

Finding LabVIEW Code Examples

WAS THIS ARTICLE HELPFUL?

Not Helpful