C++ Based OPC UA Client/Server/PubSub SDK
1.7.6.537
|
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.
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.uabinary.
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.
The UaExpert with version 1.6 contains a PubSub configuration plug-in that allows the creation of PubSub configurations and the download of the configurations to the involved OPC UA servers.
In UaExpert the PubSub configuration can be opened with Document > Add > Select Document Type “PubSub Config View” > Add.
Existing configurations can be loaded from a server or new configurations can be created. A new configuration can be downloaded to a server.
In a configuration, a PubSubConnection must be created. Make sure the Publisher ID is unique in your network for the address (multi-cast). The PubSubConnection is needed to send and receive messages from a network address e.g. UDP multi-cast address or message broker for MQTT. The PublisherId of the connection is only relevant for the Publisher part (sending of messages). For UDP multi-cast, it is necessary to configure the used network interface by entering the IP-address of the adapter in the configuration option 'Address Network Interface'.
To send data, it is necessary to create a WriterGroup and a DataSetWriter. If UaExpert is connected to the OPC UA server of the Publisher, the Variables can be selected in the Address Space view and can be added to Published DataSet with drag&drop. For first tests with the C++ SDK Demo Server the simulated variables in Objects > Demo > 001_Dynamic > Scalar can be used as source variables with different data types. A larger number of simulated variables can be found in Objects > Demo > 007_Massfolder_Dynamic.
To receive data in the Subscriber, it is necessary to create a ReaderGroup and a DataSetReader. To create a DataSetReader, it is necessary to have the corresponding configuration of the related DataSetWriter available in the UaExpert PubSub configuration. The configuration of a Publisher can be loaded as a standard PubSub binary configuration file.
If UaExpert is connected to the OPC UA server of the Subscriber, the target variables can be selected with drag&drop from the Address Space view to the Target Variable list of the DataSetReader. For first tests with the C++ SDK Demo Server the variables in Objects > Demo > 000_Static > Scalar can be used as target variables with different data types.
See the documentation of UaExpert for more details.
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 create the PubSub configuration inside the OPC UA server based on product specific configuration options.
The PubSubImporter 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
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
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.
This option creates an OPC UA binary encoded PubSub configuration file from the imported configuration.
The output file name is pubsubconfig_out.uabinary. 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.
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.uabinary. 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.
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.
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
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
WriterGroups
DataSetWriters
PublishedDataSets
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
ReaderGroups
DataSetReaders
SubscribedDataSets
The following pages provide further information on the PubSub functionality in the SDK: