feat(historian): AddServerHistorian DI + Host wiring of IHistorianDataSource
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Opc.Ua;
|
||||
using Opc.Ua.Server;
|
||||
using ZB.MOM.WW.OtOpcUa.Commons.OpcUa;
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.OpcUaServer;
|
||||
|
||||
@@ -59,6 +60,28 @@ public sealed class OtOpcUaSdkServer : StandardServer
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wire the server-side HistoryRead backend (the <see cref="IHistorianDataSource"/> the node
|
||||
/// manager's HistoryRead overrides block-bridge to) onto the created
|
||||
/// <see cref="OtOpcUaNodeManager"/>. The host calls this after start with the DI-resolved source —
|
||||
/// the <c>NullHistorianDataSource</c> default (GoodNoData-empty reads) or the configured Wonderware
|
||||
/// read client. Passing <c>null</c> restores the Null default (the property setter null-coalesces),
|
||||
/// i.e. "no historian". No-op (returns <c>false</c>) when the node manager has not been created yet,
|
||||
/// so the caller can detect a too-early call (mirrors <see cref="SetNodeWriteGateway"/>).
|
||||
/// </summary>
|
||||
/// <param name="source">The read backend invoked by the node manager's HistoryRead overrides; may be
|
||||
/// <c>null</c> to restore the Null default (GoodNoData-empty reads).</param>
|
||||
/// <returns><c>true</c> when the source was set on a live node manager; <c>false</c> when no node
|
||||
/// manager exists yet.</returns>
|
||||
public bool SetHistorianDataSource(IHistorianDataSource? source)
|
||||
{
|
||||
if (_otOpcUaNodeManager is null) return false;
|
||||
// The HistorianDataSource setter null-coalesces to the Null default, so a null source is intentional
|
||||
// (restores GoodNoData-empty reads); forgive the nullable-in here.
|
||||
_otOpcUaNodeManager.HistorianDataSource = source!;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override MasterNodeManager CreateMasterNodeManager(
|
||||
IServerInternal server, ApplicationConfiguration configuration)
|
||||
|
||||
Reference in New Issue
Block a user