From 83e1318425c47fbada7534473d64011670fdd143 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sun, 14 Jun 2026 20:23:22 -0400 Subject: [PATCH] refactor(historian): align ServerHistorianOptions with AlarmHistorian (Port default, Validate list, log context) --- .../Historian/ServerHistorianOptions.cs | 12 +++++++----- .../ServiceCollectionExtensions.cs | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/Historian/ServerHistorianOptions.cs b/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/Historian/ServerHistorianOptions.cs index c63cb16a..254dd24a 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/Historian/ServerHistorianOptions.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/Historian/ServerHistorianOptions.cs @@ -30,7 +30,7 @@ public sealed class ServerHistorianOptions public string Host { get; init; } = "localhost"; /// TCP port the Wonderware historian sidecar listens on. - public int Port { get; init; } + public int Port { get; init; } = 32569; /// When true, the client connects over TLS. public bool UseTls { get; init; } @@ -44,12 +44,14 @@ public sealed class ServerHistorianOptions /// Returns operator-facing misconfiguration warnings for an Enabled historian /// (empty when disabled or correctly configured). Pure — the registration logs each entry. /// Zero or more human-readable warning messages. - public IEnumerable Validate() + public IReadOnlyList Validate() { - if (!Enabled) yield break; + var warnings = new List(); + if (!Enabled) return warnings; if (string.IsNullOrWhiteSpace(SharedSecret)) - yield return "ServerHistorian:SharedSecret is empty while the historian is enabled — the Wonderware sidecar Hello frame will carry an empty secret."; + warnings.Add("ServerHistorian:SharedSecret is empty while the historian is enabled — the Wonderware sidecar Hello frame will carry an empty secret."); if (Port <= 0) - yield return $"ServerHistorian:Port is {Port} — must be > 0; the read client cannot dial the sidecar."; + warnings.Add($"ServerHistorian:Port is {Port} — must be > 0; the read client cannot dial the sidecar."); + return warnings; } } diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/ServiceCollectionExtensions.cs b/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/ServiceCollectionExtensions.cs index e31a023a..c6aa75c6 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/ServiceCollectionExtensions.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/ServiceCollectionExtensions.cs @@ -119,7 +119,7 @@ public static class ServiceCollectionExtensions if (opts is not { Enabled: true }) return services; // leave the Null default from AddOtOpcUaRuntime foreach (var warning in opts.Validate()) - Serilog.Log.Logger.ForContext().Warning("ServerHistorian config: {ServerHistorianConfigWarning}", warning); + Serilog.Log.Logger.ForContext().Warning("ServerHistorian config: {ServerHistorianConfigWarning}", warning); // Last-registration-wins over the TryAddSingleton Null default seeded by AddOtOpcUaRuntime. services.AddSingleton(sp => dataSourceFactory(opts, sp));