refactor(opcuaclient): remove vestigial TargetNamespaceKind + UnsMappingTable (#648)
Nothing read the mapping table beyond the startup validator; v3 UNS projection is
explicit via UnsTagReference. Legacy keys in stored DriverConfig are ignored (pinned).
Reverts the docker-dev opc-plc seed workaround from fdee129f.
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
+1
-1
@@ -21,7 +21,7 @@ public sealed class OpcUaClientDriverBrowser : IDriverBrowser
|
||||
// Kept identical to OpcUaClientDriverFactoryExtensions.JsonOptions and
|
||||
// OpcUaClientDriverProbe._opts so the browser parses a given DriverConfig JSON
|
||||
// the same way as the factory and the probe. The JsonStringEnumConverter lets
|
||||
// enum-valued knobs (SecurityPolicy / SecurityMode / AuthType / TargetNamespaceKind)
|
||||
// enum-valued knobs (SecurityPolicy / SecurityMode / AuthType)
|
||||
// be authored as their string names — the natural form for AdminUI-emitted JSON.
|
||||
// JsonStringEnumConverter also accepts numeric ordinals, so existing numeric configs
|
||||
// continue to work without migration.
|
||||
|
||||
-49
@@ -153,36 +153,6 @@ public sealed record OpcUaClientDriverOptions
|
||||
[Range(1, int.MaxValue)]
|
||||
public int MaxBrowseDepth { get; init; } = 10;
|
||||
|
||||
/// <summary>
|
||||
/// The namespace kind this driver instance gateways into. Per
|
||||
/// <c>docs/v2/driver-specs.md</c> §8 "Namespace Assignment", the OPC UA Client driver
|
||||
/// is the only driver that supports <b>either</b> kind, decided per instance:
|
||||
/// <list type="bullet">
|
||||
/// <item><see cref="OpcUaTargetNamespaceKind.Equipment"/> — gatewaying a remote
|
||||
/// server that exposes raw equipment data; the driver remaps remote browse paths
|
||||
/// to UNS.</item>
|
||||
/// <item><see cref="OpcUaTargetNamespaceKind.SystemPlatform"/> — gatewaying a
|
||||
/// remote server that exposes processed/derived data; hierarchy is preserved via
|
||||
/// the remote browse path with no UNS conversion.</item>
|
||||
/// </list>
|
||||
/// The driver enforces the choice at startup — see
|
||||
/// <c>OpcUaClientDriver.ValidateNamespaceKind</c> — so a misconfiguration fails
|
||||
/// draft validation rather than surfacing as a runtime surprise.
|
||||
/// </summary>
|
||||
public OpcUaTargetNamespaceKind TargetNamespaceKind { get; init; } = OpcUaTargetNamespaceKind.Equipment;
|
||||
|
||||
/// <summary>
|
||||
/// Optional config-driven remote-to-UNS mapping table. Required when
|
||||
/// <see cref="TargetNamespaceKind"/> is <see cref="OpcUaTargetNamespaceKind.Equipment"/>:
|
||||
/// §8 mandates that a remote server gatewayed as Equipment carry a mapping table
|
||||
/// because remote nodes do not conform to UNS by default. Keys are remote browse-path
|
||||
/// prefixes; values are the UNS Area/Line/Name path the matching subtree maps onto.
|
||||
/// For <see cref="OpcUaTargetNamespaceKind.SystemPlatform"/> the table must be empty —
|
||||
/// processed data preserves its own hierarchy and a mapping table would be ambiguous.
|
||||
/// </summary>
|
||||
public IReadOnlyDictionary<string, string> UnsMappingTable { get; init; }
|
||||
= new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Timeout for the AdminUI Test Connect probe, in seconds. The AdminUI clamps to a
|
||||
/// 60s server-side maximum; this default is what the form pre-fills for new instances.
|
||||
@@ -266,25 +236,6 @@ public sealed record OpcUaCertificateValidationOptions
|
||||
public string? IssuerStorePath { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The namespace kind an OPC UA Client driver instance gateways its remote server into.
|
||||
/// See <c>docs/v2/driver-specs.md</c> §8 "Namespace Assignment".
|
||||
/// </summary>
|
||||
public enum OpcUaTargetNamespaceKind
|
||||
{
|
||||
/// <summary>
|
||||
/// Remote server exposes raw equipment data; remote browse paths are remapped to UNS
|
||||
/// via <see cref="OpcUaClientDriverOptions.UnsMappingTable"/>.
|
||||
/// </summary>
|
||||
Equipment,
|
||||
|
||||
/// <summary>
|
||||
/// Remote server exposes processed/derived data; hierarchy is preserved via the
|
||||
/// remote browse path with no UNS conversion.
|
||||
/// </summary>
|
||||
SystemPlatform,
|
||||
}
|
||||
|
||||
/// <summary>OPC UA message security mode.</summary>
|
||||
public enum OpcUaSecurityMode
|
||||
{
|
||||
|
||||
@@ -241,10 +241,6 @@ public sealed class OpcUaClientDriver : IDriver, ITagDiscovery, IReadable, IWrit
|
||||
if (HasConfigBody(driverConfigJson))
|
||||
_options = OpcUaClientDriverFactoryExtensions.ParseOptions(_driverInstanceId, driverConfigJson);
|
||||
|
||||
// Enforce the Equipment-vs-SystemPlatform choice at startup per driver-specs.md
|
||||
// §8 "Namespace Assignment" — a misconfigured remote fails draft validation here,
|
||||
// not as a runtime surprise.
|
||||
ValidateNamespaceKind(_options);
|
||||
ValidateTuning(_options);
|
||||
|
||||
var appConfig = await BuildApplicationConfigurationAsync(cancellationToken).ConfigureAwait(false);
|
||||
@@ -643,42 +639,6 @@ public sealed class OpcUaClientDriver : IDriver, ITagDiscovery, IReadable, IWrit
|
||||
return effective < TimeSpan.FromMilliseconds(50) ? 50 : (int)effective.TotalMilliseconds;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enforce the §8 "Namespace Assignment" rule at startup. An <c>Equipment</c>-kind
|
||||
/// instance gateways raw equipment data and therefore needs a config-driven UNS
|
||||
/// mapping table (remote nodes don't conform to UNS); a <c>SystemPlatform</c>-kind
|
||||
/// instance gateways processed data whose hierarchy is preserved verbatim, so a
|
||||
/// UNS mapping table is meaningless and rejected. Throwing here surfaces the
|
||||
/// misconfiguration as a draft-validation failure rather than a runtime surprise.
|
||||
/// </summary>
|
||||
/// <param name="opts">Driver options containing namespace configuration.</param>
|
||||
internal static void ValidateNamespaceKind(OpcUaClientDriverOptions opts)
|
||||
{
|
||||
switch (opts.TargetNamespaceKind)
|
||||
{
|
||||
case OpcUaTargetNamespaceKind.Equipment:
|
||||
if (opts.UnsMappingTable is null || opts.UnsMappingTable.Count == 0)
|
||||
throw new InvalidOperationException(
|
||||
"OpcUaClient driver configured with TargetNamespaceKind=Equipment but no " +
|
||||
"UnsMappingTable: §8 requires a config-driven remote-to-UNS mapping table " +
|
||||
"because remote nodes do not conform to UNS by default. Provide a mapping " +
|
||||
"table or set TargetNamespaceKind=SystemPlatform if the remote exposes " +
|
||||
"processed data.");
|
||||
break;
|
||||
case OpcUaTargetNamespaceKind.SystemPlatform:
|
||||
if (opts.UnsMappingTable is { Count: > 0 })
|
||||
throw new InvalidOperationException(
|
||||
"OpcUaClient driver configured with TargetNamespaceKind=SystemPlatform but " +
|
||||
"a UnsMappingTable was supplied: processed data preserves its own hierarchy " +
|
||||
"and a UNS mapping table is ambiguous here. Clear the mapping table or set " +
|
||||
"TargetNamespaceKind=Equipment if the remote exposes raw equipment data.");
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(
|
||||
nameof(opts), opts.TargetNamespaceKind, "Unknown TargetNamespaceKind.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Build the user-identity token from the driver options. Split out of
|
||||
/// <see cref="InitializeAsync"/> so the failover sweep reuses one identity across
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public static class OpcUaClientDriverFactoryExtensions
|
||||
|
||||
// Match OpcUaClientDriverProbe exactly so factory + probe parse a config identically.
|
||||
// The JsonStringEnumConverter lets enum-valued knobs (SecurityMode / SecurityPolicy /
|
||||
// AuthType / TargetNamespaceKind) be authored as their string names — the natural form
|
||||
// AuthType) be authored as their string names — the natural form
|
||||
// for human-edited + AdminUI-emitted DriverConfig JSON.
|
||||
private static readonly JsonSerializerOptions JsonOptions = new()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user