Skip to content

opc-ua-pubsub-dotnet is a library which implements OPC UA PubSub encoding and decoding in a simplified way.

License

Notifications You must be signed in to change notification settings

siemens/opc-ua-pubsub-dotnet

Repository files navigation

Contributor Covenant GitHub

Build & Test Publish NuGet Packages

Nuget Nuget

opc-ua-pubsub-dotnet

opc-ua-pubsub-dotnet is a library which implements OPC UA PubSub encoding and decoding in a simplified way.

It's not offering the full flexibility of OPC UA PubSub, but it supports encoding and decoding of all data types which are used by Siemens SICAM A8000 and SICAM GridEdge. You can easily extend this library to support additional data types.

The library itself is written in .NET 5.

Using

Add the Nuget package, e.g.:

dotnet add package opc.ua.pubsub.dotnet.client

or by using Visual Studio, Visual Studio for Mac or the Package Manager Console

Decoding

Create a new instace of DecodeMessage and pass the binary message:

DecodeMessage Decoder = new DecodeMessage();
NetworkMessage message = Decoder.ParseBinaryMessage(rawMessage)

Please keep in mind, that OPC UA PubSub is stateful. That means you need to have decoded the Meta-Message before you can decode any Key- or Delta-Message.

For more advanced use cases please see the developer documentation.

Encoding

Create an instance of the ProcessData class:

string publisherID = "my-publisher-id";
string dataSetName = "my-data-set-name";
ushort writerID    = 123;
ProcessDataSet dataSet = new ProcessDataSet( publisherID, dataSetName, writerID, ProcessDataSet.DataSetType.TimeSeries );

Now you can create a Datapoint and add it to the previously created ProcessData instance:

DPSEvent dataPoint = new DPSEvent()
{
        Name      = "Sample DPS",
        Value     = 2,
        Orcat     = OrcatConstants.Process,
        Quality   = QualityConstants.Good,
        Timestamp = DateTime.Now.ToFileTimeUtc()
};

dataSet.AddDataPoint( dataPoint );

Now you can get the binary encoded Meta-Message and as well a binary encoded Key- or Delta-Message from the ProcessData instance:

ushort sequenceNumber = 1;
byte[]         encodedMeta        = dataSet.GetEncodedMetaFrame( new EncodingOptions(), sequenceNumber++ );
byte[]         encodedKey         = dataSet.GetEncodedDeltaFrame( sequenceNumber++ );

More advanced use cases including the usage of MQTT are available in the developer documentation.

Build

Building just the library requires only .NET Core 3.1 SDK and can be done on any operating system supported by .NET Core 3.1.

Building the entire repository including sample applications can done only on Windows and requires additionally the installation of the .NET Framework Developer Pack. It's recommended to use Visual Studio for building the entire repository.

Contributions

Contributions are always welcome! Please see CONTRIBUTING.md for details.

License

This project use the following license: MIT

About

opc-ua-pubsub-dotnet is a library which implements OPC UA PubSub encoding and decoding in a simplified way.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages