Using communication packages: Difference between revisions

From OPC Labs Knowledge Base
Line 23: Line 23:
<pre>UADemoPublisher --MqttUadpTcp --ConnectionProperties {http://opclabs.com/OpcUA/PubSub}MessageChannel!=OpcLabs.Mqtt.MqttClientMessageChannel,OpcLabs.Mqtt</pre>
<pre>UADemoPublisher --MqttUadpTcp --ConnectionProperties {http://opclabs.com/OpcUA/PubSub}MessageChannel!=OpcLabs.Mqtt.MqttClientMessageChannel,OpcLabs.Mqtt</pre>
As typing this in would be cumbersome, UADemoPublisher comes with several ready-made response files which contain the necessary settings for common [[MQTT communication packages]]. With the help of the response file, the command above can be shortened to:
As typing this in would be cumbersome, UADemoPublisher comes with several ready-made response files which contain the necessary settings for common [[MQTT communication packages]]. With the help of the response file, the command above can be shortened to:
<pre>UADemoPublisher -mut @MessageChannel-Mqtt</pre>
<pre>UADemoPublisher --MqttUadpTcp @MessageChannel-Mqtt</pre>
Since the command-line option name is the same as in the "uaSubscriber subscribeDataSet" or "uaSubscriber subscribeDataSetField" commands in the OpcCmd tool, the same response files can be used for communication package selection as with the OpcCmd tool.
Since the command-line option name is the same as in the "uaSubscriber subscribeDataSet" or "uaSubscriber subscribeDataSetField" commands in the OpcCmd tool, the same response files can be used for communication package selection as with the OpcCmd tool.



Revision as of 11:18, 13 December 2019

Before you use any communication package, make sure you understand its licensing terms, and the licensing terms of any other software it depends on (recursively). If you are using the package from NuGet, the NuGet client will allow you to review the licensing terms for each software involved. In other cases (such as when the communication package comes preinstalled with other software, or when you are using the ZIP package), consult the corresponding documentation. You may still end up having to use a NuGet client (e.g. Visual Studio) and install a NuGet package, just for the purpose of reviewing the license terms.

Installing the communication package

Selecting the communication package

In order to use the chosen communication package in OPC UA PubSub tools, you need to select it by setting a custom property on a PubSub connection as follows:

  • Property namespace: http://opclabs.com/OpcUA/PubSub
  • Property name: MessageChannel!
  • Property datatype: String
  • Property value: The type name of the message channel object. See the communication package documentation (example: OpcLabs.Mqtt.MqttClientMessageChannel,OpcLabs.Mqtt).

How this is done depends on the concrete software you are using. The actual value is an assembly-qualified name, so if needed, you can specify the version of the assembly, its public key token, and so on.

EasyUASubscriber object

Usually, you will use the same communication package across your solution, but there is nothing that prevents you to use a different one with each PubSub connection, e.g. for compatibility reasons with different MQTT brokers.

OpcCmd tool

UADemoPublisher tool

In UADemoPublisher, you set the custom property on a PubSub connection using the --ConnectionProperties (-cp) option. They key is in the form {url}name, where url is the property namespace, and name is the property name. For example, to publish messages using the OpcLabs.Mqtt communication package, you can use the following command:

UADemoPublisher --MqttUadpTcp --ConnectionProperties {http://opclabs.com/OpcUA/PubSub}MessageChannel!=OpcLabs.Mqtt.MqttClientMessageChannel,OpcLabs.Mqtt

As typing this in would be cumbersome, UADemoPublisher comes with several ready-made response files which contain the necessary settings for common MQTT communication packages. With the help of the response file, the command above can be shortened to:

UADemoPublisher --MqttUadpTcp @MessageChannel-Mqtt

Since the command-line option name is the same as in the "uaSubscriber subscribeDataSet" or "uaSubscriber subscribeDataSetField" commands in the OpcCmd tool, the same response files can be used for communication package selection as with the OpcCmd tool.

Configuring the communication package

The specific information necessary for establishing and maintaining the communication is provided by the host software. In addition to that, the communication packages typically have various configuration parameters that influence their behavior, and the parameters differ from package to package. The defaults are set in such a way that in most cases, you do not need to care about the configuration at all. If the configuration needs to be changed, the primary way of doing so is using the configuration properties.


UADemoPublisher --MqttUadpTcp --ConnectionProperties {http://opclabs.com/OpcUA/PubSub}MessageChannel.MqttClientOptions.ProtocolVersion=V500

Beside programmatically accessible configuration properties, the communication package may provide other means of configuration, described in its documentation.