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; /// /// for the HistorianGateway sidecar. Numeric-only /// (Double/Int64/Boolean) and read/alarm/provisioning only — no HistoryUpdate. /// public sealed class GatewayHistorianProvider : IHistorianBackendProvider { private readonly ServerHistorianOptions _options; /// Creates the provider over the bound ServerHistorian options. /// The gateway connection options. public GatewayHistorianProvider(ServerHistorianOptions options) { _options = options ?? throw new ArgumentNullException(nameof(options)); } /// public string Name => "Gateway"; // The recorder's own default set (ContinuousHistorizationRecorder.DefaultSupportedKinds), so the // gateway's kinds and the recorder's fallback can never drift apart. /// public IReadOnlySet SupportedKinds => ContinuousHistorizationRecorder.DefaultSupportedKinds; /// public IHistorianDataSource CreateDataSource(IServiceProvider sp) => GatewayHistorian.CreateDataSource(_options, sp); /// public IHistorianValueWriter CreateValueWriter(IServiceProvider sp) { ArgumentNullException.ThrowIfNull(sp); var loggerFactory = sp.GetService() ?? NullLoggerFactory.Instance; var logger = sp.GetService>() ?? NullLogger.Instance; return new GatewayHistorianValueWriter(HistorianGatewayClientAdapter.Create(_options, loggerFactory), logger); } /// public IAlarmHistorianWriter CreateAlarmWriter(IServiceProvider sp) => GatewayHistorian.CreateAlarmWriter(_options, sp); /// public IHistorianProvisioning CreateProvisioning(IServiceProvider sp) => GatewayHistorian.CreateProvisioner(_options, sp); /// public IHistorianDataUpdater? CreateUpdater(IServiceProvider sp) => null; }