open62541 Documentation Release 1.0.5-1-g982f0796

The open62541 authors

January 05, 2021

Contents

1 Introduction 1 1.1 OPC Unified Architecture...... 1 1.2 open62541 Features...... 2 1.3 Getting Help...... 2 1.4 Contributing...... 2

2 Building open62541 5 2.1 Building the Library...... 5 2.2 Build Options...... 7 2.3 Building the Examples...... 10 2.4 Building for specific architectures...... 10

3 Installing open62541 13 3.1 Manual installation...... 13 3.2 Prebuilt packages...... 14

4 Tutorials 15 4.1 Working with Data Types...... 15 4.2 Building a Simple Server...... 17 4.3 Adding Variables to a Server...... 18 4.4 Connecting a Variable with a Physical Process...... 20 4.5 Working with Variable Types...... 23 4.6 Working with Objects and Object Types...... 25 4.7 Adding Methods to Objects...... 31 4.8 Observing Attributes with Local MonitoredItems...... 34 4.9 Generating events...... 35 4.10 Building a Simple Client...... 37 4.11 Working with Publish/Subscribe...... 38

5 Protocol 43 5.1 Establishing a Connection...... 43 5.2 Structure of a protocol message...... 44

6 Data Types 47 6.1 Builtin Types...... 47 6.2 Generic Type Handling...... 59 6.3 Array handling...... 61 6.4 Random Number Generator...... 62 6.5 Generated Data Type Definitions...... 62

7 Services 103 7.1 Discovery Service Set...... 103 7.2 SecureChannel Service Set...... 104

i 7.3 Session Service Set...... 104 7.4 NodeManagement Service Set...... 105 7.5 View Service Set...... 106 7.6 Query Service Set...... 107 7.7 Attribute Service Set...... 107 7.8 Method Service Set...... 108 7.9 MonitoredItem Service Set...... 109 7.10 Subscription Service Set...... 109

8 Information Modelling 113 8.1 Base Node Attributes...... 113 8.2 VariableNode...... 114 8.3 VariableTypeNode...... 115 8.4 MethodNode...... 116 8.5 ObjectNode...... 116 8.6 ObjectTypeNode...... 116 8.7 ReferenceTypeNode...... 116 8.8 DataTypeNode...... 117 8.9 ViewNode...... 118

9 Nodestore Plugin API 119

10 Node Handling 121

11 Server 123 11.1 Server Configuration...... 123 11.2 Server Lifecycle...... 126 11.3 Timed Callbacks...... 127 11.4 Reading and Writing Node Attributes...... 128 11.5 Browsing...... 133 11.6 Discovery...... 134 11.7 Information Model Callbacks...... 135 11.8 Interacting with Objects...... 141 11.9 Node Addition and Deletion...... 141 11.10 Reference Management...... 145 11.11 Events...... 146 11.12 Utility Functions...... 147

12 Client 149 12.1 Client Configuration...... 149 12.2 Client Lifecycle...... 151 12.3 Connect to a Server...... 151 12.4 Discovery...... 152 12.5 Services...... 153 12.6 Asynchronous Services...... 156 12.7 Timed Callbacks...... 157

13 Standard-Defined Constants 173 13.1 Attribute Id...... 173 13.2 Access Level Masks...... 173 13.3 Write Masks...... 174 13.4 ValueRanks...... 174

14 Internal Constants 175 14.1 Rule Handling...... 175 14.2 Order...... 175

15 XML Nodeset Compiler 177 15.1 Getting started...... 177 ii 15.2 Creating object instances...... 182 15.3 Combination of multiple nodesets...... 183

16 Internals 187 16.1 StatusCodes...... 187 16.2 Networking Plugin API...... 198 16.3 Access Control Plugin API...... 201 16.4 Logging Plugin API...... 202 16.5 PubSub Connection Plugin API...... 204 16.6 Publish/Subscribe...... 205

iii iv CHAPTER 1

Introduction

open62541 (http://open62541.org) is an open source and free implementation of OPC UA (OPC Unified Architec- ture) written in the common subset of the C99 and ++98 languages. The library is usable with all major compilers and provides the necessary tools to implement dedicated OPC UA clients and servers, or to integrate OPC UA- based communication into existing applications. open62541 library is platform independent. All platform-specific functionality is implemented via exchangeable plugins. Plugin implementations are provided for the major oper- ating systems. open62541 is licensed under the