diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/DataConnections/DataConnectionDiagnostics.cs b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/DataConnections/DataConnectionDiagnostics.cs
index 9badce08a..b56ff0092 100644
--- a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/DataConnections/DataConnectionDiagnostics.cs
+++ b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/DataConnections/DataConnectionDiagnostics.cs
@@ -26,17 +26,23 @@ public static class DataConnectionDiagnostics
"auth-failed" => "Authentication failed", "backoff" => "Backoff", _ => "Unavailable"
};
/// H4: the features the last handshake negotiated; "none (v1)" when the peer negotiated nothing optional.
+ /// Every set bit is shown — a name when this AdminUI knows it, hex otherwise (H4 review: never hidden by a known one).
public static string Features(DataFeatures? features) => features switch
{
null => "unavailable",
DataFeatures.None => "none (v1 behaviour)",
- { } f => string.Join(", ", Enum.GetValues().Where(x => x != DataFeatures.None && f.HasFlag(x)).Select(x => x.ToString())
- .DefaultIfEmpty($"0x{(int)f:X}")),
+ { } f => Bits((uint)(int)f, bit => Enum.IsDefined((DataFeatures)(int)bit) ? ((DataFeatures)(int)bit).ToString() : null),
};
+ /// Each set bit of across all 32, low to high: its name, or hex when unnamed.
+ private static string Bits(uint value, Func name) =>
+ string.Join(", ", Enumerable.Range(0, 32).Select(i => 1u << i).Where(bit => (value & bit) != 0)
+ .Select(bit => name(bit) ?? $"0x{bit:X}"));
+
/// H4: the history variants and aggregate count the origin advertised to this caller.
public static string HistoryServed(DataConnectionDiagnosticsSnapshot row) =>
- row.HistoryVariants is not { } variants ? "not advertised"
+ row.NegotiatedFeatures is null && row.HistoryVariants is null ? "unavailable"
+ : row.HistoryVariants is not { } variants ? "not advertised"
: variants.Count == 0 ? "advertised, no variant granted"
: string.Join(", ", variants) + (row.HistoryAggregateCount is { } n ? $" ({n} aggregates)" : "");
@@ -53,8 +59,7 @@ public static class DataConnectionDiagnostics
{
null => "unavailable",
DataOperations.None => "none",
- { } b => string.Join(", ", Enumerable.Range(0, 31).Select(i => (DataOperations)(1 << i)).Where(x => b.HasFlag(x))
- .Select(x => Enum.IsDefined(x) ? DataOperationAuthoring.Label(x) : $"0x{(int)x:X}")),
+ { } b => Bits((uint)(int)b, bit => Enum.IsDefined((DataOperations)(int)bit) ? DataOperationAuthoring.Label((DataOperations)(int)bit) : null),
};
/// #919: true when the drop deserves the "node build is older than the authored feature" hint.
diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/DataConnections/GrpcDataHistoryDiagnosticsDisplayTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/DataConnections/GrpcDataHistoryDiagnosticsDisplayTests.cs
index 61d92a9f7..51e032b48 100644
--- a/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/DataConnections/GrpcDataHistoryDiagnosticsDisplayTests.cs
+++ b/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/DataConnections/GrpcDataHistoryDiagnosticsDisplayTests.cs
@@ -20,13 +20,17 @@ public sealed class GrpcDataHistoryDiagnosticsDisplayTests
DataConnectionDiagnostics.Features(DataFeatures.None).ShouldBe("none (v1 behaviour)");
DataConnectionDiagnostics.Features(DataFeatures.History).ShouldBe("History");
DataConnectionDiagnostics.Features(DataFeatures.History | DataFeatures.Conditions).ShouldBe("History, Conditions");
+ // H4 review 6: an unknown bit is never hidden by a known one.
+ DataConnectionDiagnostics.Features(DataFeatures.History | (DataFeatures)8).ShouldBe("History, 0x8");
+ DataConnectionDiagnostics.Features((DataFeatures)int.MinValue).ShouldBe("0x80000000");
}
[Fact]
public void Origin_history_shows_the_advertised_variants_and_aggregate_count()
{
- DataConnectionDiagnostics.HistoryServed(Row()).ShouldBe("not advertised");
- DataConnectionDiagnostics.HistoryServed(Row() with { HistoryVariants = [] }).ShouldBe("advertised, no variant granted");
+ DataConnectionDiagnostics.HistoryServed(Row()).ShouldBe("unavailable", "no handshake evidence at all (H4 review 5)");
+ DataConnectionDiagnostics.HistoryServed(Row() with { NegotiatedFeatures = DataFeatures.None }).ShouldBe("not advertised");
+ DataConnectionDiagnostics.HistoryServed(Row() with { NegotiatedFeatures = DataFeatures.History, HistoryVariants = [] }).ShouldBe("advertised, no variant granted");
DataConnectionDiagnostics.HistoryServed(Row() with { HistoryVariants = ["raw", "processed", "attime"], HistoryAggregateCount = 12 })
.ShouldBe("raw, processed, attime (12 aggregates)");
}
@@ -45,6 +49,8 @@ public sealed class GrpcDataHistoryDiagnosticsDisplayTests
DataConnectionDiagnostics.DroppedBits(DataOperations.None).ShouldBe("none");
DataConnectionDiagnostics.DroppedBits(DataOperations.HistoryRead | DataOperations.AlarmSubscribe).ShouldBe("HistoryRead, AlarmSubscribe");
DataConnectionDiagnostics.DroppedBits((DataOperations)(1 << 20)).ShouldBe("0x100000");
+ // H4 review 6: the full width, bit 31 included, beside a known bit.
+ DataConnectionDiagnostics.DroppedBits(DataOperations.HistoryRead | (DataOperations)int.MinValue).ShouldBe("HistoryRead, 0x80000000");
}
[Fact]