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.
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
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.
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.
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 are always welcome! Please see CONTRIBUTING.md for details.
This project use the following license: MIT