C++ Based OPC UA Client/Server/PubSub SDK  1.7.1.476
Getting Started

The getting started describes the creation of a PubSub configuration for initial PubSub testing using the C++ SDK Demo Server and the PubSubImporter demo application.

Demo Server

The C++ SDK Demo Server has the PubSub capabilities included and can be configured to publish data from the variables in the demo server address space. The sample configuration explained in the getting started will use variables with simulated data out of the demo address space (Demo/001_Dynamic and Demo/007_Massfolder_Dynamic)

The demo server can also be configured to subscribe for PubSub messages. The received data can be written to variables in the demo server address space. The address space contains variables for this purpose in the folder PubSubTargetVariables.

The PubSub configuration is stored by the C++ SDK Demo Server in the file bin/pubsubconfig.bin.

The PubSub configuration can be created off-line with the PubSubImporter. One option is to copy the resulting file into the demo server location and to restart the server with the new configuration. Another option is the download of the configuration to the demo server by the PubSubImporter using a FileType object in the demo server.

PubSubImporter

The PubSubImporter provides an example for the use of the UA PubSub Base Library for the off-line creation of a PubSub configuration but it can also be used as simple configuration tool.

The PubSubImporter creates the standardized OPC UA binary encoded PubSub configuration files from an INI text file and is able to download the file to the C++ SDK Demo Server using OPC UA client/server.

The tool is working with the following input files in the working directory of the tool

  • PubSubClientConfig.ini contains the basic client configuration necessary to to connect to a server
  • PubSubConfigImport.ini contains the PubSub configuration in a simplified text form

Sample files can be found in the SDK setup directory in examples/config. The files must be copied to the working directory of the PubSubImporter (e.g. sdk/bin)

The following actions are possible with the PubSubImporter console application

Create configuration from INI file

This option reads the configuration from the file PubSubConfigImport.ini and prints the read configuration objects to the console output. The file must be located in the working directory of the PubSubImporter.

Save configuration to PubSub binary file

This option creates an OPC UA binary encoded PubSub configuration file from the imported configuration.

The output file name is pubsubconfig_out.bin. The file is stored in the working directory of the PubSubImporter.

The file can be used to replace the demo server configuration. This requires to stop the demo server, to replace the file and to start the server with the new file.

Load DataSetWriters from PubSub binary file

The configuration of a subscriber requires knowledge about the configuration of the WriterGroups and DataSetWriters of interest. This option allows the import of a Publisher configuration that contains the WriterGroups and DataSetWriters referenced in the Subscriber configuration.

The import file name is pubsubconfig_in.bin. The file is stored in the working directory of the PubSubImporter.

If a Publisher configuration is necessary, this option must be used before the Subscriber configuration is imported with the INI file.

Transfer configuration to server

The option allows the transfer of the imported configuration to the server.

It is necessary to create a connection to the server using the option "Connect to server".

Changes to the configuration require a user with the role ConfigureAdmin.

Working with PubSub

The import file PubSubConfigImport.ini provided with the SDK contains a Publisher and Subscriber configuration. If this configuration is imported and loaded to the demo server, the Subscriber receives the messages produced by its own Publisher.

The following steps describe how a configuration can be created with two demo servers on different network nodes.

Example:
In this example, we use two Demo servers and two PCs.
The first Demo server, which is running on PC1 consider it as a Publisher
The second Demo server, which is running on PC2 consider it as a Subscriber

PC1-Publisher

The following configuration options must be provided in the file PubSubConfigImport.ini for the publisher configuration. The file contained in the SDK setup can be used as example.

PubSubConnection

  • Create a PubSubConnection with required parameters: TransportFacet, Address Url (e.g: opc.udp://239.0.0.1:4840), AddressNetworkInterface (IP address of the Publisher) and PublisherId
  • Both Publisher and Subscriber must have a same Address Url if UDP multicast is used.

WriterGroups

  • Create WriterGroups with required parameters: PublisherId, PublishingInterval, KeepAliveTime, WriterGroupId, MaxNetworkMessageSize and UadpHeaderConfiguration

DataSetWriters

  • Each WriterGroup can have different DataSetWriters such as Simple, AllTypes and MassData (use UA variables to fill these DataSets)
  • All the DataSetWriters must have a unique DataSetWriterId

PublishedDataSets

  • A single Publisher may support multiple PublishedDataSets and multiple DataSetWriters
  • Creation of this information depends on the product configuration

PC2-Subscriber

As first step, the Publisher binary configuration file must be imported.

The following configuration options must be provided in the file PubSubConfigImport.ini for the subscriber configuration. The file contained in the SDK setup can be used as example.

PubSubConnection

  • Create a PubSubConnection with required parameters: TransportFacet, Address Url (e.g : opc.udp://239.0.0.1:4840), AddressNetworkInterface (IP address of the Subscriber) and PublisherId
  • Both Publisher and Subscriber must have a same Address Url if UDP multicast is used.
  • The PublisherId is not relevant for the Subscriber functionality but a unique PublisherId should be configured for each PubSub application

ReaderGroups

  • Create ReaderGroups with DataSetReaders. ReaderGroups must have a MaxNetworkMessageSize parameter

DataSetReaders

  • Configure PublisherId, DataSetWriterId of each DataSetReader. It must match the Publisher setting and the parameter MessegeReceiveTimeout value is required for all the DataSets.
  • The Subscriber must have configured filters (like a PublisherId, DataSetWriterId) so that it can drop all messages that do not match the filter

SubscribedDataSets

  • SubscribedDataSet is a list of targetVariables (use either PubSubTargetVariables or static UA variables)
  • A single Subscriber may support multiple SubscribedDataSets and multiple DataSetReaders
  • Creation of this information depends on the product configuration