Top Related Projects
Open source implementation of OPC UA (OPC Unified Architecture) aka IEC 62541 licensed under Mozilla Public License v2.0
Unlocking the Full Potential of OPC UA with Typescript and NodeJS - http://node-opcua.github.io/
Quick Overview
The UA-.NETStandard repository is an official implementation of the OPC Unified Architecture (OPC UA) standard for .NET Standard. It provides a comprehensive set of libraries and tools for developing OPC UA clients and servers in .NET environments, supporting various platforms and frameworks.
Pros
- Cross-platform compatibility due to .NET Standard implementation
- Comprehensive support for OPC UA features and specifications
- Active development and maintenance by the OPC Foundation
- Extensive documentation and sample applications
Cons
- Steep learning curve for newcomers to OPC UA
- Complex architecture may be overwhelming for simple use cases
- Limited support for older .NET Framework versions
- Performance overhead compared to native implementations
Code Examples
- Creating an OPC UA client and connecting to a server:
using Opc.Ua;
using Opc.Ua.Client;
var config = new ApplicationConfiguration()
{
ApplicationName = "MyClient",
ApplicationUri = "urn:MyClient",
ApplicationType = ApplicationType.Client,
SecurityConfiguration = new SecurityConfiguration { AutoAcceptUntrustedCertificates = true },
TransportConfigurations = new TransportConfigurationCollection(),
TransportQuotas = new TransportQuotas { OperationTimeout = 15000 },
ClientConfiguration = new ClientConfiguration { DefaultSessionTimeout = 60000 }
};
await config.Validate(ApplicationType.Client);
var application = new ApplicationInstance(config);
await application.CheckApplicationInstanceCertificate(false, 0);
using (var session = await Session.Create(config, new ConfiguredEndpoint(null, new EndpointDescription("opc.tcp://localhost:4840")), false, "", 60000, null, null))
{
// Use the session to interact with the server
}
- Reading a value from an OPC UA server:
NodeId nodeId = new NodeId("ns=2;s=MyVariable");
DataValue value = await session.ReadValueAsync(nodeId);
Console.WriteLine($"Value: {value.Value}, StatusCode: {value.StatusCode}");
- Writing a value to an OPC UA server:
NodeId nodeId = new NodeId("ns=2;s=MyVariable");
DataValue newValue = new DataValue(new Variant(42));
StatusCode result = await session.WriteValueAsync(nodeId, newValue);
Console.WriteLine($"Write result: {result}");
Getting Started
-
Install the NuGet package:
dotnet add package OPCFoundation.NetStandard.Opc.Ua
-
Create a new console application and add the following using statements:
using Opc.Ua; using Opc.Ua.Client;
-
Implement a basic OPC UA client as shown in the first code example above.
-
Run your application and connect to an OPC UA server.
Competitor Comparisons
Open source implementation of OPC UA (OPC Unified Architecture) aka IEC 62541 licensed under Mozilla Public License v2.0
Pros of open62541
- Written in C, offering better performance and lower resource usage
- Highly portable, suitable for embedded systems and various platforms
- More flexible and customizable due to its low-level implementation
Cons of open62541
- Steeper learning curve, especially for developers not familiar with C
- Less extensive documentation compared to UA-.NETStandard
- Smaller community and ecosystem compared to the .NET-based alternative
Code Comparison
UA-.NETStandard (C#):
var application = new ApplicationInstance {
ApplicationName = "MyOPCUAClient",
ApplicationType = ApplicationType.Client
};
await application.CheckApplicationInstanceCertificate(false, 2048);
open62541 (C):
UA_Client *client = UA_Client_new();
UA_ClientConfig_setDefault(UA_Client_getConfig(client));
UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
if(retval != UA_STATUSCODE_GOOD) {
UA_Client_delete(client);
return (int)retval;
}
The code snippets demonstrate the initialization of a client application in both libraries. UA-.NETStandard offers a more high-level, object-oriented approach, while open62541 provides a lower-level C implementation, requiring more manual setup but offering finer control over the process.
Unlocking the Full Potential of OPC UA with Typescript and NodeJS - http://node-opcua.github.io/
Pros of node-opcua
- Written in JavaScript, making it easier for web developers to integrate
- Supports both client and server implementations
- Active community and frequent updates
Cons of node-opcua
- May have performance limitations compared to native implementations
- Less comprehensive documentation and examples
- Smaller ecosystem of tools and extensions
Code Comparison
UA-.NETStandard (C#):
var endpointUrl = "opc.tcp://localhost:4840";
var client = new OpcUaClient();
await client.ConnectAsync(endpointUrl);
var node = client.Session.NodeCache.Find(ObjectIds.Server_ServerStatus_CurrentTime);
var value = await node.ReadValueAsync();
node-opcua (JavaScript):
const client = OPCUAClient.create();
await client.connect("opc.tcp://localhost:4840");
const session = await client.createSession();
const node = "ns=0;i=2258";
const dataValue = await session.read({nodeId: node});
Both repositories provide implementations of the OPC UA protocol, but they target different languages and ecosystems. UA-.NETStandard is the official .NET implementation, offering robust performance and comprehensive features. node-opcua, on the other hand, brings OPC UA to the JavaScript world, making it accessible to a wider range of developers, especially those working on web-based applications. While UA-.NETStandard may have an edge in terms of performance and completeness, node-opcua offers flexibility and ease of integration for JavaScript developers.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Official OPC UA .NET Standard Stack from the OPC Foundation
Overview
This OPC UA reference implementation is targeting the .NET Standard specification.
.NET Standard allows to develop apps that run on all common platforms available today, including Linux, iOS, Android (via Xamarin) and Windows 7/8/8.1/10/11 (including embedded/IoT editions) without requiring platform-specific modifications.
One of the reference implementations inside this project has been certified for compliance through an OPC Foundation Certification Test Lab to prove its high quality. Fixes and enhancements since the certification process have been tested and verified for compliance using the latest Compliance Test Tool (CTT).
Furthermore, cloud applications and services (such as ASP.NET, DNX, Azure Websites, Azure Webjobs, Azure Nano Server and Azure Service Fabric) are also supported.
More samples based on the official Nuget packages can be found in the OPC UA .NET Standard Samples repository. For development there is also a preview Nuget feed available. For local testing a Docker container of the Reference Server is available for preview and release builds.
For more information and license terms, see here.
Features included
Core and Libraries
- Fully ported Core OPC UA Stack and Libraries (Client, Server, Configuration, Complex Types & GDS assemblies).
- Reference sample Server and Client.
- X.509 Certificate support for client and server authentication.
- SHA-2 support (up to SHA512) including security profile Basic256Sha256, Aes128Sha256RsaOaep and Aes256Sha256RsaPss for configurations with high security needs.
- Anonymous, username and X.509 certificate user authentication.
- UA-TCP & HTTPS transports (client and server).
- Reverse Connect for the UA-TCP transport (client and server).
- Folder & OS-level (X509Store) Certificate Stores with Global Discovery Server and Server Push support.
- Sessions and Subscriptions.
- A PubSub library with samples.
Key Features and Updates in OPC UA 1.05
- Security Enhancements: Improved encryption and authentication mechanisms.
- CRL Support: Added Certificate Revocation List support for X509Store on Windows.
- Performance Improvements: Faster binary encoding and decoding, reducing memory usage and latency.
- Role-Based Management: Support for WellKnownRoles and RoleBasedUserManagement WellKnownRoles & RoleBasedUserManagement.
- Improved Logging: Enhanced logging with
ILogger
andEventSource
.
Breaking Changes and Heads-Up when upgrading from 1.04 to 1.05
- A few features are still missing to fully comply for 1.05 (e.g. ECC support), but certification for V1.04 is still possible with the 1.05 release.
- Thread Safety and Locking: Improved thread safety and reduced locking in secure channel operations.
- Audit and Redaction: New interfaces for auditing and redacting sensitive information.
New in 1.05.374.70
- CRL Support for the X509Store on Windows
New in 1.05.373
- 1.05 Nodeset
- Support for WellKnownRoles & RoleBasedUserManagement.
New in 1.04.368
- Improved support for Logging with
ILogger
andEventSource
. - Support for custom certificate stores with refactored
ICertificateStore
andCertificateStoreType
interface. - Client and Server support for TransferSubscriptions.
- How to use Container support with reference server.
Samples and Nuget packages
- OPC UA Console Reference Server for .NET Core. A Linux Container of the latest builds is available here. See also Container support.
- The OPC UA Reference Server has been certified for compliance through an OPC Foundation Certification Test Lab. Fixes and enhancements since the certification process have been tested and verified for compliance using the Compliance Test Tool (CTT). All releases are verified for compliance with the latest official Compliance Test Tool by the maintainers.
- OPC UA Console Reference Publisher and Console Reference Subscriber for .NET Core and .NET Framework.
- An official OPC UA Nuget package of the core, client, server and configuration libraries is available for integration in .NET projects. Note: The package has been split into Core, Client and Server packages to reduce the dependencies in projects where only client or server is needed. The https binding is now a seperate optional package.
- A preview Nuget feed is available from Azure Devops.
Project Information
General Project Info
Build Status
Code Quality
Getting Started
All the tools you need for .NET Standard come with the .NET Core tools. See Get started with .NET Core for what you need.
How to build and run the reference samples in Visual Studio on Windows
Note: Since .NET Core 2.1 is end of life,
- VS 2017 has only limited support for .NET 4.8.
- VS 2019 has only limited support for .NET 4.8 because .NET Core 3.1 reached end of life.
- VS 2022 is the current supported version, including .NET 6.0 (LTS) and .NET 8.0 (LTS).
- Open the UA Reference.sln solution file using Visual Studio.
- Choose a project in the Solution Explorer and set it with a right click as
Startup Project
. - Hit
F5
to build and execute the sample.
How to build and run the console samples on Windows, Linux and iOS
This section describes how to run the ConsoleReferenceServer sample application.
Please follow instructions in this article to setup the dotnet command line environment for your platform. As of today .NET Core SDK 3.1 is required for Visual Studio 2019 and .NET SDK 6.0 is required for Visual Studio 2022.
Prerequisites
- Once the
dotnet
command is available, navigate to the root folder in your local copy of the repository and executedotnet restore 'UA Reference.sln'
. This command calls into NuGet to restore the tree of dependencies.
Start the server
- Open a command prompt.
- Navigate to the folder Applications/ConsoleReferenceServer.
- To run the server sample type
dotnet run --project ConsoleReferenceServer.csproj -a
.- The server is now running and waiting for connections.
Remarks
Self signed certificates for the sample applications
All required application certificates for OPC UA are created at the first start of each application in a directory or OS-level certificate store and remain in use until deleted from the store. Please read Certificates for more information about certificates and stores
Local Discovery Server
By default all sample applications are configured to register with a Local Discovery Server (LDS). A reference implementation of a LDS for Windows can be downloaded here. To setup trust with the LDS the certificates need to be exchanged or registration will fail.
Contributing
We strongly encourage community participation and contribution to this project. First, please fork the repository and commit your changes there. Once happy with your changes you can generate a 'pull request'.
You must agree to the contributor license agreement before we can accept your changes. The CLA and "I AGREE" button is automatically displayed when you perform the pull request. You can preview CLA here.
Top Related Projects
Open source implementation of OPC UA (OPC Unified Architecture) aka IEC 62541 licensed under Mozilla Public License v2.0
Unlocking the Full Potential of OPC UA with Typescript and NodeJS - http://node-opcua.github.io/
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot