diff --git a/src/Core/ZB.MOM.WW.OtOpcUa.Commons/Browsing/BrowseNode.cs b/src/Core/ZB.MOM.WW.OtOpcUa.Commons/Browsing/BrowseNode.cs new file mode 100644 index 00000000..33dbacac --- /dev/null +++ b/src/Core/ZB.MOM.WW.OtOpcUa.Commons/Browsing/BrowseNode.cs @@ -0,0 +1,32 @@ +namespace ZB.MOM.WW.OtOpcUa.Commons.Browsing; + +/// One node in a driver-agnostic browse tree. +/// Stable identifier passed back to the picker on commit. For OPC UA +/// this is the nsu=...;... form; for Galaxy this is the tag_name. +/// Label shown in the tree. +/// Whether this node terminates the address (Leaf) or has children +/// (Folder). Galaxy never returns Leaves; only the attribute side-panel terminates. +/// When true, the UI renders an expand affordance before +/// the children have been fetched. +public sealed record BrowseNode( + string NodeId, + string DisplayName, + BrowseNodeKind Kind, + bool HasChildrenHint); + +/// Discriminates terminal vs. expandable nodes for UI rendering. +public enum BrowseNodeKind +{ + /// Expandable — has (or may have) children. UI shows expand affordance. + Folder, + /// Terminal — commit on select. + Leaf, +} + +/// Metadata for an attribute of a Galaxy object (or the equivalent +/// per-driver concept). Surfaced in the picker's attribute side-panel. +public sealed record AttributeInfo( + string Name, + string DriverDataType, + bool IsArray, + string SecurityClass); diff --git a/src/Core/ZB.MOM.WW.OtOpcUa.Commons/Browsing/IBrowseSession.cs b/src/Core/ZB.MOM.WW.OtOpcUa.Commons/Browsing/IBrowseSession.cs new file mode 100644 index 00000000..a470b7e2 --- /dev/null +++ b/src/Core/ZB.MOM.WW.OtOpcUa.Commons/Browsing/IBrowseSession.cs @@ -0,0 +1,29 @@ +namespace ZB.MOM.WW.OtOpcUa.Commons.Browsing; + +/// +/// A live, one-level-at-a-time browse over a remote address space. Owned by the +/// AdminUI BrowseSessionRegistry; disposed by the registry's TTL reaper or +/// the picker body on close. +/// +public interface IBrowseSession : IAsyncDisposable +{ + /// Opaque token identifying this session in the registry. + Guid Token { get; } + + /// Wall-clock time of the most recent successful call. Refreshed on + /// , , and + /// ; used by the reaper for idle eviction. + DateTime LastUsedUtc { get; } + + /// Returns the top-level browse nodes. + Task> RootAsync(CancellationToken cancellationToken); + + /// Returns the direct children of the node identified by + /// . + Task> ExpandAsync(string nodeId, CancellationToken cancellationToken); + + /// Returns the attributes of the node identified by . + /// Empty for drivers whose tree is uniform (OPC UA Client). Galaxy uses this to populate + /// the attribute side-panel after the user selects an object. + Task> AttributesAsync(string nodeId, CancellationToken cancellationToken); +} diff --git a/src/Core/ZB.MOM.WW.OtOpcUa.Commons/Browsing/IDriverBrowser.cs b/src/Core/ZB.MOM.WW.OtOpcUa.Commons/Browsing/IDriverBrowser.cs new file mode 100644 index 00000000..80f80375 --- /dev/null +++ b/src/Core/ZB.MOM.WW.OtOpcUa.Commons/Browsing/IDriverBrowser.cs @@ -0,0 +1,19 @@ +namespace ZB.MOM.WW.OtOpcUa.Commons.Browsing; + +/// +/// Per-driver factory that opens an ad-hoc browse session against the configuration +/// supplied as JSON. Parallels IDriverProbe in the runtime — one implementation +/// per driver type, registered in AdminUI DI and indexed by . +/// +public interface IDriverBrowser +{ + /// Driver type key, matching the AdminUI's persisted DriverType string + /// (e.g. "OpcUaClient", "Galaxy"). + string DriverType { get; } + + /// Opens a browse session against the supplied configuration. + /// Driver options serialized as JSON; same shape the runtime + /// driver would consume. + /// Cancellation for the connect phase only. + Task OpenAsync(string configJson, CancellationToken cancellationToken); +}