Intrinsic Component Configuration: Difference between revisions

From OPC Labs Knowledge Base
No edit summary
 
(41 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:Configuration]] [[Category:High-Level Configuration]]
[[Category:Configuration]] [[Category:High-Level Configuration]] [[Category:OpcCmd Utility]]
= Introduction =
The parameters of main QuickOPC components can be configured externally, without a need to write any code for it. See [[High-Level Intrinsic 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 {{Style=Identifier|EasyUAClient}} component are under the <code>OpcLabs.EasyOpc.UA.EasyUAClient</code> configuration section.
 
The component parameter name is then the key (name) of the sub-section. For example, the {{Style=Identifier|InstanceParameters}} can be configured under the <code>InstanceParameters</code> sub-section. If the parameter is not an atomic value, but rather a structured object, deeper sub-sections are used as necessary, recursively.
= Error Handling =
All errors that occur when the components read their parameters using the intrinsic configuration mechanism are silently ignored. This behavior was chosen because the reading of the configuration happens at time that is generally unpredictable to the developers (such as inside the static constructors of the components), and exceptions thrown at unpredictable place would have potential to crash the application. When an error occurs, the configuration may be read just partially.
= 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:
<syntaxhighlight lang="json">
{
  "OpcLabs.EasyOpc.UA.EasyUAClient": {
    "InstanceParameters": {
      "GdsEndpointDescriptor": {
        "UrlString": "opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer"
      }
    }
  }
}
</syntaxhighlight>
== 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):
<syntaxhighlight lang="bat">
set OpcLabs.EasyOpc.UA.EasyUAClient:InstanceParameters:GdsEndpointDescriptor:UrlString="opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer"
</syntaxhighlight>
On platforms where the <code>:</code> separator does not work (e.g. [https://linuxhint.com/bash-environment-variables Bash]), use <code>__</code> (double underscore) instead.
== More examples ==
See [[Intrinsic component configuration examples]].
 
= Note on Programmatic Component Configuration =
The sequence of high-level component configuration evaluation is as follows:
# The values are set to their (constant, documented) defaults (both static and instance members).
# Intrinsic 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.
# 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.
# 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 intrinsic component configuration feature.
= Component Support =
The intrinsic component configuration feature is supported by following components, and for the data members listed:
; {{Style=Identifier|AEDialog}} (affects derived components {{Style=Identifier|AEAreaOrSourceDialog}}, {{Style=Identifier|AEAttributeDialog}}, {{Style=Identifier|AECategoryConditionDialog}}, {{Style=Identifier|AECategoryDialog}}), {{Style=Identifier|DADialog}} (affects derived components {{Style=Identifier|DAItemDialog}}, {{Style=Identifier|DAPropertyDialog}}): {{Style=Identifier|ClientSelector}}.
; {{Style=Identifier|ComManagement}}: {{Style=Identifier|Configuration}}.
; {{Style=Identifier|EasyAEClient}}: {{Style=Identifier|AdaptableParameters}}, {{Style=Identifier|SharedParameters}}, {{Style=Identifier|InstanceParameters}}, {{Style=Identifier|IsolatedParameters}}.
; {{Style=Identifier|EasyDAClient}}: {{Style=Identifier|AdaptableParameters}}, {{Style=Identifier|SharedParameters}}, {{Style=Identifier|InstanceParameters}}, {{Style=Identifier|IsolatedParameters}}.
; {{Style=Identifier|EasyUAClient}}: {{Style=Identifier|AdaptableParameters}}, {{Style=Identifier|SharedParameters}}, {{Style=Identifier|InstanceParameters}}, {{Style=Identifier|IsolatedParameters}}.
; {{Style=Identifier|EasyUASubscriber}}: {{Style=Identifier|AdaptableParameters}}, {{Style=Identifier|SharedParameters}}, {{Style=Identifier|InstanceParameters}}, {{Style=Identifier|IsolatedParameters}}.
; {{Style=Identifier|OpcBrowseControl}}, {{Style=Identifier|OpcBrowseDialog}}: {{Style=Identifier|AEClientSelector}}, {{Style=Identifier|DAClientSelector}}.
; {{Style=Identifier|UABrowseControl}}, {{Style=Identifier|UABrowseDialog}}: {{Style=Identifier|ClientSelector}}.
; {{Style=Identifier|UADialog}} (affects derived components {{Style=Identifier|UADataDialog}}, {{Style=Identifier|UAEndpointDialog}}, {{Style=Identifier|UAHostAndEndpointDialog}}): {{Style=Identifier|ClientSelector}}.

Latest revision as of 15:55, 1 February 2022

Introduction

The parameters of main QuickOPC components can be configured externally, without a need to write any code for it. See High-Level Intrinsic 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.

Error Handling

All errors that occur when the components read their parameters using the intrinsic configuration mechanism are silently ignored. This behavior was chosen because the reading of the configuration happens at time that is generally unpredictable to the developers (such as inside the static constructors of the components), and exceptions thrown at unpredictable place would have potential to crash the application. When an error occurs, the configuration may be read just partially.

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.

More examples

See Intrinsic component configuration examples.

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. Intrinsic 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 intrinsic component configuration feature.

Component Support

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

AEDialog (affects derived components AEAreaOrSourceDialog, AEAttributeDialog, AECategoryConditionDialog, AECategoryDialog), DADialog (affects derived components DAItemDialog, DAPropertyDialog)
ClientSelector.
ComManagement
Configuration.
EasyAEClient
AdaptableParameters, SharedParameters, InstanceParameters, IsolatedParameters.
EasyDAClient
AdaptableParameters, SharedParameters, InstanceParameters, IsolatedParameters.
EasyUAClient
AdaptableParameters, SharedParameters, InstanceParameters, IsolatedParameters.
EasyUASubscriber
AdaptableParameters, SharedParameters, InstanceParameters, IsolatedParameters.
OpcBrowseControl, OpcBrowseDialog
AEClientSelector, DAClientSelector.
UABrowseControl, UABrowseDialog
ClientSelector.
UADialog (affects derived components UADataDialog, UAEndpointDialog, UAHostAndEndpointDialog)
ClientSelector.