feat(dcl): register MxGateway protocol in factory + config flatten + options

DataConnectionFactory registers 'MxGateway' -> MxGatewayDataConnection over the
real client; AddDataConnectionLayer binds MxGatewayGlobalOptions; DeploymentManager
FlattenConnectionConfig gains an MxGateway arm using the typed serializer. Factory
test confirms Create("MxGateway") returns the adapter.
This commit is contained in:
Joseph Doherty
2026-05-29 07:58:51 -04:00
parent 9b7916bb2e
commit 5461e4968e
4 changed files with 26 additions and 0 deletions
@@ -38,6 +38,13 @@ public class DataConnectionFactory : IDataConnectionFactory
RegisterAdapter("OpcUa", details => new OpcUaDataConnection(
new RealOpcUaClientFactory(globalOptions, _loggerFactory),
_loggerFactory.CreateLogger<OpcUaDataConnection>()));
// MxGateway: gRPC to the MxAccess Gateway. The RealMxGatewayClient wraps the
// ZB.MOM.WW.MxGateway.Client package; per-connection config arrives via the
// flat details dict (see MxGatewayEndpointConfigSerializer).
RegisterAdapter("MxGateway", details => new MxGatewayDataConnection(
new RealMxGatewayClientFactory(_loggerFactory),
_loggerFactory.CreateLogger<MxGatewayDataConnection>()));
}
/// <summary>
@@ -18,6 +18,9 @@ public static class ServiceCollectionExtensions
services.AddOptions<OpcUaGlobalOptions>()
.BindConfiguration("OpcUa");
services.AddOptions<MxGatewayGlobalOptions>()
.BindConfiguration("MxGateway");
// WP-34: Register the factory for protocol extensibility
services.AddSingleton<IDataConnectionFactory, DataConnectionFactory>();
@@ -767,6 +767,12 @@ public class DeploymentManagerActor : ReceiveActor, IWithTimers
return Commons.Serialization.OpcUaEndpointConfigSerializer.ToFlatDict(config);
}
if (string.Equals(protocol, "MxGateway", StringComparison.OrdinalIgnoreCase))
{
var config = Commons.Serialization.MxGatewayEndpointConfigSerializer.Deserialize(json);
return Commons.Serialization.MxGatewayEndpointConfigSerializer.ToFlatDict(config);
}
// Fallback: assume legacy flat-dict shape for any future / unknown protocol.
try
{
@@ -18,6 +18,16 @@ public class DataConnectionFactoryTests
Assert.IsType<OpcUaDataConnection>(connection);
}
[Fact]
public void Create_MxGateway_ReturnsMxGatewayAdapter()
{
var factory = new DataConnectionFactory(NullLoggerFactory.Instance);
var connection = factory.Create("MxGateway", new Dictionary<string, string>());
Assert.IsType<MxGatewayDataConnection>(connection);
}
[Fact]
public void Create_CaseInsensitive()
{