58 lines
2.9 KiB
C#
58 lines
2.9 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Runtime.Historian;
|
|
|
|
/// <summary>
|
|
/// Binds the <c>ServerHistorian</c> configuration section that gates the server-side
|
|
/// HistoryRead backend. When <see cref="Enabled"/> is <c>true</c>, <c>AddServerHistorian</c>
|
|
/// registers a read-only <c>WonderwareHistorianClient</c> (supplied by the Host) as the
|
|
/// <c>IHistorianDataSource</c> in place of the <c>NullHistorianDataSource</c> default;
|
|
/// otherwise the Null default survives and HistoryRead returns <c>GoodNoData</c>-empty.
|
|
/// <para>
|
|
/// This is the READ path only — there are no DatabasePath / drain / capacity / retention
|
|
/// knobs (those belong to the write-side <c>AlarmHistorian</c> store-and-forward sink). The
|
|
/// client's own <c>CallTimeout</c> bounds each read; the node manager adds no extra timeout.
|
|
/// </para>
|
|
/// </summary>
|
|
public sealed class ServerHistorianOptions
|
|
{
|
|
/// <summary>The configuration section name this options class binds.</summary>
|
|
public const string SectionName = "ServerHistorian";
|
|
|
|
/// <summary>
|
|
/// When <c>true</c>, the Wonderware read client is registered as the
|
|
/// <c>IHistorianDataSource</c>; when <c>false</c> (the default) the no-op
|
|
/// <c>NullHistorianDataSource</c> stays in place and HistoryRead returns empty.
|
|
/// </summary>
|
|
public bool Enabled { get; init; }
|
|
|
|
/// <summary>TCP hostname or IP address the Wonderware historian sidecar listens on.</summary>
|
|
public string Host { get; init; } = "localhost";
|
|
|
|
/// <summary>TCP port the Wonderware historian sidecar listens on.</summary>
|
|
public int Port { get; init; } = 32569;
|
|
|
|
/// <summary>When <c>true</c>, the client connects over TLS.</summary>
|
|
public bool UseTls { get; init; }
|
|
|
|
/// <summary>Expected TLS server certificate thumbprint (hex, no spaces). Null or empty disables pinning.</summary>
|
|
public string? ServerCertThumbprint { get; init; }
|
|
|
|
/// <summary>Per-process shared secret the sidecar verifies in the Hello frame.</summary>
|
|
public string SharedSecret { get; init; } = "";
|
|
|
|
/// <summary>Returns operator-facing misconfiguration warnings for an <c>Enabled</c> historian
|
|
/// (empty when disabled or correctly configured). Pure — the registration logs each entry.</summary>
|
|
/// <returns>Zero or more human-readable warning messages.</returns>
|
|
public IReadOnlyList<string> Validate()
|
|
{
|
|
var warnings = new List<string>();
|
|
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;
|
|
}
|
|
}
|