Part 4: Using an OPC UA Client
- Updated2025-10-28
- 9 minute(s) read
In part 4 of this tutorial, you learn to use an OPC UA client to complete the following tasks:
- Browsing a node
- Getting the attributes of a node
- Reading and writing the value of a node
- Reading history data and events
- Creating a data subscription
- Creating an event subscription
- Responding to an acknowledgeable condition
- Shelving and unshelving an alarm
Browsing a Node
- Folders
- Items
- Properties
- Notifiers
- Conditions
A node ID describes the ID of a node in the address space of the OPC UA server. You can use the OPC UA client VIs to browse a node. Browsing a node allows you to get the ID, name, and type of all the child nodes of this node.
What to Use
To browse a node, use the following object:
| Forward Browse VI |
|
What to Do
- Reference type
- ID
- Name
- Class
- Type of all its child nodes
To browse a node of an address space, create the following block diagram:
The following list describes important details about the previous diagram:
- The Forward Browse VI browses a node with the ns=2;s=Folder1 ID.
- The browse result output of the Forward Browse
VI returns the following information:
- Reference type
- ID
- Name
- Class
- Type of all its child nodes
Getting the Attributes of a Node
- Name
- Type
- Data type
- Access level
- Description
What to Use
To get the attributes of a node, use the following object:
| Get Node Attribute VI |
|
What to Do
To get the attributes of a node, create the following block diagram:
The following list describes important details about the previous diagram:
- The Get Node Attribute VI gets the attributes of a node with the ns=2;s=Folder1 ID.
- The node attribute output of the Get Node
Attribute VI returns the attributes of the node with the
ns=2;s=Folder1 ID. The attributes contain the following
information on the node:
- Name
- Type
- Data type
- Access level
- Description
Reading and Writing the Value of a Node
- Read the value of a node.
- Write a value to a node.
What to Use
To read and to write the value of a node, use the following objects:
| Multiple Read VI | Multiple Write VI |
|
|
What to Do
- Read the value of a node.
- Read the timestamp of a node.
- Read the status of a node.
- Write a value to the node.
To read and to write the value of a node, create the following block diagram:
The following list describes important details about the previous diagram:
- The Multiple Read VI reads the value, timestamp, and status of the node with the ns=2;s=Folder1.Item1.Property ID.
- The Multiple Write VI writes the 1234 value and the Good status to the node with the ns=2;s=Folder1.Item1.Property ID.
Reading History Data and History Events
- Device data
- Calculated data
- Status information
- Dynamically changing system data
- Diagnostic data
- Notifications
- System alarms
- Operator action events
- System triggers
What to Use
To read history data and history events, use the following objects:
| History Data Multiple Read VI | History Event Multiple Read VI |
|
|
What to Do
To read history data and history events, create the following block diagram:
The following list describes important details about the previous diagram:
- The History Data Multiple Read VI reads the history data. num values per nodes specifies the maximum number of values to return over the time range.
- The History Event Multiple Read VI reads the history events.
Creating a Data Subscription
You can use the OPC UA client VIs to create a data subscription to the nodes of an OPC UA server. The OPC UA server collects data changes that happen on a node that the OPC UA client subscribes to. The OPC UA server also sends a notification message about the changes to the OPC UA client.
What to Use
To create a data subscription, use the following objects:
| Create Subscription VI | Add Monitored Data Nodes VI | Delete Monitored Nodes VI | Delete Subscriptions VI |
|
|
|
|
What to Do
To create a data subscription to the nodes of an OPC UA server, create the following block diagram:
The following list describes important details about the previous diagram:
- To create a data subscription to the nodes of the OPC UA server and add nodes to
the subscription, do the following:
- Wire the subscription ID out output of the Create Subscription VI to the subscription ID in input of the Add Monitored Data Nodes VI.
- The node IDs control of the Add Monitored Data Nodes VI specifies an array of node IDs that this VI adds to a subscription.
- The Event Structure handles the data change event. You can wire the OPC UA data change event output of the Create Subscription VI to the event source input of the Register For Events function. You can also wire the event registration refnum output of the Register For Events function to the Event Dynamic Registration terminal of the Event Structure to handle the data change event. Within the While Loop, the Event Structure continuously gets the data change event.
- The Data Change output returns updates of the data on the OPC UA server.
- (Optional) The Delete Monitored Nodes VI deletes monitored nodes from a subscription. To delete monitored nodes, wire the subscription ID out output of the Create Subscription VI to the subscription ID in input of the Delete Monitored Nodes VI. The node IDs control of the Delete Monitored Nodes VI specifies an array of node IDs that this VI deletes from a subscription.
- (Optional) The Delete Subscriptions VI deletes one or more subscriptions. By deleting a subscription, you delete all the monitored nodes from the subscription.
Creating an Event Subscription
You can use the OPC UA client VIs to create an event subscription to the notifier of an OPC UA server. When the notifier that an OPC UA client subscribes to receives event notifications, the OPC UA server collects these events. The the OPC UA server sends a notification message to the OPC UA client.
What to Use
To create an event subscription, use the following objects:
| Create Event Subscription VI | Add Monitored Event Nodes VI | Delete Monitored Nodes VI | Delete Subscriptions VI |
|
|
|
|
What to Do
To create an event subscription to the notifier of an OPC UA server, create the following block diagram:
The following list describes important details about the previous diagram:
- To create an event subscription to monitor the notifier of the OPC UA server, do
the following:
- Wire the subscription ID out output of the Create Event Subscription VI to the subscription ID in input of the Add Monitored Event Nodes VI.
- The node IDs control of the Add Monitored Events Nodes VI specifies an array of node IDs. This array of node IDs corresponds to the notifiers that this VI adds to an event subscription.
- The Event Structure handles the data change event. You can wire the OPC UA condition event output of the Create Event Subscription VI to the event source input of the Register For Events function. You can also wire the event registration refnum output of the Register For Events function to the Event Dynamic Registration terminal of the Event Structure to handle the data change event. Within the While Loop, the Event Structure continuously gets the condition event.
- The condition events output returns event notifications from the OPC UA server.
- (Optional) The Delete Monitored Nodes VI deletes monitored nodes from a subscription. To delete monitored nodes, wire the subscription ID out output of the Create Subscription VI to the subscription ID in input of the Delete Monitored Nodes VI. The node IDs control of the Delete Monitored Nodes VI specifies an array of node IDs that this VI deletes from a subscription.
- (Optional) The Delete Subscriptions VI deletes one or more subscriptions. By deleting a subscription, you delete all the monitored notifiers from the event subscription.
Responding to an Acknowledgeable Condition
You can use the Alarms and Conditions VIs of the OPC UA client VIs to respond to an acknowledgeable condition.
What to Use
To respond to an acknowledgeable condition, use the following objects:
| Create Event Subscription VI | Add Monitored Event Nodes VI | Respond Acknowledgeable Condition VI |
|
|
|
What to Do
To change the states of conditions and alarms, create the following block diagram:
The following list describes important details about the previous diagram:
- The Respond Acknowledgeable Condition VI acknowledges an acknowledgeable condition.
- The Respond Acknowledgeable Condition VI confirms an acknowledgeable condition. A condition must be acknowledged before it is confirmed.
Shelving and Unshelving an Alarm
You can use the Alarms and Conditions VIs of the OPC UA client VIs to shelve and unshelve an alarm.
What to Use
To shelve and unshelve an alarm, use the following objects:
| Create Event Subscription VI | Add Monitored Event Nodes VI | Shelve Alarm Condition VI |
|
|
|
What to Do
To shelve and unshelve an alarm, create the following block diagram:
The following list describes important details about the previous diagram:
- The Timed Shelve instance of the Shelve Alarm Condition VI shelves an alarm for a definite time period. When the shelving time value is set to 0, the Shelve Alarm Condition VI shelves an alarm for the maximum amount of time. The OPC UA client cannot receive events when the alarm is in shelved state, unless the alarm is changed to unshelved or inactive state.
- The unshelve instance of Shelve Alarm Condition VI unshelves an alarm.