C++ Based OPC UA Client/Server/PubSub SDK  1.7.6.537
PubSub Configuration Options

The following options are available for PubSub configuration:

On-line configuration with an OPC UA Client

The PubSub server module implements the OPC UA PubSub configuration information model. This allows generic OPC UA clients like UaExpert to configure the PubSub communication on-line. See also PubSub Configuration with UaExpert.

In-process vendor specific configuration

An OPC UA PubSub application can be configured with vendor specific mechanisms. This can be done in a configuration tool or inside the PubSub application using the UA PubSub Base Library. The UA PubSub Base Library simplifies the creation and modification of a PubSub configuration. It provides a C++ library for the different PubSub configuration objects like PubSubConnection, DataSetWriter or DataSetReader.

The following sample code shows a simple example of an in-process configuration in an OPC UA Server and PubSub application. It is based on the PubSub module integration into the C++ SDK Demo Server

// Create and initialize server object
OpcServer* pServer = new OpcServer;
pServer->setServerConfig(sConfigFileName, szAppPath);
// Create and initialize PubSub module
PubSubManager* pPubSubManager = new PubSubManager;
MyPubSubCallback pubSubCallback;
pPubSubManager->setPubSubServerApplicationCallback(&pubSubCallback);
pPubSubManager->setPubSubConfig("pubsubconfig.uabinary", szAppPath);
pServer->addModule(pPubSubManager);
// Start OPC UA Server with PubSub
ret = pServer->start();
if ( ret == 0 )
{
pPubSubManager->getPubSubConfig(pPubSubConfiguration);
// Add a PubSubConnection
PubSubBase::PubSubConnection* pPubSubConnection = pPubSubConfiguration->addConnection_Datagram(
"MyConnection", // Name of the PubSubConnection
true, // Enabled
UaVariant((OpcUa_UInt16)99), // PublisherId
"opc.udp://239.0.0.1:4840", // Address
"", // Network Interface -> set adapter address if multiple adapters
"");
if (pPubSubConnection)
{
// Add WriterGroup
PubSubBase::WriterGroup *pWriterGroup = pPubSubConnection->addWriterGroup_UADP(
"MyWriterGroup", // Name of the WriterGroup
true, // Enabled
1, // WriterGroupId
100, // PublishingInterval
1000, // KeepAliveTime
if (pWriterGroup)
{
// Create a PublishedDataSet with current server time
UaStringArray fieldNames;
fieldNames.create(1);
UaString fieldName("Current server time");
fieldName.copyTo(&fieldNames[0]);
UaNodeIdArray publishedVariableNodeIds;
publishedVariableNodeIds.create(1);
publishedVariableNodeIds[0].Identifier.Numeric = OpcUaId_Server_ServerStatus_CurrentTime;
UaByteArray publishedVariableBuiltInTypes;
publishedVariableBuiltInTypes.create(1);
publishedVariableBuiltInTypes[0] = OpcUaType_DateTime;
UaInt32Array publishedVariableValueRanks;
publishedVariableValueRanks.create(1);
publishedVariableValueRanks[0] = -1; // Skalar
PubSubBase::PublishedDataSet* publishedDataSet = pPubSubConfiguration->addDataSet(
"MyDataSet", // Name of the DataSet
fieldNames, // Field names of the fields in the DataSet
publishedVariableNodeIds, // Variables used as source for fields in the DataSet
publishedVariableBuiltInTypes, // Built-in DataType of fields in the DataSet
publishedVariableValueRanks); // Value ranks of fields in the DataSet
if (publishedDataSet)
{
// Add DataSetWriter
PubSubBase::DataSetWriter* pDataSetWriter = pWriterGroup->addDataSetWriter_UADP(
"MyDataSetWriter", // Name of the DataSetWriter
true, // Enabled
1, // DataSetWriterId
publishedDataSet); // Published DataSet
if (pDataSetWriter)
{
// Use the updated configuration
pPubSubManager->setPubSubConfig(pPubSubConfiguration);
}
}
}
}
pPubSubConfiguration->releaseReference();

Off-line configuration

The PubSub configuration can be created off-line in a configuration tool. The configuration tool can be a generic tool like UaExpert of a vendor specific engineering tool.

The off-line configuration can be loaded by the SDK if it complies with the PubSub configuration binary file in the UA binary format defined by the OPC UA specification.

The PubSubImporter provides an example for the use of the UA PubSub Base Library for the off-line creation of a PubSub configuration. The UA PubSub Base Library can also be used to load the PubSub configuration.

The following page provide further information on the PubSub functionality in the SDK: