using System.Collections.Generic; namespace ZB.MOM.WW.OtOpcUa.Runtime.Historian; /// /// Binds the ServerHistorian configuration section that gates the server-side /// HistoryRead backend. When is true, AddServerHistorian /// registers a read-only WonderwareHistorianClient (supplied by the Host) as the /// IHistorianDataSource in place of the NullHistorianDataSource default; /// otherwise the Null default survives and HistoryRead returns GoodNoData-empty. /// /// This is the READ path only — there are no DatabasePath / drain / capacity / retention /// knobs (those belong to the write-side AlarmHistorian store-and-forward sink). The /// client's own CallTimeout bounds each read; the node manager adds no extra timeout. /// /// public sealed class ServerHistorianOptions { /// The configuration section name this options class binds. public const string SectionName = "ServerHistorian"; /// /// When true, the Wonderware read client is registered as the /// IHistorianDataSource; when false (the default) the no-op /// NullHistorianDataSource stays in place and HistoryRead returns empty. /// public bool Enabled { get; init; } /// TCP hostname or IP address the Wonderware historian sidecar listens on. public string Host { get; init; } = "localhost"; /// TCP port the Wonderware historian sidecar listens on. public int Port { get; init; } = 32569; /// When true, the client connects over TLS. public bool UseTls { get; init; } /// Expected TLS server certificate thumbprint (hex, no spaces). Null or empty disables pinning. public string? ServerCertThumbprint { get; init; } /// Per-process shared secret the sidecar verifies in the Hello frame. public string SharedSecret { get; init; } = ""; /// 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 IReadOnlyList Validate() { var warnings = new List(); if (!Enabled) return warnings; if (string.IsNullOrWhiteSpace(SharedSecret)) warnings.Add("ServerHistorian:SharedSecret is empty while the historian is enabled — the Wonderware sidecar Hello frame will carry an empty secret."); if (Port <= 0) warnings.Add($"ServerHistorian:Port is {Port} — must be > 0; the read client cannot dial the sidecar."); return warnings; } }