|Download Help (Windows Only)|
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:
The remaining steps in this topic illustrate the code required to implement the previously listed functionality.
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.
|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.|
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:
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: