|Download Help (Windows Only)|
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.|
You interface with the System Definition API in LabVIEW through the following block diagram nodes:
The following block diagram shows an example of using these three nodes to initialize a new system definition file and return references to components that appear in the System Explorer configuration tree.
To access members of a specific System Definition API class in LabVIEW, first add a Constructor Node to the block diagram. When you add the node, LabVIEW displays the Select .NET Constructor dialog box, which lists all public assemblies in the Global Assembly Cache (GAC). The following figure shows a Constructor Node configured to initialize an instance of the SystemDefinition class from the NationalInstruments.VeriStand.SystemDefinitionAPI assembly.
The Constructors list in this dialog box shows that the SystemDefinition constructor is overloaded. The first overload, with many parameters, creates a new system definition file. The second overload, SystemDefinition(String), opens an existing system definition file whose path you specify. Note that the arguments after the class name correspond to initialization parameters. Constructor Nodes allow you to specify these initialization parameters, as the following block diagram shows.
After you initialize a new instance of a class, wiring the reference output of the Constructor Node to a Property Node allows you to get and set properties in the same class, such as the root-level item in the example block diagram. Wiring a class reference to an Invoke Node allows you to invoke a method in the class, such as the GetTargets method of the Root class in the example.
The hierarchy of classes in the System Definition API corresponds to the hierarchy of nodes that can appear in a system definition file displayed in the System Explorer window. Notice that the hierarchy of classes in the previous block diagram reflects the hierarchy of nodes in the System Explorer window, where XNETAPIExample is the root item that contains the Targets section, which in turn contains the target named Controller.
Some classes contain dottable properties that concatenate with other properties or methods. Dottable properties work the same as cascading multiple Property Nodes together. For example, compare the following code examples that both invoke the GetTargets method to return a reference to the Targets section of a system definition file.
|Cascading Property and Invoke Nodes||
Instead of traversing the hierarchy of System Definition API classes until you reach a specific section, you can use the following methods, which many of the System Definition API classes inherit, to directly find and access a node:
These methods are useful for decreasing the code required to access deeply nested nodes in system definition files. For example, the following block diagram shows the use of the FindNodeByPath method to access the CAN section under the first target in a system definition file.
In the previous block diagram, the FindNodeByPath method returns a BaseNode reference, which represents generic nodes in a system definition file. You must use the To More Specific Class function to typecast the reference to the appropriate class, which is CAN in this case.