Last updated on September 5, 2020
This tutorial is separated into multiple posts and provides a complete walkthrough from creating a custom OPC UA information model, compiling this model into an OPC UA NodeSet2.xml file, and then using the open62541 OPC UA Stack to create a running OPC UA server.
Structure of the Tutorial
The guide is organized in several articles. Each article covers a single step of all steps required to generate a custom UANodeSet and run it on an open62541 server. All steps are linked here:
- Setup open62541 on Linux & Build first server
- Setup UA-ModelCompiler with Visual Studio
- Alternative: Setup UA-ModelCompiler on Linux
- Setup Visual Studio as ModelDesign Editor
- Alternative: Additional Software which can be used as ModelDesign Editor
- Alternative: Overview and Setup of OPC UA NodeSet Editors
- ModelDesign Explained – An Overview on the Concepts
- OPC UA ModelDesign Best Practices
- Writing a ModelDesign file
- Alternative: Edit UANodeSet files with Free OPCUA Modeler
- Compile ModelDesign to UANodeSet
- Connect Application Variables to open62541
- Compile open62541 server with custom UANodeSet
- Using UAExpert to connect to an OPC UA server
The articles are organized according to the following graph:
All steps are assigned to different stages (
APPLICATION) of the complete process.
The steps in the top-half area (
SETUP) describe initial setup procedures of all required software tools.
The dotted (
...) paths in the guide mark an alternative workflow that substitutes the two-step process of editing ModelDesign files and compiling them to UANodeSet files with a single-step process of directly editing UANodeSet files. Pick either of both approaches. The result will be an UANodeSet file in both cases.
SETUP steps completed, you can start
The steps in the bottom-half area (
MODELING) are horizontally aligned to their matching SETUP steps. They describe how to use the respective tools to design, edit and apply a custom UANodeSet.
The dash-dotted (
-*-) element in the
MODELING area of the graph indicates the process of associating the variables of the ModelDesign with the variables of the application program. While this step is absolutely necessary for any application of OPC UA, it’s not required for editing and testing OPC UA models.
Once set up, this toolchain enables you to develop an OPC UA nodeset by frequently iterating on its design with little effort. If the target nodeset is already well defined, direct editing and compilation of the nodeset C99 source and header files may be more efficient. This is equal to omitting the
EDITING stage and takeing the steps of the
APPLICATION stage only. See https://open62541.org/doc/current/tutorial_server_variable.html and it’s open62541 source code pendant
tutorial_server_variable.c for reference.
This walkthrough was implemented with the following tools:
- Windows 10 with Hyper-V
- Debian as Hyper-V guest
- Visual Studio 2019 Community Edition
- git, bash and PowerShell
Whenever applicable, alternative solutions and tools will be mentioned.
Commonly used Reference Material
The following links expose the main resources used in this guide. More specific links will be provided throughout the guide.
- its submodule https://github.com/OPCFoundation/UA-Nodeset
- OPC UA Standard Documents (Web and PDF format hold the same information, but PDF format requires a free account)
This tutorial is published with the kind permission of Harald Eschbach.