Phase 0 — mechanical rename ZB.MOM.WW.LmxOpcUa.* → ZB.MOM.WW.OtOpcUa.*

Renames all 11 projects (5 src + 6 tests), the .slnx solution file, all source-file namespaces, all axaml namespace references, and all v1 documentation references in CLAUDE.md and docs/*.md (excluding docs/v2/ which is already in OtOpcUa form). Also updates the TopShelf service registration name from "LmxOpcUa" to "OtOpcUa" per Phase 0 Task 0.6.

Preserves runtime identifiers per Phase 0 Out-of-Scope rules to avoid breaking v1/v2 client trust during coexistence: OPC UA `ApplicationUri` defaults (`urn:{GalaxyName}:LmxOpcUa`), server `EndpointPath` (`/LmxOpcUa`), `ServerName` default (feeds cert subject CN), `MxAccessConfiguration.ClientName` default (defensive — stays "LmxOpcUa" for MxAccess audit-trail consistency), client OPC UA identifiers (`ApplicationName = "LmxOpcUaClient"`, `ApplicationUri = "urn:localhost:LmxOpcUaClient"`, cert directory `%LocalAppData%\LmxOpcUaClient\pki\`), and the `LmxOpcUaServer` class name (class rename out of Phase 0 scope per Task 0.5 sed pattern; happens in Phase 1 alongside `LmxNodeManager → GenericDriverNodeManager` Core extraction). 23 LmxOpcUa references retained, all enumerated and justified in `docs/v2/implementation/exit-gate-phase-0.md`.

Build clean: 0 errors, 30 warnings (lower than baseline 167). Tests at strict improvement over baseline: 821 passing / 1 failing vs baseline 820 / 2 (one flaky pre-existing failure passed this run; the other still fails — both pre-existing and unrelated to the rename). `Client.UI.Tests`, `Historian.Aveva.Tests`, `Client.Shared.Tests`, `IntegrationTests` all match baseline exactly. Exit gate compliance results recorded in `docs/v2/implementation/exit-gate-phase-0.md` with all 7 checks PASS or DEFERRED-to-PR-review (#7 service install verification needs Windows service permissions on the reviewer's box).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-04-17 13:57:47 -04:00
parent 5b8d708c58
commit 3b2defd94f
293 changed files with 841 additions and 722 deletions

View File

@@ -0,0 +1,28 @@
using Opc.Ua;
using ZB.MOM.WW.OtOpcUa.Client.Shared.Models;
namespace ZB.MOM.WW.OtOpcUa.Client.Shared.Helpers;
/// <summary>
/// Maps the library's AggregateType enum to OPC UA aggregate function NodeIds.
/// </summary>
public static class AggregateTypeMapper
{
/// <summary>
/// Returns the OPC UA NodeId for the specified aggregate type.
/// </summary>
public static NodeId ToNodeId(AggregateType aggregate)
{
return aggregate switch
{
AggregateType.Average => ObjectIds.AggregateFunction_Average,
AggregateType.Minimum => ObjectIds.AggregateFunction_Minimum,
AggregateType.Maximum => ObjectIds.AggregateFunction_Maximum,
AggregateType.Count => ObjectIds.AggregateFunction_Count,
AggregateType.Start => ObjectIds.AggregateFunction_Start,
AggregateType.End => ObjectIds.AggregateFunction_End,
AggregateType.StandardDeviation => ObjectIds.AggregateFunction_StandardDeviationPopulation,
_ => throw new ArgumentOutOfRangeException(nameof(aggregate), aggregate, "Unknown AggregateType value.")
};
}
}

View File

@@ -0,0 +1,52 @@
namespace ZB.MOM.WW.OtOpcUa.Client.Shared.Helpers;
/// <summary>
/// Parses and normalizes failover URL sets for redundant OPC UA connections.
/// </summary>
public static class FailoverUrlParser
{
/// <summary>
/// Parses a comma-separated failover URL string, prepending the primary URL.
/// Trims whitespace and deduplicates.
/// </summary>
/// <param name="primaryUrl">The primary endpoint URL.</param>
/// <param name="failoverCsv">Optional comma-separated failover URLs.</param>
/// <returns>An array with the primary URL first, followed by unique failover URLs.</returns>
public static string[] Parse(string primaryUrl, string? failoverCsv)
{
if (string.IsNullOrWhiteSpace(failoverCsv))
return [primaryUrl];
var urls = new List<string> { primaryUrl };
foreach (var url in failoverCsv.Split(',', StringSplitOptions.RemoveEmptyEntries))
{
var trimmed = url.Trim();
if (!string.IsNullOrEmpty(trimmed) && !urls.Contains(trimmed, StringComparer.OrdinalIgnoreCase))
urls.Add(trimmed);
}
return urls.ToArray();
}
/// <summary>
/// Builds a failover URL set from the primary URL and an optional array of failover URLs.
/// </summary>
/// <param name="primaryUrl">The primary endpoint URL.</param>
/// <param name="failoverUrls">Optional failover URLs.</param>
/// <returns>An array with the primary URL first, followed by unique failover URLs.</returns>
public static string[] Parse(string primaryUrl, string[]? failoverUrls)
{
if (failoverUrls == null || failoverUrls.Length == 0)
return [primaryUrl];
var urls = new List<string> { primaryUrl };
foreach (var url in failoverUrls)
{
var trimmed = url?.Trim();
if (!string.IsNullOrEmpty(trimmed) && !urls.Contains(trimmed, StringComparer.OrdinalIgnoreCase))
urls.Add(trimmed);
}
return urls.ToArray();
}
}

View File

@@ -0,0 +1,42 @@
using Opc.Ua;
using ZB.MOM.WW.OtOpcUa.Client.Shared.Models;
namespace ZB.MOM.WW.OtOpcUa.Client.Shared.Helpers;
/// <summary>
/// Maps between the library's SecurityMode enum and OPC UA SDK MessageSecurityMode.
/// </summary>
public static class SecurityModeMapper
{
/// <summary>
/// Converts a <see cref="SecurityMode" /> to an OPC UA <see cref="MessageSecurityMode" />.
/// </summary>
public static MessageSecurityMode ToMessageSecurityMode(SecurityMode mode)
{
return mode switch
{
SecurityMode.None => MessageSecurityMode.None,
SecurityMode.Sign => MessageSecurityMode.Sign,
SecurityMode.SignAndEncrypt => MessageSecurityMode.SignAndEncrypt,
_ => throw new ArgumentOutOfRangeException(nameof(mode), mode, "Unknown SecurityMode value.")
};
}
/// <summary>
/// Parses a string to a <see cref="SecurityMode" /> value, case-insensitively.
/// </summary>
/// <param name="value">The string to parse (e.g., "none", "sign", "encrypt", "signandencrypt").</param>
/// <returns>The corresponding SecurityMode.</returns>
/// <exception cref="ArgumentException">Thrown for unrecognized values.</exception>
public static SecurityMode FromString(string value)
{
return (value ?? "none").Trim().ToLowerInvariant() switch
{
"none" => SecurityMode.None,
"sign" => SecurityMode.Sign,
"encrypt" or "signandencrypt" => SecurityMode.SignAndEncrypt,
_ => throw new ArgumentException(
$"Unknown security mode '{value}'. Valid values: none, sign, encrypt, signandencrypt")
};
}
}

View File

@@ -0,0 +1,32 @@
namespace ZB.MOM.WW.OtOpcUa.Client.Shared.Helpers;
/// <summary>
/// Converts raw string values into typed values based on the current value's runtime type.
/// Ported from the CLI tool's OpcUaHelper.ConvertValue.
/// </summary>
public static class ValueConverter
{
/// <summary>
/// Converts a raw string value into the runtime type expected by the target node.
/// </summary>
/// <param name="rawValue">The raw string supplied by the user.</param>
/// <param name="currentValue">The current node value used to infer the target type. May be null.</param>
/// <returns>A typed value suitable for an OPC UA write request.</returns>
public static object ConvertValue(string rawValue, object? currentValue)
{
return currentValue switch
{
bool => bool.Parse(rawValue),
byte => byte.Parse(rawValue),
short => short.Parse(rawValue),
ushort => ushort.Parse(rawValue),
int => int.Parse(rawValue),
uint => uint.Parse(rawValue),
long => long.Parse(rawValue),
ulong => ulong.Parse(rawValue),
float => float.Parse(rawValue),
double => double.Parse(rawValue),
_ => rawValue
};
}
}