LabVIEW OPC UA Toolkit API Reference

Content Type
Programming Language
Current manual

Part 4: Using an OPC UA Client (OPC UA Toolkit)

Part 4: Using an OPC UA Client (OPC UA Toolkit)

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

An OPC UA server uses an address space to store data. The address space consists of nodes that include folders, items, properties, notifiers, and 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 and get the ID, name, and type of all the child nodes of this node.

What to Use

Use the following object to browse a node:

What to Do

Create the following block diagram to browse a node of an address space to get the reference type, ID, name, class, and type of all the child nodes of this node.

The following list describes important details about the previous diagram:

The Forward Browse VI browses a node whose ID is ns=2;s=Folder1.
The browse result output of the Forward Browse VI returns the reference type, ID, name, class, and type of all the child nodes of this node.

Getting the Attributes of a Node

The attributes of a node include the name, node type, data type, and access attribute of the node. You can use the OPC UA Client VIs to get the attributes of a node. The node attributes include the node name, the node class, the data type, the access level, and the description.

What to Use

Use the following object to get the attributes of a node:

What to Do

Create the following block diagram to get the attributes of a node.

The following list describes important details about the previous diagram:

The Get Node Attribute VI gets the attributes of a node whose ID is ns=2;s=Folder1.
The node attribute output of the Get Node Attribute VI returns the attributes of the node whose ID is ns=2;s=Folder1. The attributes contain the name, class, data type, access level, and description of the node.

Reading and Writing the Value of a Node

An OPC UA server allows an OPC UA client to read and update the data in an address space of the OPC UA server. You can use the OPC UA Client VIs to read the value of a node and write a value to a node in an OPC UA server.

What to Use

Use the following objects to read and write the value of a node:

What to Do

Create the following block diagram to read the value, timestamp, and status of a node and write a value to the node on an OPC UA server.

The following list describes important details about the previous diagram:

The Multiple Read VI reads the value, timestamp, and status of the node whose ID is ns=2;s=Folder1.Item1.Property.
The Multiple Write VI writes a value, 1234, and status, Good, to the node whose ID is ns=2;s=Folder1.Item1.Property.

Reading History Data and Events

You can use the Historical Access VIs of the OPC UA Client VIs to read history data from nodes and history events from notifiers. History data refers to the time series data stored for a node that supports historical access. Examples of history data include device data, calculated data, status information, dynamically changing system data, and diagnostic data. History events refer to the time series events stored in some historical system. Examples of such data include notifications, system alarms, operator action events, and system triggers.

What to Use

Use the following objects to read history data and events:

What to Do

Create the following block diagram to read the history data and events.

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. When the nodes that an OPC UA client subscribes to incur data changes, the OPC UA server collects the data change and sends a notification message to the OPC UA client.

What to Use

Use the following objects to create a data subscription:

What to Do

Create the following block diagram to create a data subscription to the nodes of an OPC UA server.

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, you must first 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 and 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. You can wire the subscription ID out output of the Create Subscription VI to the subscription ID in input of the Delete Monitored Nodes VI to delete monitored nodes. 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 the events and sends a notification message to the OPC UA client.

What to Use

Use the following objects to create an event subscription:

What to Do

Create the following block diagram to create an event subscription to the notifier of an OPC UA server.

The following list describes important details about the previous diagram:

To create an event subscription to monitor the notifier of the OPC UA server, you must first 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 of 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 and 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. You can wire the subscription ID out output of the Create Subscription VI to the subscription ID in input of the Delete Monitored Nodes VI to delete monitored nodes. 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

Use the following objects to respond to an acknowledgeable condition:

What to Do

Create the following block diagram to change the states of conditions and alarms.

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 has to 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

Use the following objects to shelve and unshelve an alarm:

What to Do

Create the following block diagram to shelve and unshelve an alarm.

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 shelving time is 0, Shelve Alarm Condition VI shelves an alarm for the maximum time that an alarm condition is in shelved state. 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.
Previous
Establishing Connections between an OPC UA Server and an OPC UA Client
Home
Creating an OPC UA Server and an OPC UA Client
Was this information helpful?