821763a09d
- I-1: an Empty sample is always Bad. The writer stores a non-Bad NaN/Inf as Empty+BadOutOfRange and any other non-Bad Empty as BadNoData; the updater refuses a non-Bad Empty with BadInvalidArgument; reads clamp a legacy non-Bad Empty row to BadNoData (Raw and AtTime). - Tag/source names over 400 chars are refused, never truncated: writer per-tag failure, updater BadInvalidArgument, reads not-found, events none. - HistorianInfoBits masks the historian bits before setting one. - AtTime past now, stepped from the last sample => UncertainDataSubNormal. - Bootstrapper: logger, 5 s negative cache, ClearPool + Warning when sp_releaseapplock fails. - Provider builds its shared state lazily (an invalid Schema no longer throws at Resolve); Kinds is a FrozenSet; Gateway reuses the recorder's DefaultSupportedKinds. - Cleanup: SqlHistorianDataTypes in its own file (updater dup removed), dead Invalidate and unused status consts deleted, named severity masks, alarm writer brace. Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
58 lines
2.5 KiB
C#
58 lines
2.5 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
|
using ZB.MOM.WW.OtOpcUa.Core.AlarmHistorian;
|
|
using ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Recorder;
|
|
using ZB.MOM.WW.OtOpcUa.Runtime.Historian;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway;
|
|
|
|
/// <summary>
|
|
/// <see cref="IHistorianBackendProvider"/> for the HistorianGateway sidecar. Numeric-only
|
|
/// (<c>Double</c>/<c>Int64</c>/<c>Boolean</c>) and read/alarm/provisioning only — no HistoryUpdate.
|
|
/// </summary>
|
|
public sealed class GatewayHistorianProvider : IHistorianBackendProvider
|
|
{
|
|
private readonly ServerHistorianOptions _options;
|
|
|
|
/// <summary>Creates the provider over the bound <c>ServerHistorian</c> options.</summary>
|
|
/// <param name="options">The gateway connection options.</param>
|
|
public GatewayHistorianProvider(ServerHistorianOptions options)
|
|
{
|
|
_options = options ?? throw new ArgumentNullException(nameof(options));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public string Name => "Gateway";
|
|
|
|
/// <inheritdoc />
|
|
/// <remarks>
|
|
/// The recorder's own default set (<see cref="ContinuousHistorizationRecorder.DefaultSupportedKinds"/>), so the
|
|
/// gateway's kinds and the recorder's fallback can never drift apart.
|
|
/// </remarks>
|
|
public IReadOnlySet<HistorianValueKind> SupportedKinds => ContinuousHistorizationRecorder.DefaultSupportedKinds;
|
|
|
|
/// <inheritdoc />
|
|
public IHistorianDataSource CreateDataSource(IServiceProvider sp) => GatewayHistorian.CreateDataSource(_options, sp);
|
|
|
|
/// <inheritdoc />
|
|
public IHistorianValueWriter CreateValueWriter(IServiceProvider sp)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(sp);
|
|
var loggerFactory = sp.GetService<ILoggerFactory>() ?? NullLoggerFactory.Instance;
|
|
var logger = sp.GetService<ILogger<GatewayHistorianValueWriter>>()
|
|
?? NullLogger<GatewayHistorianValueWriter>.Instance;
|
|
return new GatewayHistorianValueWriter(HistorianGatewayClientAdapter.Create(_options, loggerFactory), logger);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public IAlarmHistorianWriter CreateAlarmWriter(IServiceProvider sp) => GatewayHistorian.CreateAlarmWriter(_options, sp);
|
|
|
|
/// <inheritdoc />
|
|
public IHistorianProvisioning CreateProvisioning(IServiceProvider sp) => GatewayHistorian.CreateProvisioner(_options, sp);
|
|
|
|
/// <inheritdoc />
|
|
public IHistorianDataUpdater? CreateUpdater(IServiceProvider sp) => null;
|
|
}
|