Merge ph-T4 (pluggable historian)

Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
Joseph Doherty
2026-10-09 12:57:52 -04:00
6 changed files with 198 additions and 5 deletions
@@ -38,8 +38,6 @@ namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Recorder;
/// </remarks>
public sealed class GatewayHistorianValueWriter : IHistorianValueWriter, IAsyncDisposable
{
private const uint LegacyGoodQuality = 192;
private readonly IHistorianGatewayClient _client;
private readonly ILogger<GatewayHistorianValueWriter> _logger;
@@ -70,12 +68,20 @@ public sealed class GatewayHistorianValueWriter : IHistorianValueWriter, IAsyncD
var liveValues = new List<HistorianLiveValue>(values.Count);
foreach (HistorizationValue value in values)
{
if (!value.Value.TryGetDouble(out double number))
{
// The gateway live path is numeric-only; non-numeric kinds are skipped, never thrown.
_logger.LogDebug("Skipping non-numeric {Kind} value for live write.", value.Value.Kind);
continue;
}
var live = new HistorianLiveValue
{
NumericValue = value.Value.Number,
NumericValue = number,
// Documented-dead input on the WriteLiveValues SQL path (0.2.0 Contracts C-002 —
// server-managed, silently discarded). Populated deliberately; see the class <remarks>.
Quality = LegacyGoodQuality,
// server-managed, silently discarded). Populated deliberately from the value's
// status; Good maps to 192 as before. See the class <remarks>.
Quality = Mapping.GatewayQualityMapper.ToDaQuality(value.StatusCode),
};
if (value.TimestampUtc is { } timestampUtc)
@@ -88,6 +94,12 @@ public sealed class GatewayHistorianValueWriter : IHistorianValueWriter, IAsyncD
liveValues.Add(live);
}
if (liveValues.Count == 0)
{
// Every value was non-numeric: nothing to send, trivially drained.
return true;
}
WriteAck ack = await _client.WriteLiveValuesAsync(tag, liveValues, ct).ConfigureAwait(false);
return ack.Success || ack.Queued;
}