Skip to content

C++ and C++/CLI extension for the open62541.org implementation of OPC UA

License

Notifications You must be signed in to change notification settings

jurihock/reopen62541

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reopen62541

reopen62541 is an attempt to extend the great open62541 by the C++17 and C++/CLI interfaces, to hopefully minimize the syntactic overhead as well as provide a certain syntactic uniformity in C++ and C# environments. The goal is however not to support the complete feature set of the open62541 implementation or even all specified OPC UA nuances. In other words, reopen62541 is not designed for complexity, but for simplicity.

Features

  • Basic server and client instance management
  • Callback based log message forwarding
  • Callback based variable and method binding
  • Template/generics based data type conversion
  • Support of main data types like boolean, integers, floats and strings
  • Support of scalars and vectors
  • Unicode string handling

Examples

Create server and client instances

C++ C#
ua::server server;
server.run_async(); server.shutdown();
ua::client client;
client.connect(); client.disconnect();
var server = new UA.Server();
server.RunAsync(); server.Shutdown();
var client = new UA.Client();
client.Connect(); client.Disconnect();

Create objects and folders

C++ C#
server.add_object(
  "MyObject",
  "The root object");
server.add_folder( "MyFolder", "Folder inside object", { "MyObject" });
server.AddObject(
  "MyObject",
  "The root object");
server.AddFolder( "MyFolder", "Folder inside object", new[] { "MyObject" });

Implement variables on the server side

C++ C#
int variable = 0;
server.add_variable<int>( "MyVariable", "Variable inside folder", { "MyObject", "MyFolder" }, [&](ua::variant& output) { output.set<int>(variable); }, [&](const ua::variant& input) { variable = input.get<int>(); });
int variable = 0;
server.AddVariable<int>( "MyVariable", "Variable inside folder", new[] { "MyObject", "MyFolder" }, output => { output.Set<int>(variable); }, input => { variable = input.Get<int>(); });

Access variables on the client side

C++ C#
int variable = 0;
variable = client.get<int>( "MyVariable", { "MyObject", "MyFolder" });
client.set<int>( "MyVariable", { "MyObject", "MyFolder" }, variable);
int variable = 0;
variable = client.Get<int>( "MyVariable", new[] { "MyObject", "MyFolder" });
client.Set<int>( "MyVariable", new[] { "MyObject", "MyFolder" }, variable);

License

This Source Code Form is subject to the terms of the Mozilla Public License 2.0. The file LICENSE contains a copy of the MPL. Alternatively obtain another one at https://mozilla.org/MPL/2.0.

Releases

No releases published