Intrinsic Component Configuration

From OPC Labs Knowledge Base

Introduction

The parameters of main QuickOPC components can be configured externally, without a need to write any code for it. See High-Level Implicit Configuration for an overview of this mechanism.

Naming Conventions

The key (name) of the configuration section is the full (namespace-qualified) name of the component being configured. For example, parameters for the EasyUAClient component are under the OpcLabs.EasyOpc.UA.EasyUAClient configuration section.

The component parameter name is then the key (name) of the sub-section. For example, the InstanceParameters can be configured under the InstanceParameters sub-section. If the parameter is not an atomic value, but rather a structured object, deeper sub-sections are used as necessary, recursively.

Examples

The JSON and the environment variable configuration providers are available by default on most hosts (including ASP.NET, and .NET console apps), and you can therefore reliably use configurations similar to the examples below "out of the box" with any QuickOPC-based software.

Example: Using the JSON configuration provider

In order to set the default URL of the OPC UA Global Discovery Server (GDS) used by QuickOPC global discovery operations, you can use the following appsettings.json file:

{
  "OpcLabs.EasyOpc.UA.EasyUAClient": {
    "InstanceParameters": {
      "GdsEndpointDescriptor": {
        "UrlString": "opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer"
      }
    }
  } 
}

Example: Using the environment variable configuration provider

In order to achieve the same configuration effect as with the JSON example above, you can set the environment variable as follows (the syntax is for Windows, but the provider is available on other systems as well):

set OpcLabs.EasyOpc.UA.EasyUAClient:InstanceParameters:GdsEndpointDescriptor:UrlString="opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer"

On platforms where the : separator does not work (e.g. Bash), use __ (double underscore) instead.

Note on Programmatic Component Configuration

The sequence of high-level component configuration evaluation is as follows:

  1. The values are set to their (constant, documented) defaults (both static and instance members).
  2. Implicit configuration, if present, is applied (this can involve multiple configuration providers in specific sequence). This affects both the static and instance members of the component.
  3. If the component supports programmatic component configuration, and the code that creates the component specifies a configuration interface, using a constructor designed for IoC (Inversion of Control), the configuration given by the specified interface is applied (this, again, can involve multiple configuration providers in specific sequence). Only instance members of the component can be configured in this way.
  4. The program code can then further modify values of any component parameters.

As you can see, if the programmatic component configuration or settings the parameters through code is used, the initial values (of instance members) that the component will end up using may be different from what you specify using the implicit component configuration feature.

Component Support

The implicit component configuration feature is supported by following components, and for the data members listed:

EasyAEClient
AdaptableParameters, SharedParameters, InstanceParameters, IsolatedParameters.
EasyDAClient
AdaptableParameters, SharedParameters, InstanceParameters, IsolatedParameters.
EasyUAClient
AdaptableParameters, SharedParameters, InstanceParameters, IsolatedParameters.
EasyUASubscriber
AdaptableParameters, SharedParameters, InstanceParameters, IsolatedParameters.