feat(dcl): surface MxGateway attribute DataType through browse seam

This commit is contained in:
Joseph Doherty
2026-06-27 13:24:25 -04:00
parent 5076f0a277
commit ce4d5f0639
4 changed files with 22 additions and 3 deletions
@@ -18,7 +18,7 @@ public record MxReadOutcome(string TagPath, bool Success, object? Value, Quality
public record MxWriteOutcome(string TagPath, bool Success, string? Error); public record MxWriteOutcome(string TagPath, bool Success, string? Error);
/// <summary>One node in a Galaxy browse level.</summary> /// <summary>One node in a Galaxy browse level.</summary>
public record MxBrowseChild(string NodeId, string DisplayName, BrowseNodeClass NodeClass, bool HasChildren); public record MxBrowseChild(string NodeId, string DisplayName, BrowseNodeClass NodeClass, bool HasChildren, string? DataType = null);
/// <summary> /// <summary>
/// Seam over the MxAccess Gateway .NET client + Galaxy repository client. Decouples /// Seam over the MxAccess Gateway .NET client + Galaxy repository client. Decouples
@@ -267,7 +267,7 @@ public class MxGatewayDataConnection : IDataConnection, IBrowsableDataConnection
// and no continuation is ever surfaced (ContinuationToken stays null). // and no continuation is ever surfaced (ContinuationToken stays null).
var (children, truncated) = await _client.BrowseChildrenAsync(parentNodeId, cancellationToken); var (children, truncated) = await _client.BrowseChildrenAsync(parentNodeId, cancellationToken);
var nodes = children var nodes = children
.Select(c => new BrowseNode(c.NodeId, c.DisplayName, c.NodeClass, c.HasChildren)) .Select(c => new BrowseNode(c.NodeId, c.DisplayName, c.NodeClass, c.HasChildren, DataType: c.DataType))
.ToList(); .ToList();
return new BrowseChildrenResult(nodes, truncated); return new BrowseChildrenResult(nodes, truncated);
} }
@@ -266,7 +266,8 @@ public sealed class RealMxGatewayClient : IMxGatewayClient
attr.FullTagReference, attr.FullTagReference,
attr.AttributeName, attr.AttributeName,
BrowseNodeClass.Variable, BrowseNodeClass.Variable,
false)); false,
string.IsNullOrEmpty(attr.DataTypeName) ? null : attr.DataTypeName));
} }
} }
@@ -245,6 +245,24 @@ public class MxGatewayDataConnectionTests
Assert.Equal(BrowseNodeClass.Variable, result.Children[1].NodeClass); Assert.Equal(BrowseNodeClass.Variable, result.Children[1].NodeClass);
} }
[Fact]
public async Task BrowseChildrenAsync_surfaces_attribute_datatype()
{
var fake = new FakeMxGatewayClient
{
BrowseHandler = _ => (new List<MxBrowseChild>
{
new("Area1.Pump.Speed", "Speed", BrowseNodeClass.Variable, false, "Double"),
}, false)
};
var adapter = NewAdapter(fake);
await adapter.ConnectAsync(Details());
var result = await adapter.BrowseChildrenAsync(null);
Assert.Equal("Double", result.Children[0].DataType);
}
[Fact] [Fact]
public async Task BrowseChildrenAsync_throws_when_not_connected() public async Task BrowseChildrenAsync_throws_when_not_connected()
{ {