Files
ScadaBridge/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Deployment/DebugTreeNode.cs
T
Joseph Doherty cc017aabfc feat(debugview): DV-3 DebugTreeNode model + attribute tree builder
Pure path-split composition forest from streamed AttributeValueChanged: branch dedupe by accumulated prefix, ordinal child sort, post-order bad-quality roll-up, case-insensitive name-contains filter (keeps ancestors). BuildAlarmTree left as a NotImplementedException stub for DV-4. 16 unit tests cover structure + roll-up + filter.
2026-06-17 15:01:02 -04:00

36 lines
1.5 KiB
C#

using ZB.MOM.WW.ScadaBridge.Commons.Messages.Streaming;
using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums; // AlarmState
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Components.Pages.Deployment;
/// <summary>
/// A node in a Debug View composition tree. Attribute (and, in DV-4, alarm)
/// names are path-qualified canonical names (e.g. <c>Motor1.Compressor.Pump</c>);
/// the tree is derived by splitting those names on <c>'.'</c>. A node is either a
/// branch (composition member, no payload, has children) or a leaf (one attribute
/// or one alarm). Consumed by the generic <c>TreeView&lt;TItem&gt;</c> component.
/// </summary>
public sealed class DebugTreeNode
{
/// <summary>Full canonical path — stable TreeView key.</summary>
public required string Key { get; init; }
/// <summary>Display label (the last path segment).</summary>
public required string Segment { get; init; }
public List<DebugTreeNode> Children { get; } = new();
// Leaf payloads — exactly one is set on a leaf; both null on a pure branch.
public AttributeValueChanged? Attribute { get; init; }
public AlarmStateChanged? Alarm { get; init; } // computed leaf, native condition, or placeholder (DV-4)
public bool IsNativeBinding { get; init; } // branch grouping native conditions (DV-4)
// Roll-up (set by the builder for branch nodes).
public AlarmState WorstState { get; set; } = AlarmState.Normal;
public int ActiveCount { get; set; }
public bool HasBadQuality { get; set; }
public bool HasChildren => Children.Count > 0;
}