UADemoPublisher Basics

From OPC Labs Knowledge Base
Jump to navigation Jump to search

Introduction

The UADemoPublisher program is a demonstration publisher for OPC UA PubSub.

UADemoPublisher is a console application, running on .NET. It is available for .NET Framework (Windows only), or .NET Core (Windows or Linux). It is available free of charge (does not require a license for QuickOPC or other OPC Labs product).

This version supports following transport protocol mappings:

  • OPC UA UDP (UADP over UDP; IPv4 or IPv6)
  • OPC UA Ethernet (UADP over Ethernet; with or without VLAN tagging)

Security is not supported.

For installation, see Tool Downloads. If you want to use OPC UA PubSub Ethernet transport protocol mapping, you will also need

See also: OPC UA PubSub Common Traps And Pitfalls

Note2-icon.png

Note: This page describes a preliminary version (5.55.0.5) of the program; the behavior is subject to change in future versions. We plan to add more features and mappings in the future. Once released, the documentation to the UADemoPublisher (intended to be a superset of this page) will be found in the QuickOPC User's Guide and Reference.

Usage

In order to run the UADemoPublisher, open a command prompt, and switch to the directory that contains the program. You can start the program without any additional parameters. If you are using the .NET Framework version, type UADemoPublisher and press Enter. If you are using the .NET Core version, type dotnet UADemoPublisher.dll and press Enter. In the text that follows, when discussing the command line options, we will be listing the commands simply with the UADemoPublisher at the beginning; remember to use dotnet UADemoPublisher.dll in .NET Core instead.

The published data sets and the way they are published are hard-coded into the program and cannot be changed (for most part).

After the program starts, it prints out a summary of the configuration it uses when publishing the datasets, and then continuously displays a statistics of messages sent on each configured connection.

By default, the UADemoPublisher sends messages to IPv4 multicast address 239.0.0.1. This can be changed using the --ConnectionResourceUri (-cru) option (see further below). If you have multiple network interfaces and the messages do not get sent to the one you want, use the --ConnectionNetworkInterface (-cni) command-line option to specify the interface name.

The UADemoPublisher runs until you interrupt it using the Ctrl+Break key combination, or until a given time period elapses. This time period can be configured using the --SleepTimeMilliseconds (-stm) or --SleepTimeSpan (-sts) command-line option.

Command-line Options

Parameters of the UADemoPublisher can be influenced by various options given on its command line. They can be entered using the long form (starts with --) or the short form (starts with -). The options are (obtained through UADemoSubscriber --help):

Usage: UADemoPublisher [options] [command]

Options:
  -?|-h|--help                                 Show help information
  --pause                                      Suspend the processing after running a command
  -udp                                         Presets for UDP over IPv4 (default)
  -udp6                                        Presets for UDP over IPv6
  --Ethernet|-eth                              Presets for Ethernet (no tagging)
  --EthernetVlan|-ethv                         Presets for Ethernet with VLAN tagging
  --SleepTimeMilliseconds|-stm <milliseconds>  Sleep time (-1 for Infinite, default)
  --SleepTimeSpan|-sts <timespan>              Sleep timespan (e.g. hh:mm, or hh:mm:ss)
  --ConnectionNetworkInterface|-cni <name>     PubSub connection network interface
  --ConnectionResourceUri|-cru <uri>           PubSub connection resource URI (default opc.udp://239.0.0.1)
  --ConnectionTransportProfile|-ctp <uri>      PubSub connection transport profile
  --KeepAliveTime|-kat <double>                Keep-alive time (milliseconds)
  --KeyFrameCount|-kfc <uint32>                Key frame count (>= 1, only where applicable, default 25)
  --PublishingInterval|-pi <double>            Publishing interval (milliseconds, default 500)

Commands:
  about  Displays software information and legal notices

Use "UADemoPublisher [command] --help" for more information about a command.

The --ConnectionTransportProfile (-ctp) does not have to specified if it can be inferred from the --ConnectionResourceUri (-cru; for example, opc.udp and opc.eth schemes in the --ConnectionResourceUri imply the transport profile unambiguously, and therefore you do not have to specify --ConnectionTransportProfile with them). Parameters such as --KeepAliveTime or --KeyFrameCount affect all targets where they can apply; you can cannot specify them differently for individual connections, writer groups or dataset writers. Several "pre-set" options are available to make the demoing of OPC UA PubSub easy without having to specify multiple complicated parameters. The presets are:

-udp 
UDP over IPv4. Publishes on opc.udp://239.0.0.1 .
-udp6 
UDP over IPv6. Publishes on opc.udp://ip6-allnodes (same as opc.udp://[ff02::1], see Enhanced Host Name Resolution).
--Ethernet (-eth) 
Ethernet with no tagging. Publishes on opc.eth://eth-broadcast (same as opc.eth://FF-FF-FF-FF-FF-FF, see Enhanced Host Name Resolution).
--EthernetVlan (-ethv) 
Ethernet with VLAN tagging. Publishes on opc.eth://eth-broadcast:2 (same as opc.eth://FF-FF-FF-FF-FF-FF:2, see Enhanced Host Name Resolution).

PubSub Configuration

The configuration of the UADemoPublisher is based on the setup used on OPC UA PlugFests and Interoperability Workshops. There are following published data sets:

Simple
4 fields. A boolean, 32-bit integers, and a DateTime.
AllTypes
9 fields. Types are suitable for fixed layout (raw encoding). Includes signed and unsigned integers of various sizes, and 4-byte/8-byte floats.
MassTest
100 fields, all unsigned 32-bit integers.
AllTypes-Dynamic
16 fields. Compared to AllTypes, it adds 64-bit integers, a string, a byte string, a GUID, and an array of (unsigned 32-bit) integers.

The UADemoPublisher uses following writer groups (each on its own PubSubConnection):

FixedLayoutGroup (publisher ID is 30, as UInt16)
Uses the "Message headers for periodic data with fixed layout" as per OPC UA Amendment 6. Among other characteristics, the fields use raw encoding.
DynamicLayoutGroup (publisher ID is 31, as UInt64)
Uses the "Message headers for Events and Data with dynamic layout" as per OPC UA Amendment 6. The fields in Data messages are encoded as DataValue-s, with StatusCode and SourceTimestamp. We have also included an Event message writer, which uses the Simple dataset for its event fields.
FlexibleLayoutGroup (publisher ID is 32, as String)
This group uses a "made up" header profile, with following basic characteristics: PublisherID, PayloadHeader, DataSetClassId and PromotedFields (not currently implemented) included in the UADP network message. Dataset fields are encoded as Variant-s, KeyFrameCount is 1, and the UADP dataset message does not contain any additional fields (timestamps or versions).

Parameters such as the publishing interval (defaults to 500 milliseconds), keep-alive time or key frame count can be changed using the command-line options.

Examples

Send all messages to IP multicast address 224.0.2.0:

UADemoPublisher -cru opc.udp://224.0.2.0

Send all messages to IPv6 multicast address ff02::1 (all nodes on the local network segment):

UADemoPublisher -cru opc.udp://[ff02::1]

Send all messages to Ethernet broadcast address, using VID (VLAN identifier) 1000 and PCP (Priority Code Point) 3 (CA, critical applications):

UADemoPublisher -cru opc.eth://FF-FF-FF-FF-FF-FF:1000.3

Send all messages through network interface "Ethernet" (you can leave out the double-quotes if there are no spaces in the interface name):

UADemoPublisher -cni "Ethernet"

Only enable the MassTestWriter in DynamicLayoutGroup:

UADemoPublisher -wg DynamicLayoutGroup -dsw MassTestWriter

Set the publishing interval to 5 seconds:

UADemoPublisher -pi 5000

Run the UADemoPublisher for 15 minutes:

UADemoPublisher -sts 0:15:00

Show help information:

UADemoPublisher --help

Sample Output

Below is a sample output from the UADemoPublisher, also showing its configuration with the default values.

OPC Labs UADemoPublisher Utility (.NET Core) 5.55.0.3: OPC-UA Demo Publisher.
Copyright © 2019 CODE Consulting and Development, s.r.o., Plzen. All rights reserved.

TransportProfileUri: http://opcfoundation.org/UA-Profile/Transport/pubsub-udp-uadp
Loading configuration...
PublishedDataSets:
  Simple: DataSetClassId=eae79794-1af7-4f96-8401-4096cd1d8908, 4 fields
  AllTypes: DataSetClassId=c51be198-9ade-4a72-8d75-1fbebee173d6, 9 fields
  MassTest: DataSetClassId=96976b7b-0db7-46c3-a715-0979884b55ae, 100 fields
  AllTypes-Dynamic: DataSetClassId=cc7cb5f4-4272-45c2-9a4d-f85a8b331f6a, 16 fields
Connections:
  FixedLayoutConnection: {opc.udp://239.0.0.1 | } PublisherId=[UInt16]30
    FixedLayoutGroup: WriterGroupId=101, PublishingInterval=500, KeepAliveTime=2000, GroupVersion=615377160
      SimpleWriter: DataSetWriterId=1, DataSetName=Simple, KeyFrameCount=1
      AllTypesWriter: DataSetWriterId=2, DataSetName=AllTypes, KeyFrameCount=1
      MassTestWriter: DataSetWriterId=3, DataSetName=MassTest, KeyFrameCount=1
  DynamicLayoutConnection: {opc.udp://239.0.0.1 | } PublisherId=[UInt64]31
    DynamicLayoutGroup: WriterGroupId=102, PublishingInterval=500, KeepAliveTime=2000, GroupVersion=615377160
      SimpleWriter: DataSetWriterId=1, DataSetName=Simple, KeyFrameCount=25
      MassTestWriter: DataSetWriterId=3, DataSetName=MassTest, KeyFrameCount=25
      AllTypes-DynamicWriter: DataSetWriterId=4, DataSetName=AllTypes-Dynamic, KeyFrameCount=25
      EventSimpleWriter: DataSetWriterId=51, DataSetName=Simple, KeyFrameCount=0
  FlexibleLayoutConnection: {opc.udp://239.0.0.1 | } PublisherId=[String]32
    FlexibleLayoutGroup: WriterGroupId=103, PublishingInterval=500, KeepAliveTime=2000, GroupVersion=615377160
      SimpleWriter: DataSetWriterId=1, DataSetName=Simple, KeyFrameCount=1
      MassTestWriter: DataSetWriterId=3, DataSetName=MassTest, KeyFrameCount=1
      AllTypes-DynamicWriter: DataSetWriterId=4, DataSetName=AllTypes-Dynamic, KeyFrameCount=1

Starting to publish...
Sleeping for Infinite (press Ctrl+Break to abort)...
Messages sent: DynamicLayoutConnection 20, FixedLayoutConnection 19, FlexibleLayoutConnection 60

Receiving Messages

You can use any compliant OPC UA PubSub subscriber to receive and process messages from the UADemoPublisher. It needs to be configured, of course, according to format and contents of the messages sent by the UADemoPublisher. The subscriber, regardless of its type, needs to be either on the same computer as the UADemoPublisher (for simplest test), or on the same local subnetwork, or you need to configure the multicast routing appropriately.

Examples in the QuickOPC documentation show how to use the EasyUASubscriber object, and other QuickOPC facilities, to subscribe to messages generated by the UADemoPublisher.

You can also use our OpcCmd utility to verify that UADemoPublisher is working, and view the datasets it is publishing. For the default configuration of UADemoPublisher, enter following command:

OpcCmd uaSubscriber subscribeDataSet -cru opc.udp://239.0.0.1

Or, for a specific publisher ID (31, in 64 bits) and dataset writer ID (4):

OpcCmd uaSubscriber subscribeDataSet -cru opc.udp://239.0.0.1 -pin64 31 -dswi 4

For more information, see Using OpcCmd Utility as OPC UA PubSub Subscriber. Note that without providing a way for OpcCmd to resolve the configuration metadata, you won't be able to actually see the data published by FixedLayoutConnection/FixedLayoutGroup, because it uses raw encoding. Data published by DynamicLayoutConnection/DynamicLayoutGroup, and FlexibleLayoutConnection/FlexibleLayoutGroup can be viewed immediately.