Adding Custom Device Item Properties

NI VeriStand 2018 Help

Edition Date: May 2018

Part Number: 372846M-01

»View Product Info
Download Help (Windows Only)

Parent Topic: Configuring the Appearance and Components of a Custom Device

You can use VIs on the Item Properties palette to get and set properties of custom device items. A custom device item is anything that appears in the System Explorer window configuration tree, such as a channel within a custom device or the custom device itself. While you can call these VIs from any VI within the custom device, you should call them from VIs that run before the engine is deployed, such as in a page VI or your Initialization VI, as you cannot pass property information from the configuration to the engine after the engine is deployed.

To illustrate a common example of how to implement item properties, this topic walks through a theoretical custom device customized to set and read properties. The following image shows the hierarchy of the custom device in the System Explorer window.

This theoretical custom device contains several hardware input channels, each with two item properties, Filter Setting and Input Range. The custom device has the following functionality regarding its properties:

  • When a user selects a channel from the system definition, the configuration page for that channel initializes Filter Setting and Input Range. However, if the properties already have set values, the configuration page displays the values of the properties.
  • The configuration page allows operators to enter new values for each property.
  • Finally, when an operator deploys the custom device, the RT Driver VI gets the value for each item property so the RT Driver VI can use the values.

The remaining steps in this topic illustrate the code required to implement the previously listed functionality.

Related Links

VIs on the Item Properties palette

Custom Device Item Properties

I. Initializing Item Properties in a Page VI

When an operator selects a custom device channel in the System Explorer configuration tree, the page VI associated with that channel or section runs. The page VI then uses a reference to the selected channel or section to get and set the properties for that channel. The following block diagram shows the initialization code of a page VI customized to initialize the properties Filter Setting and Input Range for the selected channel. If the properties are already initialized, the page VI gets the current values for the properties and displays them on the front panel.

  1. Node Ptr is the reference to the channel an operator selects in the System Explorer configuration tree. The Get Item Property VIs use this reference to get the values for the Filter Setting and Input Range properties of the selected channel and then populate the controls on the configuration page with that data. If a value does not already exist, Get Item Property VI initializes the property with Default Value. In this example, the default values are FALSE for Filter Setting and 1 for Input Range.
    Note  The names of properties are case sensitive strings. To reduce the risk of error, consider storing property names as global variables. Refer to the topic on working with property names for more details.
  2. Get Item Description VI and Get Item Data VI are part of the template page VI. These VIs get the description and name of the channel or section, and send that information to indicators on the front panel.

II. Detecting Change of an Item Property Value in a Page VI

In this custom device, operators can change the values of Filter Setting and Input Range through controls on a channel's configuration page in the System Explorer window. In order to support this functionality, the page VI must detect when an operator enters a new value and then update the value of the property. To do so, this page VI contains two Value Change event cases, one for the Input Range control and one for the Filter Setting control, as shown in the following block diagrams:

  1. In this example, the Event structure of the page VI contains two Value Change event cases: one for the Input Range control and one for the Filter Setting control.
  2. If an operator changes the value of the item property using one of these controls, the page VI detects the change in value and the Set Item Property VI sets the new value.

III. Getting Properties in an RT Driver VI

The RT Driver VI of this custom device uses the Filter Setting of each channel to determine whether or not to filter each channel, and the Input Range property to determine the appropriate range of each channel. In order to use the values, the RT Driver VI must first get the values of Filter Setting and Input Range for each channel. The following block diagram shows the code required to get the property values for each channel:

  1. The Device Reference control is the reference to the custom device. The Get Item Property VI uses this reference to get the Device Name item property, and then passes the reference to the Get Item Reference by Name VI.
  2. The Get Item Reference by Name VI searches under the custom device for the Hardware Inputs section, as shown in the hierarchy, and outputs the reference to that section.
  3. Using the reference for the Hardware Inputs section, the Get Item Children VI returns an array containing all the references for all of the children, or items, under that section. As you can see in the hierarchy, channels ADDataFromCh<1...8> appear under Hardware Inputs, so the Get Item Children VI returns an array of references for the channels.
  4. Using the array of channel references, the Get Item Property VIs in the For Loop return the values for the Filter Setting and Input Range properties of each channel.

WAS THIS ARTICLE HELPFUL?

Not Helpful