Accessing device
variables
Overview
Device variables can be accessed by the Workbench, triggers, and other features when the device is in a Started state.
The Workbench Variables tab displays
all started devices, with controls to expand and collapse
the device's internal structure and variables. When one or
more variable rows are selected, the Read
and Write function buttons are enabled.
The Security feature
can be used to control a user's access to features,
including devices and device variables.
For physical devices, the device and its programming tools
may have their own security access control features to
limit read and/or write access to its variables.
Triggers that execute on the same node as the device definition have access to all started devices' variables for use in the trigger actions that make up the application logic of the M2M solution.
Trigger actions have a concept of a source variable(s) and a destination variable(s). The source variables are read from the device and the destination variables are written to the device.
Using a Set action as an example:
- The Source variable, aInt4, is an integer (INT4) in the device named GlobalVariables
- The Destination variable,
DeviceID, is an integer (INT8) in the same
device.
In additional to trigger actions, device variables are also accessed by the features that are part of the application logic, including:
- Some trigger event types
- Data mappings
- Variable groups
Using the Variables tab
The Variables tab lists the started devices for the current node. A device must be in the Started state to be included in the Variables tab.
To use the Variables tab, follow these steps:
- From Workbench left pane, expand the node whose device variables you want to view or change.
- Select the Devices icon.
- From the right pane, select the
Variables tab.
The Variables tab appears as the right pane. - For any device, use the plus sign and minus sign to expand and collapse the device's internal structure and variables.
The Variables tab provides these columns:
Column name | Description |
---|---|
Name | This is the name of the device. You will not see devices listed on the Variables tab if they are not in a Started state. When the device's structure is expanded, the internal structure and variables are displayed. |
Type | When a device row is selected, this
is the type of device. When a device variable row is selected, this is the type of the device variable. For devices that support structures and user defined types, this is the type of the structure or the user defined type. |
Value | The current value of the device variable. If you have write access, you can select the device variable and then change (write) its value. |
Description | The description of the device variable as set in the device's programming tool. |
You can also right-click on a row to display a pop-up
menu with options according to the row type and the user's
access.
Searching for Variables
At the bottom of the variable panel is a field for searching variable names and descriptions. Enter text in this field and hit enter or press the button to search forward in the tree for any variable name or description containing this text. The search will start from your currently selected item in the tree (or the beginning of the tree if nothing selected). Press the button to search backward from the current selection.
The field will flash red if no match is found.
The variables of the device is displayed when you expand the tree in the Variables panel. Therefore this will only search within devices that have already been expanded at least once.
Variable length
A variable's fully qualified name can be a maximum of 128 characters long. The variable fully qualified name consists of the parent structure names plus the variable name. Renaming a variable to fit the 128 character limit will allow you to read and write to the variable. A variable with a fully qualified name greater than 128 characters long will not be able to be accessed, and will return an "Error: Variable does not exist" error.