From 5461e4968e2f55d120f138469b6f056a44f4a91b Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Fri, 29 May 2026 07:58:51 -0400 Subject: [PATCH] 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. --- .../DataConnectionFactory.cs | 7 +++++++ .../ServiceCollectionExtensions.cs | 3 +++ .../Actors/DeploymentManagerActor.cs | 6 ++++++ .../DataConnectionFactoryTests.cs | 10 ++++++++++ 4 files changed, 26 insertions(+) diff --git a/src/ZB.MOM.WW.ScadaBridge.DataConnectionLayer/DataConnectionFactory.cs b/src/ZB.MOM.WW.ScadaBridge.DataConnectionLayer/DataConnectionFactory.cs index 11819cd5..9c9d12f4 100644 --- a/src/ZB.MOM.WW.ScadaBridge.DataConnectionLayer/DataConnectionFactory.cs +++ b/src/ZB.MOM.WW.ScadaBridge.DataConnectionLayer/DataConnectionFactory.cs @@ -38,6 +38,13 @@ public class DataConnectionFactory : IDataConnectionFactory RegisterAdapter("OpcUa", details => new OpcUaDataConnection( new RealOpcUaClientFactory(globalOptions, _loggerFactory), _loggerFactory.CreateLogger())); + + // 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())); } /// diff --git a/src/ZB.MOM.WW.ScadaBridge.DataConnectionLayer/ServiceCollectionExtensions.cs b/src/ZB.MOM.WW.ScadaBridge.DataConnectionLayer/ServiceCollectionExtensions.cs index dbb169bb..42cf2e6c 100644 --- a/src/ZB.MOM.WW.ScadaBridge.DataConnectionLayer/ServiceCollectionExtensions.cs +++ b/src/ZB.MOM.WW.ScadaBridge.DataConnectionLayer/ServiceCollectionExtensions.cs @@ -18,6 +18,9 @@ public static class ServiceCollectionExtensions services.AddOptions() .BindConfiguration("OpcUa"); + services.AddOptions() + .BindConfiguration("MxGateway"); + // WP-34: Register the factory for protocol extensibility services.AddSingleton(); diff --git a/src/ZB.MOM.WW.ScadaBridge.SiteRuntime/Actors/DeploymentManagerActor.cs b/src/ZB.MOM.WW.ScadaBridge.SiteRuntime/Actors/DeploymentManagerActor.cs index 4117d929..d53212e4 100644 --- a/src/ZB.MOM.WW.ScadaBridge.SiteRuntime/Actors/DeploymentManagerActor.cs +++ b/src/ZB.MOM.WW.ScadaBridge.SiteRuntime/Actors/DeploymentManagerActor.cs @@ -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 { diff --git a/tests/ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests/DataConnectionFactoryTests.cs b/tests/ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests/DataConnectionFactoryTests.cs index d7a31039..97d31170 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests/DataConnectionFactoryTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests/DataConnectionFactoryTests.cs @@ -18,6 +18,16 @@ public class DataConnectionFactoryTests Assert.IsType(connection); } + [Fact] + public void Create_MxGateway_ReturnsMxGatewayAdapter() + { + var factory = new DataConnectionFactory(NullLoggerFactory.Instance); + + var connection = factory.Create("MxGateway", new Dictionary()); + + Assert.IsType(connection); + } + [Fact] public void Create_CaseInsensitive() {