Table Of Contents

Adding Custom Device Item Properties

Last Modified: March 24, 2021

Use VIs on the Item Properties palette to get and set properties of custom device items.

Before you begin, you should understand custom device item properties.

While you can call Item Properties 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. You cannot pass property information from the configuration to the engine after the engine is deployed.

The following image displays the hierarchy of a custom device modified to set and read properties.

This custom device contains several hardware input channels, each with two item properties. They are 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.
  • 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.

To implement this functionality, you have to modify your custom device code.

  1. Modify the following code to set up the Initialization case to initialize the item properties Filter Setting and Input Range in a page VI for a selected channel.

    When an operator selects a custom device channel in System Explorer, 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. If the properties are already initialized, the page VI gets the current values for the properties and displays them on the front panel.

    Node Ptr—Reference to the channel an operator selects in System Explorer.
    Get Item Property VIs—Gets the values for the Filter Setting and Input Range properties of the selected channel and then populates 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.
    spd-note-note
    Note  

    The names of properties are case sensitive strings. To reduce the risk of error, consider storing property names as global variables.

    Get Item Description VI and Get Item Data VI—Get the description and name of the channel or section, and send that information to indicators on the front panel. These VIs are part of the template page VI.

  2. Modify the following code to set up the cases that detect a change of an item property value in a page VI.

    The page VI contains two Value Change event cases, one for the Input Range control and one for the Filter Setting control. 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. The following table shows these cases.

    Control Basic Architecture Purpose
    Input Range Determine the appropriate range of each channel.
    Filter Setting Determines whether to filter each channel
  3. Modify the following code to set up a RT Driver VI to get the property values of Filter Setting and Input Range for each channel.

    Device Reference and Get Item Property VI—References custom device and gets the Device Name item property to pass to the Get Item Reference by Name VI.

    Get Item Reference by Name VI—Searches under the custom device for the Hardware Inputs section and outputs the reference to that section.

    Get Item Children VI—Returns an array containing all the references for all of the children, or items, under the Hardware Inputs section. 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.

    Get Item Property VIs—Returns the values for the Filter Setting and Input Range properties of each channel using the array of channel references.


Recently Viewed Topics