diff --git a/src/ZB.MOM.WW.ScadaBridge.Commons/Messages/Management/BrowseCommands.cs b/src/ZB.MOM.WW.ScadaBridge.Commons/Messages/Management/BrowseCommands.cs new file mode 100644 index 00000000..fbc58205 --- /dev/null +++ b/src/ZB.MOM.WW.ScadaBridge.Commons/Messages/Management/BrowseCommands.cs @@ -0,0 +1,31 @@ +using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Protocol; + +namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.Management; + +/// +/// Sent from CentralUI to a specific site to enumerate the immediate children +/// of an OPC UA node on the live server backing the given data connection. +/// +/// Id of the site-local data connection to browse against. +/// Node to browse, or null to browse from the server root (ObjectsFolder). +public record BrowseOpcUaNodeCommand( + int DataConnectionId, + string? ParentNodeId); + +public record BrowseOpcUaNodeResult( + IReadOnlyList Children, + bool Truncated, + BrowseFailure? Failure); + +public record BrowseFailure( + BrowseFailureKind Kind, + string Message); + +public enum BrowseFailureKind +{ + ConnectionNotFound, + ConnectionNotConnected, + NotBrowsable, + Timeout, + ServerError +} diff --git a/tests/ZB.MOM.WW.ScadaBridge.Commons.Tests/Messages/BrowseCommandsRegistryTests.cs b/tests/ZB.MOM.WW.ScadaBridge.Commons.Tests/Messages/BrowseCommandsRegistryTests.cs new file mode 100644 index 00000000..a2042bd3 --- /dev/null +++ b/tests/ZB.MOM.WW.ScadaBridge.Commons.Tests/Messages/BrowseCommandsRegistryTests.cs @@ -0,0 +1,23 @@ +using ZB.MOM.WW.ScadaBridge.Commons.Messages.Management; + +namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Messages; + +/// +/// Verifies that is discovered by +/// so it travels over the management +/// boundary as a known command (resolvable by wire name and round-trippable +/// through GetCommandName / Resolve). +/// +public class BrowseCommandsRegistryTests +{ + [Fact] + public void Registry_discovers_BrowseOpcUaNodeCommand() + { + // GetCommandName throws ArgumentException for any type the registry + // does not contain, so a successful call here is proof of discovery. + var name = ManagementCommandRegistry.GetCommandName(typeof(BrowseOpcUaNodeCommand)); + + Assert.Equal("BrowseOpcUaNode", name); + Assert.Equal(typeof(BrowseOpcUaNodeCommand), ManagementCommandRegistry.Resolve(name)); + } +}