@page "/clusters/{ClusterId}/data-connections" @attribute [Authorize(Policy = AdminUiPolicies.AuthenticatedRead)] @rendermode RenderMode.InteractiveServer @using ZB.MOM.WW.OtOpcUa.AdminUI.DataConnections @using ZB.MOM.WW.OtOpcUa.Configuration.Entities @using ZB.MOM.WW.OtOpcUa.Configuration.Validation @using ZB.MOM.WW.OtOpcUa.Core.Abstractions.DataConnections @using ZB.MOM.WW.OtOpcUa.Commons.OpcUa @using ZB.MOM.WW.OtOpcUa.Commons.Interfaces @using ZB.MOM.WW.OtOpcUa.Commons.Types @inject DataConnectionAdminService Service @inject IFleetDiagnosticsClient Diagnostics Data connections · OtOpcUa

Data connections · @ClusterId

Connections are directional. Exports grant a peer access to local data; mappings place remote data under a local Raw or UNS parent.

Changes are saved as drafts. Deploy them from Deployments; saving alone does not start or stop an import. Runtime status is unavailable until reported by a node.
@if (_snapshot is null) {

Loading…

} else { @if (_error is not null) { } @if (_message is not null) {
@_message
}

Connections

@if (!ConnectionRows.Any()) {

No draft, applied, or observed connections.

} @foreach (var row in ConnectionRows) {
@row.Id@if (row.Draft is { } draft) { Draft: @(draft.Enabled ? "enabled" : "disabled") } else { Removed from draft }@if (!_live.Any(x => Same(x.Row.ConnectionId, row.Id))) { Runtime: unavailable } @foreach (var live in _live.Where(x => Same(x.Row.ConnectionId, row.Id))) {
@live.NodeId: @DataConnectionDiagnostics.State(live.Row.State) · revision @live.Row.Revision · endpoint @DataConnectionDiagnostics.Endpoint(live.Row.SelectedEndpoint) @if (live.Row.Serving is { } serving) { · serving @serving.NodeId · role @serving.Role · incarnation @serving.Incarnation }
Streams @live.Row.ActiveStreams · calls @live.Row.ActiveCalls · retained import views @Measure(live.Row.SourceCount) · registrations @Measure(live.Row.RegistrationCount) · resets @Measure(live.Row.ResetCount) · coalesced notices @Measure(live.Row.CoalescedCount) · overflows @Measure(live.Row.OverflowCount)
Writes succeeded @Measure(live.Row.WriteSucceededCount) · rejected @Measure(live.Row.WriteRejectedCount) · failed @Measure(live.Row.WriteFailedCount) · unconfirmed @Measure(live.Row.WriteUnconfirmedCount) · unknown @Measure(live.Row.WriteUnknownCount)
Last observed sample bound @Time(live.Row.LastSampleAtUtc) (age upper bound @DataConnectionDiagnostics.SampleAge(live.Row)) · metadata lease expires @Time(live.Row.MetadataLeaseExpiresAtUtc) · last handshake @Time(live.Row.LastVerifiedAtUtc) · observed @live.Row.AsOfUtc.ToString("u") · artifact @live.Row.ArtifactRevision · protocol @(live.Row.ProtocolMajor is { } major && live.Row.ProtocolMinor is { } minor ? $"{major}.{minor}" : "unavailable")
Negotiated features @DataConnectionDiagnostics.Features(live.Row.NegotiatedFeatures) · origin history @DataConnectionDiagnostics.HistoryServed(live.Row) · projected history reads @DataConnectionDiagnostics.HistoryCounts(live.Row.HistoryReadsGood, live.Row.HistoryReadsUncertain, live.Row.HistoryReadsBad) · open remote continuations (local sessions) @Measure(live.Row.OpenRemoteContinuations)
Dropped unknown operation bits: connection @DataConnectionDiagnostics.DroppedBits(live.Row.DroppedUnknownOperations) · mappings with dropped bits @Measure(live.Row.MappingsWithDroppedOperations)@if (DataConnectionDiagnostics.HasDrops(live.Row.DroppedUnknownOperations, live.Row.MappingsWithDroppedOperations)) { — this node's build is older than a feature authored here; the dropped bits grant nothing until the node is upgraded. }
} @foreach (var applied in _applied.Where(x => Same(x.ConnectionId, row.Id))) { @applied.NodeId: last applied revision @applied.Revision (@(applied.Enabled ? "enabled" : "disabled")) } @if (row.Draft is { } editable) { }
}

Origin evidence by node

@if (!_nodeSnapshots.Any()) {

No node has reported.

} @foreach (var (nodeId, node) in _nodeSnapshots) {
@nodeId @if (node.OriginHistory is { } origin) { · remote history @(origin.Available ? "served" : "no historian backend") · peer history sessions @origin.Sessions · open origin continuations @origin.OpenContinuations · history items answered @DataConnectionDiagnostics.HistoryCounts(origin.ReadsGood, origin.ReadsUncertain, origin.ReadsBad)@(origin.NoPeerTrafficYet ? " · no peer has called since start" : "") } else { · remote history evidence unavailable } @if (node.DroppedExportOperations is { } dropped) { @if (dropped.Count == 0) { · dropped unknown export bits: none } else {
Exports with dropped unknown operation bits: @string.Join("; ", dropped.OrderBy(x => x.Key, StringComparer.OrdinalIgnoreCase).Select(x => $"{x.Key}: {DataConnectionDiagnostics.DroppedBits(x.Value)}")) — this node's build is older than a feature authored here; the dropped bits grant nothing until the node is upgraded.
} } else { · dropped unknown export bits unavailable }
}

Exports

@if (!Exports.Any()) {

No export grants have been authored.

} @foreach (var e in Exports) {
@e.DataExportId@e.Realm · @e.RootKind · @e.PrincipalIdDraft: @(e.Enabled ? "enabled" : "disabled")
}

Mappings

@if (!Mappings.Any()) {

No remote branches have been mapped.

} @foreach (var w in DataOperationAuthoring.ConditionCapacityWarnings(_snapshot!, ClusterId)) {
@w
} @foreach (var m in Mappings) {
@m.RemoteNamespaceMappingId@m.Realm · @m.BranchName via @m.DataConnectionIdDraft: @(m.Enabled ? "enabled" : "disabled")
}
@if (_deleteCandidate is not null) { } @if (_connection is not null) { var c = _connection.Value;

Connection draft

@if (c.TargetMode == DataTargetMode.Node) { } else { }
Reference only; never enter a key or secret value.
Consumer nodes@foreach (var n in Nodes) { }
@Operations(c.AllowedOperations, v => c.AllowedOperations = v)
Each remote HistoryRead call is bounded by the caller's remaining deadline and this, and in addition by the origin's DataConnections:UnaryTimeout (30 s by default): a larger value has no effect past it.
@Actions(c, c.DataConnectionRowId != Guid.Empty)
} @if (_export is not null) { var e = _export;

Export draft

@Operations(e.AllowedOperations, v => e.AllowedOperations = v)
Larger answers are sent in bounded chunks.
A remote AlarmSubscribe scope with more conditions than this is refused (ConditionCapacity) before anything is imported.
Galaxy-sourced alarms are acknowledged under this peer's API-key Galaxy ack identity (provision otopcua/apikeys/<keyId>/galaxy-ack-user and …/galaxy-ack-password on this cluster). Requires AlarmAcknowledge.
@Actions(e, e.DataExportRowId != Guid.Empty)
} @if (_mapping is not null) { var m = _mapping.Value;

Mapping draft

The picker uses the configured target cluster. For a separately managed cluster, enter its root ID below.
Consumer nodes@foreach (var n in Nodes) { }
@Operations(m.AllowedOperations, v => m.AllowedOperations = v)
A remote alarm scope larger than this makes the mapping's alarms Unavailable (ConditionCapacity); each imported condition materialises up to @DataConnectionValidator.NodesPerImportedCondition nodes.
@Actions(m, m.RemoteNamespaceMappingRowId != Guid.Empty)
}
}
@code { [Parameter] public string ClusterId { get; set; } = ""; private DraftSnapshot? _snapshot; private DataConnectionEditorModel? _connection; private DataExport? _export; private RemoteMappingEditorModel? _mapping; private string? _error, _message; private object? _deleteCandidate; private IReadOnlyList _applied = []; private List<(string NodeId, DataConnectionDiagnosticsSnapshot Row)> _live = []; private List<(string NodeId, NodeDiagnosticsSnapshot Snapshot)> _nodeSnapshots = []; private IReadOnlyList ConnectionRows => DataConnectionDiagnostics.Rows(Connections, _applied.Select(x => x.ConnectionId), _live.Select(x => x.Row.ConnectionId)); private IEnumerable Connections => _snapshot!.DataConnections.Where(x => Same(x.ClusterId, ClusterId)); private IEnumerable Exports => _snapshot!.DataExports.Where(x => Same(x.ClusterId, ClusterId)); private IEnumerable Mappings => _snapshot!.RemoteNamespaceMappings.Where(x => Same(x.ClusterId, ClusterId)); private IEnumerable Nodes => _snapshot!.ClusterNodes.Where(x => Same(x.ClusterId, ClusterId) && x.Enabled); protected override async Task OnInitializedAsync() => await Reload(); private async Task Reload() { _snapshot = await Service.LoadAsync(); _applied = await Service.LoadAppliedAsync(ClusterId); var observations = await Task.WhenAll(Nodes.Select(async node => { try { return (node.NodeId, Snapshot: (NodeDiagnosticsSnapshot?)await Diagnostics.GetDiagnosticsAsync(NodeId.Parse($"{node.Host}:{node.AkkaPort}"), CancellationToken.None)); } catch (Exception) { return (node.NodeId, Snapshot: (NodeDiagnosticsSnapshot?)null); } })); _nodeSnapshots = observations.Where(x => x.Snapshot is not null).Select(x => (x.NodeId, x.Snapshot!)).ToList(); _live = observations.Where(x => x.Snapshot?.DataConnections is not null) .SelectMany(x => x.Snapshot!.DataConnections!.Select(row => (x.NodeId, row))).ToList(); } private static string Measure(T? value) where T : struct => value?.ToString() ?? "unavailable"; private static string Time(DateTime? value) => value?.ToString("u") ?? "unavailable"; private static bool Same(string? a, string? b) => string.Equals(a, b, StringComparison.OrdinalIgnoreCase); private static T Clone(T value) => System.Text.Json.JsonSerializer.Deserialize(System.Text.Json.JsonSerializer.Serialize(value))!; private void Clear() { _connection = null; _export = null; _mapping = null; _deleteCandidate = null; _error = null; _message = null; } private void NewConnection() { Clear(); _connection = new(); _connection.Value.ClusterId = ClusterId; _connection.Value.SecretScopeClusterId = ClusterId; } private void NewExport() { Clear(); _export = new() { ClusterId = ClusterId, Realm = DataRealm.Raw, AllowedOperations = DataOperations.Browse | DataOperations.Metadata | DataOperations.Read | DataOperations.Subscribe }; } private void NewMapping() { Clear(); _mapping = new(); _mapping.Value.ClusterId = ClusterId; SetRealm(_mapping.Value); } private void Edit(DataConnection c) { Clear(); _connection = new() { Value = Clone(c) }; } private void Edit(DataExport e) { Clear(); _export = Clone(e); } private void Edit(RemoteNamespaceMapping m) { Clear(); _mapping = new() { Value = Clone(m) }; } private static void Toggle(List ids, string id, bool on) { if (on && !ids.Contains(id)) ids.Add(id); else if (!on) ids.Remove(id); } private static void TargetChanged(DataConnection c) { if (c.TargetMode == DataTargetMode.Cluster) c.ExpectedNodeId = null; else c.EligibleTargetNodeIds.Clear(); } private static void SetRealm(RemoteNamespaceMapping m) { m.RemoteRealm = m.Realm; m.RemoteNamespaceUri = m.Realm == DataRealm.Raw ? V3NodeIds.RawNamespaceUri : V3NodeIds.UnsNamespaceUri; } private static void SetParent(RemoteNamespaceMapping m, string? value) { var p = (value ?? "").Split('|', 2); m.LocalParentKind = p[0]; m.LocalParentId = p.Length > 1 ? p[1] : ""; } private static void SetExportRoot(DataExport e, string? value) { var p = (value ?? "").Split('|', 2); e.RootKind = p[0]; e.RootEntityId = p.Length > 1 ? p[1] : ""; } private IEnumerable<(string Value, string Label)> Parents(DataRealm realm) { yield return ($"Cluster|{ClusterId}", "Cluster root"); if (realm == DataRealm.Raw) { foreach (var x in _snapshot!.RawFolders.Where(x => Same(x.ClusterId, ClusterId))) yield return ($"RawFolder|{x.RawFolderId}", $"Folder: {x.Name} ({x.RawFolderId})"); foreach (var x in _snapshot.DriverInstances.Where(x => Same(x.ClusterId, ClusterId))) yield return ($"RawDriver|{x.DriverInstanceId}", $"Driver: {x.Name} ({x.DriverInstanceId})"); var drivers = _snapshot.DriverInstances.Where(x => Same(x.ClusterId, ClusterId)).Select(x => x.DriverInstanceId).ToHashSet(StringComparer.OrdinalIgnoreCase); var devices = _snapshot.Devices.Where(x => drivers.Contains(x.DriverInstanceId)).ToList(); foreach (var x in devices) yield return ($"RawDevice|{x.DeviceId}", $"Device: {x.Name} ({x.DeviceId})"); var ids = devices.Select(x => x.DeviceId).ToHashSet(StringComparer.OrdinalIgnoreCase); foreach (var x in _snapshot.TagGroups.Where(x => ids.Contains(x.DeviceId))) yield return ($"RawTagGroup|{x.TagGroupId}", $"Tag group: {x.Name} ({x.TagGroupId})"); } else if (realm == DataRealm.Uns) { var areas = _snapshot!.UnsAreas.Where(x => Same(x.ClusterId, ClusterId)).ToList(); foreach (var x in areas) yield return ($"UnsArea|{x.UnsAreaId}", $"Area: {x.Name} ({x.UnsAreaId})"); var areaIds = areas.Select(x => x.UnsAreaId).ToHashSet(StringComparer.OrdinalIgnoreCase); var lines = _snapshot.UnsLines.Where(x => areaIds.Contains(x.UnsAreaId)).ToList(); foreach (var x in lines) yield return ($"UnsLine|{x.UnsLineId}", $"Line: {x.Name} ({x.UnsLineId})"); var lineIds = lines.Select(x => x.UnsLineId).ToHashSet(StringComparer.OrdinalIgnoreCase); foreach (var x in _snapshot.Equipment.Where(x => lineIds.Contains(x.UnsLineId))) yield return ($"Equipment|{x.EquipmentId}", $"Equipment: {x.Name} ({x.EquipmentId})"); } } private IEnumerable<(string Value, string Label)> ExportRoots(DataRealm realm) { foreach (var parent in Parents(realm)) yield return parent; if (realm == DataRealm.Raw) { var drivers = _snapshot!.DriverInstances.Where(x => Same(x.ClusterId, ClusterId)).Select(x => x.DriverInstanceId).ToHashSet(StringComparer.OrdinalIgnoreCase); var devices = _snapshot.Devices.Where(x => drivers.Contains(x.DriverInstanceId)).Select(x => x.DeviceId).ToHashSet(StringComparer.OrdinalIgnoreCase); foreach (var tag in _snapshot.Tags.Where(x => devices.Contains(x.DeviceId))) yield return ($"RawTag|{tag.TagId}", $"Tag: {tag.Name} ({tag.TagId})"); } else if (realm == DataRealm.Uns) { var areas = _snapshot!.UnsAreas.Where(x => Same(x.ClusterId, ClusterId)).Select(x => x.UnsAreaId).ToHashSet(StringComparer.OrdinalIgnoreCase); var lines = _snapshot.UnsLines.Where(x => areas.Contains(x.UnsAreaId)).Select(x => x.UnsLineId).ToHashSet(StringComparer.OrdinalIgnoreCase); var equipment = _snapshot.Equipment.Where(x => lines.Contains(x.UnsLineId)).Select(x => x.EquipmentId).ToHashSet(StringComparer.OrdinalIgnoreCase); foreach (var tag in _snapshot.VirtualTags.Where(x => equipment.Contains(x.EquipmentId))) yield return ($"VirtualTag|{tag.VirtualTagId}", $"Virtual tag: {tag.Name} ({tag.VirtualTagId})"); foreach (var tag in _snapshot.UnsTagReferences.Where(x => equipment.Contains(x.EquipmentId))) yield return ($"UnsTagReference|{tag.UnsTagReferenceId}", $"Tag reference: {tag.UnsTagReferenceId}"); } } private IEnumerable<(string Id, string Label)> RemoteRoots(RemoteNamespaceMapping mapping) { var target = Connections.FirstOrDefault(x => Same(x.DataConnectionId, mapping.DataConnectionId))?.ExpectedClusterId; if (string.IsNullOrEmpty(target)) yield break; yield return (target, "Cluster root: " + target); if (mapping.Realm == DataRealm.Raw) { foreach (var x in _snapshot!.RawFolders.Where(x => Same(x.ClusterId, target))) yield return (x.RawFolderId, $"Folder: {x.Name} ({x.RawFolderId})"); var drivers = _snapshot.DriverInstances.Where(x => Same(x.ClusterId, target)).ToList(); foreach (var x in drivers) yield return (x.DriverInstanceId, $"Driver: {x.Name} ({x.DriverInstanceId})"); var driverIds = drivers.Select(x => x.DriverInstanceId).ToHashSet(StringComparer.OrdinalIgnoreCase); var devices = _snapshot.Devices.Where(x => driverIds.Contains(x.DriverInstanceId)).ToList(); foreach (var x in devices) yield return (x.DeviceId, $"Device: {x.Name} ({x.DeviceId})"); var deviceIds = devices.Select(x => x.DeviceId).ToHashSet(StringComparer.OrdinalIgnoreCase); foreach (var x in _snapshot.TagGroups.Where(x => deviceIds.Contains(x.DeviceId))) yield return (x.TagGroupId, $"Tag group: {x.Name} ({x.TagGroupId})"); foreach (var x in _snapshot.Tags.Where(x => deviceIds.Contains(x.DeviceId))) yield return (x.TagId, $"Tag: {x.Name} ({x.TagId})"); } else { var areas = _snapshot!.UnsAreas.Where(x => Same(x.ClusterId, target)).ToList(); foreach (var x in areas) yield return (x.UnsAreaId, $"Area: {x.Name} ({x.UnsAreaId})"); var areaIds = areas.Select(x => x.UnsAreaId).ToHashSet(StringComparer.OrdinalIgnoreCase); var lines = _snapshot.UnsLines.Where(x => areaIds.Contains(x.UnsAreaId)).ToList(); foreach (var x in lines) yield return (x.UnsLineId, $"Line: {x.Name} ({x.UnsLineId})"); var lineIds = lines.Select(x => x.UnsLineId).ToHashSet(StringComparer.OrdinalIgnoreCase); foreach (var x in _snapshot.Equipment.Where(x => lineIds.Contains(x.UnsLineId))) yield return (x.EquipmentId, $"Equipment: {x.Name} ({x.EquipmentId})"); } } private RenderFragment Operations(DataOperations current, Action set) => builder => { builder.OpenElement(0, "fieldset"); builder.OpenElement(1, "legend"); builder.AddAttribute(2, "class", "fs-6"); builder.AddContent(3, "Allowed operations"); builder.CloseElement(); foreach (var bit in DataOperationAuthoring.AuthorableOperations) { builder.OpenElement(4, "label"); builder.AddAttribute(5, "class", "me-3"); builder.OpenElement(6, "input"); builder.AddAttribute(7, "type", "checkbox"); builder.AddAttribute(8, "checked", current.HasFlag(bit)); builder.AddAttribute(9, "onchange", EventCallback.Factory.Create(this, args => set((bool)args.Value! ? current | bit : current & ~bit))); builder.CloseElement(); builder.AddContent(10, " " + DataOperationAuthoring.Label(bit)); builder.CloseElement(); } if (DataOperationAuthoring.FeatureBitBanner(current) is { } banner) { // Plan §4.3: the X0-everywhere rule is procedural, so the editor reminds whenever a post-v1 bit is ticked. builder.OpenElement(11, "div"); builder.AddAttribute(12, "class", "notice mt-2"); builder.AddAttribute(13, "role", "note"); builder.AddContent(14, banner); builder.CloseElement(); } builder.CloseElement(); }; private RenderFragment Actions(object row, bool existing) => builder => { builder.OpenElement(0, "div"); builder.AddAttribute(1, "class", "d-flex gap-2 mt-3"); builder.OpenElement(2, "button"); builder.AddAttribute(3, "class", "btn btn-primary"); builder.AddAttribute(4, "onclick", EventCallback.Factory.Create(this, () => Save(row))); builder.AddContent(5, "Save draft"); builder.CloseElement(); builder.OpenElement(6, "button"); builder.AddAttribute(7, "class", "btn btn-outline-secondary"); builder.AddAttribute(8, "onclick", EventCallback.Factory.Create(this, Clear)); builder.AddContent(9, "Cancel"); builder.CloseElement(); if (existing) { builder.OpenElement(10, "button"); builder.AddAttribute(11, "class", "btn btn-outline-danger"); builder.AddAttribute(12, "onclick", EventCallback.Factory.Create(this, () => _deleteCandidate = row)); builder.AddContent(13, "Delete draft"); builder.CloseElement(); } builder.CloseElement(); }; private async Task Save(object row) { try { await Service.SaveAsync(ClusterId, row); Clear(); await Reload(); _message = "Draft saved. Deploy to apply it."; } catch (Exception ex) { _error = ex is UnauthorizedAccessException or InvalidOperationException ? ex.Message : "Could not save the draft. It may have changed; reload and try again."; } } private async Task Delete(object? row) { try { if (row is null) return; await Service.DeleteAsync(ClusterId, row); Clear(); await Reload(); _message = "Draft deleted. Deploy to apply the change."; } catch (Exception ex) { _error = ex is UnauthorizedAccessException or InvalidOperationException ? ex.Message : "Could not delete the draft. Reload and try again."; } } }