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. An address space consists of nodes that include the following elements:
  • 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

Browsing a node allows you to get the following information on the node:
  • 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:

  1. The Forward Browse VI browses a node with the ns=2;s=Folder1 ID.
  2. 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

You can use the OPC UA client VIs to get the attributes of a node. The attributes of a node contain the following information on the 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:

  1. The Get Node Attribute VI gets the attributes of a node with the ns=2;s=Folder1 ID.
  2. 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

An OPC UA server allows an OPC UA client to read and to update data in an address space of the OPC UA server. You can use the OPC UA client VIs to do the following actions in an OPC UA server:
  • 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

Reading and writing the value of a node allows you to do the following actions:
  • 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:

  1. The Multiple Read VI reads the value, timestamp, and status of the node with the ns=2;s=Folder1.Item1.Property ID.
  2. 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

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 that is stored for a node that supports historical access. The following examples are considered history data:
  • Device data
  • Calculated data
  • Status information
  • Dynamically changing system data
  • Diagnostic data
History events refer to the time series events that are stored in some historical system. The following examples are considered history events:
  • 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:

  1. 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.
  2. 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:

  1. 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.
  2. The node IDs control of the Add Monitored Data Nodes VI specifies an array of node IDs that this VI adds to a subscription.
  3. 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.
  4. The Data Change output returns updates of the data on the OPC UA server.
  5. (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.
  6. (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:

  1. 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.
  2. 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.
  3. 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.
  4. The condition events output returns event notifications from the OPC UA server.
  5. (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.
  6. (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:

  1. The Respond Acknowledgeable Condition VI acknowledges an acknowledgeable condition.
  2. 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:

  1. 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.
  2. The unshelve instance of Shelve Alarm Condition VI unshelves an alarm.