Technical note-OPC UA Discovery in QuickOPC

From OPC Labs Knowledge Base
Revision as of 14:35, 26 October 2016 by User (talk | contribs)
Jump to navigation Jump to search

This article summarizes the OPC UA discovery features available, and how they work internally. Currently, it describes the status as of QuickOPC 5.40.

Main methods and properties

Methods on the IEasyUAClient interface

  • UAApplicationElementCollection DiscoverApplications(string discoveryHost, applicationTypes). Discovers available OPC-UA applications and returns information about them, using the specified discovery host, and filtering by specified application types.
  • UAApplicationElementCollection FindApplications(string[] discoveryUriStringArray, applicationTypes). Discovers available OPC-UA applications and returns information about them, using the specified discovery URI strings and filtering by specified application types.

IEasyUAClient Extension methods

  • UAApplicationElementCollection DiscoverServers(this IEasyUAClient client, string discoveryHost). Discovers available OPC-UA servers and returns information about them, using the specified discovery host.

Properties and methods on the EasyUAClient object

  • Property InstanceParameters.DiscoveryHost. The name of the machine that runs the discovery server that will be used for discovery tasks.
  • Method UAApplicationElementCollection DiscoverServers(). Discovers available OPC-UA servers and returns information about them, using the default discovery host.

Design considerations

The design with two distinct discovery methods is not ideal, and may change in the future. The thinking behind it was roughly as follows:

  • We wanted a method where the developer can pass in just the discovery host name, as it is the most common use case.
  • On the other hand, we needed a way for the developer to be able to specify a discovery URI explicitly, for use cases where the LDS runs on an unusual port or uses an unusual protocol. While at this, we should not lose the built-in parallel ability, hence not just one, but multiple discovery URIs needed to be passed in.
  • The above goals were not achievable with one method being just an extension method to the other - at least not without introducing some mandatory parameters (such as discovery URI template strings) to the IEasyUAClient interface, which is what we want to avoid.

In the future, it is possible that the two methods will merged into one method nevertheless, using some kind of "discovery filter" argument with ability to describe the use cases independently of any concrete settings in the underlying client object.

Functionality

The DiscoverApplications method

  1. Determines and uses the effective host parameters (UAHostParameters) and discovery parameters (UADiscoveryParameters).
  2. Creates a *virtual* host session to the discovery host (note that this involves no connection to the target at this time).
  3. Determines the discovery URI strings for a given host. This is based on the HostParameters.DiscoveryUriTemplateStrings setting.
  4. Continues with #Steps common for both discovery methods.

The FindApplications method

  1. Determines and uses the effective discovery parameters (UADiscoveryParameters).
  2. Continues with #Steps common for both discovery methods.

Steps common for both discovery methods

  1. Depending on the UADiscoveryParameters.ParallelDiscovery setting, performs the following operations serially or in parallel, on each discovery URI string, until a first operation success.
  2. Creates a *virtual* discovery session to the discovery URI string (note that this involves no connection to the target at this time).
  3. Determines the SDK endpoint configuration, setting its operation timeout to be UADiscoveryParameters.DiscoveryTimeout.
  4. Creates SDK discovery client. This uses the given discovery URI string.
  5. Calls the OPC UA FindServers service, using the SDK discovery client.
  6. Performs various checks on the returned application descriptions.
  7. Converts the returned application descriptions to UAApplicationElementCollection.

Parameters

The UAHostParameters object

The UAHostParameters object contains:

  • Property StringSet DiscoveryUriTemplateStrings. The URL templates of discovery endpoints that will be used for discovery tasks.

The UADiscoveryParameters object

The UADiscoveryParameters object contains:

  • Property bool CheckApplicationDescription. Check the application description.
  • Property int DiscoveryTimeout. A maximum time a server discovery can take (in milliseconds).
  • Property bool ParallelDiscovery. When set to true, the server discovery will be attempted on configured discovery endpoints simultaneously.