OPC UA Fundamentals – 1

That first post explains some fundamentals and focus on the very basic building blocks of an OPC UA server.

Possibilities to provide data in OPC UA

One of the main use cases of an OPC UA server is to provide data in a structured and semantic way. There are 3 different ways to provide data in a server to be consumed by the clients. Each way has its advantages and disadvantages and reasons for its existence.

  1. Variable nodes
    It is possible to read a variable, write to a variable or subscribe to variable to be informed of value changes.
  2. Methods
    Methods can be called including input parameters and can deliver a result. So methods can be used to retrieve data or to execute commands.
  3. Events
    It is possible to subscribe to events, which is a different mechanism than subscribing to a variable. Events can also transport data.

As listed, there are more possibilities than just the variable nodes. Another post will focus on the pros and cons and will give advice when to use what.

Everything is a node

An OPC UA Server can be compared to just a bag full of nodes. Everything you can think of is represented as a node. With the only exception of OPC UA Events. There are nodes of all flavors, for example instance nodes, type nodes and reference nodes. Even a data type, like an integer, is a node.

All nodes live happily in the address space and can have relations to each other. As the name suggests, each node can be addressed via its so called NodeId. The NodeId is unique for each node in the address space and consists of two parts, the NamespaceIndex (ns) and the Identifier. All predefined nodes of the OPC UA standard live in the predefined namespace “http://opcfoundation.org/UA/” with Index 0 and have standardized identifiers. For example the NodeId of the string data type node is [ns=0, i=12], which is the same in each OPC UA server.

Node Classes

The different flavors of nodes in an OPC UA server are called node classes. All 8 node classes are briefly introduced.

An Object Type defines a template for a structure of nodes or just a single node. The structure can contain Variables, Methods and Objects.

Objects are instances of an ObjectType. They are structuring elements needed to create the node tree, like folders in the file system and can contain defined node substructures, as defined in the corresponding ObjectType.

The VariableType exists, to not be limited to simple variables. A VariableType can define a variable with subvariables. It is not to be confused with the DataType and is the most unfamiliar concept for the ordinary mortal developer.

A variable contains a value which has a DataType. Depending of its VariableType it can have subvariables. It is one of the three ways to get the valuable data.

A DataType is a data type ;-). There are predefined simple data types like Boolean, String or DateTime and complex data types called structures – like a struct in a programming language. New data types can be defined. The value of a variable has a data types.

A method node represents, as the name implies, a method. A method can have input and output parameters with certain data types. It is one of the three ways to get the valuable data.

ReferenceTypes define different types of relations between nodes. A ReferenceType can be attached to a node and references another node. Using ReferenceTypes the node trees are defined. For example with the “HasChild” ReferenceType.

With views different masks can be put on the address space to provide different views and to not show everything at the same time. Not needed 😉

The OPC UA instance node tree

An OPC UA server exposes its objects, methods and variables via a node tree. It defines the relations between the nodes and can be used by a client to browse (explore) the address space in a structured and meaningful way. The following diagram shows an exemplary tree in two levels of detail. On the left side also the corresponding ObjectTypes (OT) and VariableTypes (VT) are insinuated as well as the yellow dot for the ReferenceType. The right side shows a simplified version.

The next post will focus more on explaining Objects and Variables and will show concrete examples.

Leave a Reply

Your email address will not be published. Required fields are marked *