Part 2: Using an OPC UA Server
- Updated2025-10-28
- 8 minute(s) read
In part 2 of this tutorial, you complete the following tasks:
- Constructing an address space
- Reading and writing the value of a node
- Registering and unregistering an OPC UA server with the UA Local Discovery Server (LDS)
- Reading, updating, and deleting the history data of a node
- Reading the history events of a condition
- Updating and deleting the history events of a condition
Constructing an Address Space
- Folders
- Items
- Properties
- Notifiers
- Conditions
Constructing an address space includes the following tasks:
- Creating a folder in an address space
- Adding a notifier as a child to the folder
- Adding a source node to a notifier
- Adding a condition node to the notifier
- Adding an item as a child to the folder
- Adding a property to an item
What to Use
To create a folder in an address space, use the following objects:
| Add Folder VI | Add Notifier VI | Add Item VI | Add Condition VI | Add Property VI |
|
|
|
|
|
What to Do
To construct an address space for an OPC UA server, create the following block diagram:
The following list describes important details about the previous diagram:
- The Add Folder VI creates a folder named Folder1.
- The Add Notifier VI adds a notifier named Dialog Notifier. The Add Item VI adds an item named Source Node to Dialog Notifier.
- The Add Condition VI adds a dialog condition node to the address space.
- The Add Item VI creates an item named Item at the top level of the address space. The Add Property VI adds a property named Property to Item.
- (Optional) The Delete
Node
VI deletes the following nodes:
- The Dialog Notifier node.
- Source Node, which is the child source node of the Dialog Notifier node.
- Dialog Condition, which is the child condition node of the Dialog Notifier node.
- Add nodes to the UPC UA server
- Change the locations of nodes
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 on an OPC UA server, use the following objects:
| Add Folder VI | Add Item VI | Add Property VI | Read VI | 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.
The following list describes important details about the previous diagram:
- The Read VI reads the value, timestamp, and status of Item1.
- The Write VI writes the 1234 value and the Good status to the item that the Add Item VI created.
Registering and Unregistering an OPC UA Server with the LDS
You can use the OPC UA server VIs to register an OPC UA server with the LDS. You can also unregister the OPC UA server with the LDS.
What to Use
To register or unregister an OPC UA server with the LDS, use the following objects:
| Register Server VI | Unregister Server VI |
|
|
What to Do
To register or unregister the OPC UA server with the LDS, create the following block diagram:
The following list describes important details about the previous diagram:
- The server only trusts a valid LDS certificate file. local discovery server certificate file specifies the file path of the certificate file that the LDS uses. You must ensure that the OPC UA server and LDS trust each other. Place the server certificate file in a folder that the LDS public key infrastructure trusts.
- The Register Server VI registers the OPC UA server with the LDS. You must use this VI before the server starts. This VI registers the server to LDS after the server starts.
- The Unregister Server VI unregisters the OPC UA server with the LDS. This VI sends the offline registration to the LDS after the server stops. To register the server with the LDS after the server starts again, you must use the Register Server VI.
Reading, Updating, and Deleting History Data
- Device data
- Calculated data
- Status information
- Dynamically changing system data
- Diagnostic data
What to Use
To read, update, and delete history data, use the following objects:
| Add Folder VI | Add Item VI | Write VI | History Data Read VI | History Data Update VI | History Data Delete VI |
|
|
|
|
|
|
What to Do
To read, update, and delete history data, create the following block diagram:
The following list describes important details about the previous diagram:
- The History Data Read VI reads the history data of Item1 within a time range.
- The History Data Update VI updates the history data of Item1 at a specific timestamp.
- The History Data Delete VI deletes the history data of Item1.
Reading History Events
- Notifications
- System alarms
- Operator action events
- System triggers
What to Use
To read history events, use the following objects:
| Add Notifier VI | Add Item VI | Write VI | Add Condition VI | History Event Read VI |
|
|
|
|
|
What to Do
To read history events, create the following block diagram:
The following list describes important details about the previous diagram:
- The Add Notifier VI adds a notifier to the OPC UA server. To establish an event hierarchy, you can add a condition node and a source node as child nodes to a notifier.
- The Write VI writes a FALSE value to the Source Node. This action triggers an off-normal alarm, because the updated value of the Source Node does not match the value of the Normal State Node.
- The History Event Read VI reads history events from the notifier.
Updating and Deleting History Events
- Notifications
- System alarms
- Operator action events
- System triggers
What to Use
To update and to delete history events, use the following objects:
| Add Notifier VI | Add Item VI | Write VI | Add Condition VI | History Event Update VI | History Event Delete VI |
|
|
|
|
|
|
What to Do
To update and to delete history events, create the following block diagram:
The following list describes important details about the previous diagram:
- The History Event Update VI updates history events from the notifier.
- The History Event Delete VI deletes history events from the notifier.