Skip to content

Reference

Sample applications

Fully runnable clients and servers with the OPC UA .NET SDK in C# and VB.NET, filterable by kind and language, with links to GitHub.

This content was machine translated and may contain errors. Read in German

Reference

Sample applications ​

The sample applications in the opcuanet-samples repository on GitHub are complete programs that you can clone, run, and use as a starting point for your own applications. Most clients have a matching server in the same area. In that case, start the server first and then the client.

To run a sample, for example the client Basic/Client:

sh
git clone https://github.com/Traeger-GmbH/opcuanet-samples.git
cd opcuanet-samples
dotnet run --project cs/Basic/Server -f net8.0
dotnet run --project cs/Basic/Client -f net8.0

Run the server and the client in two separate consoles. The samples use the SDK in evaluation mode, that is, without a license key.

Type
Language
68 samples

Basics

  • ClientClient

    This sample demonstrates how to implement a primitive OPC UA client.

  • ServerServer

    This sample demonstrates how to implement a primitive OPC UA server.

  • ClientClient.AE

    This sample demonstrates how to perform handling of Alarm + Events (AE) on the nodes provided by the OPC UA server.

  • ServerServer.AE

    This sample demonstrates how to setup an OPC UA server to provide AE to its nodes provided.

  • ClientClient.Authentication

    This sample demonstrates how to authenticate at an OPC UA server using user name and password.

  • ServerServer.Authentication

    This sample demonstrates how to setup an OPC UA server with a UserName policy using the UserName ACL for custom user name and password authentication.

  • ClientClient.Browsing

    This sample demonstrates how to browse nodes and their attributes provided by the OPC UA server.

  • ClientClient.DataTypes

    This sample demonstrates how to consume structured data types defined and used by the OPC UA server.

  • ServerServer.DataTypes

    This sample demonstrates how to setup an OPC UA server to provide nodes with custom data types.

  • ServerServer.DataTypes.Complex

    This sample demonstrates how to setup an OPC UA server to provide nodes with custom data types which are supplied using subtrees there appropriate.

  • ClientClient.EventTypes

    This sample demonstrates how to subscribe to events of a custom event type and how to access their structured event data through an own event class.

  • ServerServer.EventTypes

    This sample demonstrates how to setup an OPC UA server to provide a custom event type defined in a nodeset. Its events carry structured data and are raised when a client calls the StartJob method.

  • ClientClient.HDA

    This sample demonstrates how to perform history data access (HDA) on the data provided by the OPC UA server.

  • ServerServer.HDA

    This sample demonstrates how to setup an OPC UA server to provide HDA to its nodes provided.

  • ServerServer.HDA.Sql

    This sample demonstrates how to setup an OPC UA server to provide HDA via SQL to its nodes provided.

  • ClientClient.Methods

    This sample demonstrates how to perform method calls using the OPC UA server provided method nodes.

  • ServerServer.Methods

    This sample demonstrates how to setup an OPC UA server to provide method nodes.

  • ServerServer.NodeTypes

    This use case demonstrates how to import and implement custom node types using a nodeset.

Configuration

  • ClientClient.ConfiguredViaCode

    This sample demonstrates how to configure an OPC UA client using in code configuration.

  • ServerServer.ConfiguredViaCode

    This sample demonstrates how to configure an OPC UA server using in code configuration.

  • ClientClient.ConfiguredViaXml

    This sample demonstrates how to configure an OPC UA client using a XML configuration file.

  • ServerServer.ConfiguredViaXml

    This sample demonstrates how to configure an OPC UA server using a XML configuration file.

Node types

  • ClientClient.AnalogItemNode

    This sample demonstrates how to access and work with nodes of the AnalogItemType.

  • ServerServer.AnalogItemNode

    This sample demonstrates how to setup an OPC UA server to provide nodes of the AnalogItemType.

  • ClientClient.DataTypeNode

    This sample demonstrates how to access and work with nodes which use custom data types.

  • ServerServer.DataTypeNode

    This sample demonstrates how to setup an OPC UA server to provide DataTypeNode nodes.

  • ClientClient.MethodNode

    This sample demonstrates how to access and work with method nodes.

  • ServerServer.MethodNode

    This sample demonstrates how to setup an OPC UA server to provide MethodNode nodes.

Subscriptions

  • ClientClient.BulkChanges

    This sample demonstrates how to subscribe to a large number of nodes and process their data changes in a separate consumer thread.

  • ServerServer.BulkChanges

    This sample demonstrates how to setup an OPC UA server that changes the values of a large number of nodes at once in a fixed interval.

  • ClientClient.BulkChanges.HiRes

    This sample demonstrates how to receive data changes of a large number of nodes with minimal latency, using a publishing interval of zero and a callback for each data set.

  • ServerServer.BulkChanges.HiRes

    This sample demonstrates how to configure an OPC UA server for high resolution publishing, to deliver changes of a large number of nodes in intervals of a few milliseconds.

  • ClientClient.HandshakeChanges

    This sample demonstrates how a client reads a block of data as soon as the server signals it as available and confirms its processing through a handshake node.

  • ServerServer.HandshakeChanges

    This sample demonstrates how to setup an OPC UA server that provides blocks of data using a handshake: it signals new data and waits until a client confirms their processing.

Scenarios

  • AppApp.LicenseUsage

    This sample demonstrates how to apply the license keys of the SDK and how to protect them by string encryption when the application is obfuscated, here using Eazfuscator.NET.

  • ClientClient.Blazor

    This sample demonstrates how to connect to an OPC UA server and read node values from a Blazor Server application.

  • ClientClient.ClientAddedNodesWithHistory

    This use case demonstrates how a client adds a variable node with history access to the server and writes values that the server records as history.

  • ServerServer.ClientAddedNodesWithHistory

    This use case implementes the necessary logic required to support nodes which are added through a client application which wants the server to enable historical data.

  • ServerServer.CustomFile

    This use case represents in which way the IOpcFileInfo interface can be used to implement "custom file sources" for a OpcFileNode.

  • ClientClient.DynamicNamespaces

    This use case demonstrates how a client addresses nodes by namespace URI instead of namespace index and renews its subscriptions after each reconnect, so it copes with namespaces that change on the server.

  • ServerServer.DynamicNamespaces

    This use case demonstrates how to provide each namespace through its own node manager and how to restart the server with a different selection of node managers.

  • ServerServer.DynamicNodes

    This use case realizes dynamic nodes which are created on-demand by the server depending on the underlying system needs.

  • ClientClient.GenericEvents

    This use case demonstrates how to receive events of a custom event type without an own class for its fields, using a generic event class that exposes all selected event fields.

  • ServerServer.LightweightEvents

    This use case demonstrates in which way a server can "re-use" a single event node to represent events from different event sources without to define for each source another event node.

  • ClientClient.Localization

    This use case demonstrates how a client requests localized display names and descriptions by specifying its preferred locales.

  • ServerServer.Localization

    This use case demonstrates how to provide display names and descriptions of nodes in several languages using the globalization resources of the server.

  • ServerServer.NodeAccess

    This use case realizes restricted node access using built-in ACL functionality And subclassing for user dependent node metadata.

  • ClientClient.NodeExplorer

    This sample demonstrates how to browse the address space of an OPC UA server and show it as a tree in a Windows Forms application.

  • ServerServer.NodeSet.PackML

    This use case demonstrates how to import and implement an alarm from a nodeset using the companion specification from PackML.

  • ServerServer.NodeSet.Umati.Legacy

    This use case demonstrates how to import and implement an alarm from a nodeset using the companion specification from UMATI.

  • ServerServer.NodeSet.Umati.MachineTool

    This use case demonstrates how to import and implement an alarm from a nodeset using the companion specifications from UMATI: In this case 'MachineTool'.

  • ClientClient.PackML

    This use case demonstrates how to call a method of the PackML companion specification with structured arguments, using data types generated from the PackML nodeset.

  • ServerServer.Playground

    This use case realizes a server which offers different kinds of nodes to easily test client applications against different possible use cases.

  • ClientClient.RecursiveSubscription

    This use case demonstrates how a client adds job nodes below a monitored node and receives the events the server raises for each added node.

  • ServerServer.RecursiveSubscription

    This use case represents in which way a server can monitor newly added nodes, work with them and notify clients about changes on these nodes.

  • ClientClient.SignalR

    This use case demonstrates how to forward data changes of OPC UA nodes to a web browser using an ASP.NET Core SignalR hub.

  • ServerServer.SignalR

    This use case demonstrates how to setup an OPC UA server whose node values change periodically. It provides the nodes that the Client.SignalR sample forwards to the web browser.

  • ServerServer.SimaticNodes

    This use case demonstrates how to define a custom factory for node identifiers to define / use node identifiers using the "SIEMENS SIMATIC" style of dot separated and quoted node names to construct the node identifier of a node.

  • ServerServer.SimaticNodeSet

    This use case demonstrates how to setup an OPC UA server that imports the nodeset of a SIMATIC S7-1500 controller and identifies itself like the server of the controller, e.g. to test clients without the hardware.

  • ClientClient.StateMachine

    This use case demonstrates how a client monitors the current state of a state machine provided by the server.

  • ServerServer.StateMachine

    This use case demonstrates how to implement a finite state machine node with custom states and how the server changes its state.

  • ClientClient.Temperature

    This sample demonstrates how to connect to an OPC UA server and read the value of a node once per second.

  • ServerServer.Temperature

    This sample demonstrates how to setup an OPC UA server that provides a temperature node and updates its value once per second.

  • ClientClient.Umati.Legacy

    This use case demonstrates how to subscribe to the alarms of a machine tool according to the legacy umati information model and read their specific fields.

  • ClientClient.Umati.MachineTool

    This use case demonstrates how to receive and confirm alerts of a machine tool according to the OPC UA companion specification for machine tools (umati).

  • ServerServer.UserIdentities

    This use case demonstrates how generic user identities could be implemented using built-in ACL functionality and how subclassing can be used to define the generic user identities.

Platforms

  • ClientClient.Uwp

    This sample demonstrates how to implement a simple OPC UA client in an UWP Application.

  • ClientClient.Wpf

    This sample demonstrates how to use the OPC UA client in a WPF application to subscribe to a node and show its value.