Using OpcCmd Utility as OPC UA PubSub Subscriber

From OPC Labs Knowledge Base
Revision as of 15:18, 17 July 2019 by User (talk | contribs) (→‎Usage)


Introduction

The OpcCmd utility is a program that allows performing various OPC operations from the command line.

OpcCmd 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, but without an appropriate QuickOPC commercial or evaluation license made available to it, it provides valid data only for 30 minutes (it needs to be started over then).

Note2-icon.png

Note: This page describes a preliminary version (5.55.0.3) of the program; the behavior is subject to change in future versions. This version only supports the OPC UA UDP transport protocol mapping (UADP over UDP). We plan to add more features and mappings in the future. Once released, the documentation to the OpcCmd (intended to be a superset of this page) will be found in the QuickOPC User's Guide and Reference.

Note2-icon.png

Note: OpcCmd may be enhanced in the future to support other OPC-related functionality, for Client-Server or PubSub. This page, however, is only for the PubSub subscriber aspect of the OpcCmd tool.

Usage

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

After the program starts, it displays all dataset messages received (according to the criteria given by the command-line options) and their content (data fields). In case of an error, it displays an appropriate error message.

By default, OpcCmd stays subscribed for one minute, or until you interrupt it using the Ctrl+Break key combination. The time period can be configured using the --SleepTimeMilliseconds (-stm) or --SleepTimeSpan (-sts) command-line option.

Command-line Options

OpcCmd has a concept of (possibly nested) commands and options. For the usage as OPC UA PubSub subscriber, you will need one command (uaSubscriber) and one sub-command (subscribeDataSet), so they will practically always be present on the command line, and you will just give them additional options as needed. For this reason, most of your commands will start with:

OpcCmd uaSubscriber subscribeDataSet

Parameters of the subscribeDataSet command can be influenced by various options given after it on the command line. They are (obtained through OpcCmd uaSubscriber subscribeDataSet --help):

Usage: OpcCmd uaSubscriber subscribeDataSet [options]

Options:
  --SleepTimeMilliseconds|-stm <milliseconds>                          Sleep time (-1 for Infinite, default=1 minute)
  --SleepTimeSpan|-sts <timespan>                                      Sleep timespan (e.g. hh:mm, or hh:mm:ss)
  --ResolverPublisherEndpointUri|-rpeu <uri>                           Resolver publisher endpoint URI
  --ResolverPublisherFileResourceUri|-rpfru <uri>                      Resolver publisher file resource URI
  --ResolverKind|-rk <None/Discovery/PublisherEndpoint/PublisherFile>  Resolver kind [DISCOVERY NOT IMPLEMENTED]
  --ConnectionNetworkInterface|-cni <name>                             PubSub connection network interface
  --ConnectionName|-cn <name>                                          PubSub connection name
  --ConnectionResourceUri|-cru <uri>                                   PubSub connection resource URI
  --ConnectionTransportProfile|-ctp <uri>                              PubSub connection transport profile
  --PcapReaderCaptureFile|-prcf <fileName>                             Pcap reader capture file (requires OpcLabs.Pcap)
  --ConnectionBrokerAuthenticationProfileUri|-cbapu <uri>              PubSub connection broker authentication profile URI
  --ConnectionBrokerResourceUri|-cbru <uri>                            PubSub connection broker resource URI
  --ConnectionDatagramDiscoveryUri|-cddu <uri>                         PubSub connection datagram discovery URI
  --MaximumNetworkMessageSize|-mnms <uint32>                           Maximum network message size (ignored)
  --MessageReceiveTimeout|-mrt <double>                                Message receive timeout (milliseconds)
  --SecurityGroupId|-sgi <name>                                        Security group Id
  --SecurityKeyServiceEndpointUris|-skseu <uris>                       Security key service endpoint URIs
  --SecurityMode|-sm <securityMode>                                    Security mode (None/SecurityNone/SecuritySign/SecuritySignAndEncrypt)
  --BrokerAuthenticationProfileUri|-bapu <uri>                         Broker authentication profile URI
  --BrokerMetaDataQueueName|-bmdqn <name>                              Broker metadata queue name
  --BrokerQueueName|-bqn <name>                                        Broker queue name
  --BrokerRequestedDeliveryGuarantee|-brdg <guarantee>                 Broker requested delivery guarantee (NotSpecified/BestEffort/AtLeastOnce/AtMostOnce/ExactlyOnce)
  --BrokerResourceUri|-bru <uri>                                       Broker resource URI
  --DataSetOffset|-dso <uint16>                                        Dataset offset
  --GroupVersion|-gv <uint32>                                          Group version
  --NetworkMessageNumber|-nmn <uint16>                                 Network message number
  --DataSetClassId|-dsci <guid>                                        Dataset class Id
  --AllowDataMessages|-adm <bool>                                      Allow data messages (default=true)
  --AllowEventMessages|-aem <bool>                                     Allow event messages (default=true)
  --DataSetWriterId|-dswi <uint16>                                     Dataset writer Id
  --DataSetWriterName|-dswn <name>                                     Dataset writer name
  --PublisherIdNumeric8|-pin8 <byte>                                   Publisher Id (Byte)
  --PublisherIdNumeric16|-pin16 <uint16>                               Publisher Id (UInt16)
  --PublisherIdNumeric32|-pin32 <uint32>                               Publisher Id (UInt32)
  --PublisherIdNumeric64|-pin64 <uint64>                               Publisher Id (UInt64)
  --PublisherIdString|-pis <string>                                    Publisher Id (String)
  --WriterGroupId|-wgi <uint16>                                        Writer group Id
  --WriterGroupName|-wgn <name>                                        Writer group name
  --MessageOriginFilter|-mof <string>                                  Message origin filter (ipaddress:port for UDP)
  --PublishedDataSetName|-pdsn <name>                                  Published dataset name
  -?|-h|--help                                                         Show help information

Help text for the OpcCmd utility itself can by displayed using OpcCmd --help. Help text for the OpcCmd uaSubscriber command can be displayed using OpcCmd uaSubscriber --help.

Examples

(TBD)

Usage examples:

Subscribe to a dataset, specifying physical parameters:
	OpcCmd uaSubscriber subscribeDataSet -cru opc.udp://239.0.0.1:4840
	OpcCmd uaSubscriber subscribeDataSet -cru opc.udp://224.0.0.22 -dswi 62541
	OpcCmd uaSubscriber subscribeDataSet -sts 01:00 -cru opc.udp://239.0.0.1:4840
	OpcCmd uaSubscriber subscribeDataSet -cru opc.udp://239.0.0.1:4840 -pin 20

Subscribe to a dataset, specifying logical parameters (and resolving them first):
	OpcCmd uaSubscriber subscribeDataSet -rpeu opc.tcp://192.168.0.85:4840 -cn UDP1 -wgn WriterGroupStatic -dswn WriterSimple
	OpcCmd uaSubscriber subscribeDataSet -rpeu opc.tcp://192.168.0.50:4842 -pdsn "PublishedDataSet #1"
	OpcCmd uaSubscriber subscribeDataSet -rfru unified_automation_cpp.bin -cn UDP1 -wgn WriterGroupDynamic -dswn WriterAllTypes

(TBD)

For messages from a default configuration of UADemoPublisher utility, with 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

(TBD)

Sample Output

(TBD)

Testing

(TBD)