feat(commons): add BrowseOpcUaNodeCommand + result + failure types
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Protocol;
|
||||||
|
|
||||||
|
namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.Management;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="DataConnectionId">Id of the site-local data connection to browse against.</param>
|
||||||
|
/// <param name="ParentNodeId">Node to browse, or null to browse from the server root (ObjectsFolder).</param>
|
||||||
|
public record BrowseOpcUaNodeCommand(
|
||||||
|
int DataConnectionId,
|
||||||
|
string? ParentNodeId);
|
||||||
|
|
||||||
|
public record BrowseOpcUaNodeResult(
|
||||||
|
IReadOnlyList<BrowseNode> Children,
|
||||||
|
bool Truncated,
|
||||||
|
BrowseFailure? Failure);
|
||||||
|
|
||||||
|
public record BrowseFailure(
|
||||||
|
BrowseFailureKind Kind,
|
||||||
|
string Message);
|
||||||
|
|
||||||
|
public enum BrowseFailureKind
|
||||||
|
{
|
||||||
|
ConnectionNotFound,
|
||||||
|
ConnectionNotConnected,
|
||||||
|
NotBrowsable,
|
||||||
|
Timeout,
|
||||||
|
ServerError
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Management;
|
||||||
|
|
||||||
|
namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Messages;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Verifies that <see cref="BrowseOpcUaNodeCommand"/> is discovered by
|
||||||
|
/// <see cref="ManagementCommandRegistry"/> so it travels over the management
|
||||||
|
/// boundary as a known command (resolvable by wire name and round-trippable
|
||||||
|
/// through <c>GetCommandName</c> / <c>Resolve</c>).
|
||||||
|
/// </summary>
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user