/* ========================================================================
* Copyright (c) 2005-2025 The OPC Foundation, Inc. All rights reserved.
*
* OPC Foundation MIT License 1.00
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* The complete license agreement can be found here:
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/
using Opc.Ua.Client.AliasNames.Refresh;
namespace Opc.Ua.Client.AliasNames
{
///
/// Controls how refreshes its cache.
///
///
/// For finer control set
/// directly to
/// an instance — it takes
/// precedence over this enum.
///
public enum AliasNameResolverRefreshMode
{
///
/// The cache is loaded once via
/// and never updated automatically. This is the safe default — it
/// works even when the server does not allow subscriptions.
///
Manual = 0,
///
/// On the first call, the resolver polls the category's
/// LastChange property (Part 17 §6.3.1) every
///
/// and invalidates the cache on any value-difference (covers
/// VersionTime wraparound; see Part 5 §6.4.10). Works on
/// servers that do not support subscriptions.
///
AutoOnLastChangePolling = 1,
///
/// On the first call, the resolver creates an OPC UA
/// Subscription + MonitoredItem on the category's
/// LastChange variable and invalidates the cache on every
/// notification whose value differs from the cached one
/// (wrap-safe). Requires a server that supports subscriptions
/// and exposes LastChange.
///
AutoOnLastChangeMonitoredItem = 2
}
///
/// Tunables for an .
///
public sealed class AliasNameResolverOptions
{
///
/// How the resolver refreshes its cache; defaults to
/// .
/// Ignored when is set.
///
public AliasNameResolverRefreshMode RefreshMode { get; set; }
= AliasNameResolverRefreshMode.Manual;
///
/// Optional explicit refresh strategy; takes precedence over
/// when non-null. Use this to
/// plug in custom strategies (e.g. the Annex D PubSub bridge in
/// Opc.Ua.Client.AliasNames.PubSub).
///
public IAliasNameRefreshStrategy? RefreshStrategy { get; set; }
///
/// Sampling interval (ms) for the LastChange monitored
/// item created in
///
/// mode. Defaults to 1000ms; ignored by polling and manual modes.
///
public double LastChangeSamplingIntervalMs { get; set; } = 1000.0;
///
/// Publishing interval (ms) for the polling /
/// monitored-item-based refresh strategies. Defaults to 1000ms.
///
public double PublishingIntervalMs { get; set; } = 1000.0;
///
/// When true,
/// prefers FindAliasVerbose and exposes per-target
/// ServerUris; when false (default) it uses the
/// less expensive FindAlias.
///
public bool UseVerbose { get; set; }
internal AliasNameResolverOptions Clone()
{
return new AliasNameResolverOptions
{
RefreshMode = RefreshMode,
RefreshStrategy = RefreshStrategy,
LastChangeSamplingIntervalMs = LastChangeSamplingIntervalMs,
PublishingIntervalMs = PublishingIntervalMs,
UseVerbose = UseVerbose
};
}
}
}