From ee03a5180a46661bcb8d28c1dbcac1b32442f823 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Dec 2025 14:55:10 +0000 Subject: [PATCH 1/5] Bump Beckhoff.TwinCAT.Ads and 3 others Bumps Beckhoff.TwinCAT.Ads from 6.1.203 to 7.0.123 Bumps Beckhoff.TwinCAT.Ads.Reactive from 6.1.203 to 7.0.123 Bumps Beckhoff.TwinCAT.Ads.TcpRouter from 6.1.203 to 7.0.123 Bumps Microsoft.Extensions.Logging.Abstractions from 8.0.2 to 8.0.3 --- updated-dependencies: - dependency-name: Beckhoff.TwinCAT.Ads dependency-version: 7.0.123 dependency-type: direct:production update-type: version-update:semver-major dependency-group: beckhoff - dependency-name: Microsoft.Extensions.Logging.Abstractions dependency-version: 8.0.3 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: beckhoff - dependency-name: Beckhoff.TwinCAT.Ads.Reactive dependency-version: 7.0.123 dependency-type: direct:production update-type: version-update:semver-major dependency-group: beckhoff - dependency-name: Beckhoff.TwinCAT.Ads.TcpRouter dependency-version: 7.0.123 dependency-type: direct:production update-type: version-update:semver-major dependency-group: beckhoff ... Signed-off-by: dependabot[bot] --- src/PlcInterface.Ads/PlcInterface.Ads.csproj | 6 +++--- src/PlcInterface.Sandbox/PlcInterface.Sandbox.csproj | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PlcInterface.Ads/PlcInterface.Ads.csproj b/src/PlcInterface.Ads/PlcInterface.Ads.csproj index 9b0f1c5..b94278f 100644 --- a/src/PlcInterface.Ads/PlcInterface.Ads.csproj +++ b/src/PlcInterface.Ads/PlcInterface.Ads.csproj @@ -18,9 +18,9 @@ - - - + + + diff --git a/src/PlcInterface.Sandbox/PlcInterface.Sandbox.csproj b/src/PlcInterface.Sandbox/PlcInterface.Sandbox.csproj index 0498caa..e5e8c98 100644 --- a/src/PlcInterface.Sandbox/PlcInterface.Sandbox.csproj +++ b/src/PlcInterface.Sandbox/PlcInterface.Sandbox.csproj @@ -13,7 +13,7 @@ - + From e32e6d699734e8702c078000f1d249521daff48d Mon Sep 17 00:00:00 2001 From: Vectron Date: Mon, 15 Dec 2025 16:21:29 +0100 Subject: [PATCH 2/5] Fix MA0042: Use 'DisconnectAsync' instead of 'Disconnect' --- src/PlcInterface.Ads/PlcConnection.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/PlcInterface.Ads/PlcConnection.cs b/src/PlcInterface.Ads/PlcConnection.cs index 174a6f9..feab666 100644 --- a/src/PlcInterface.Ads/PlcConnection.cs +++ b/src/PlcInterface.Ads/PlcConnection.cs @@ -71,12 +71,12 @@ public void Disconnect() => DisconnectAsync().GetAwaiter().GetResult(); /// - public Task DisconnectAsync() - => Task.Run(() => - { - _ = adsDisposableConnection.Disconnect(); - adsDisposableConnection.ConnectionStateChanged -= AdsDisposableConnection_ConnectionStateChanged; - }); + public async Task DisconnectAsync() + { + using var timeoutCts = new CancellationTokenSource(TimeSpan.FromSeconds(2)); + _ = await adsDisposableConnection.DisconnectAsync(timeoutCts.Token).ConfigureAwait(false); + adsDisposableConnection.ConnectionStateChanged -= AdsDisposableConnection_ConnectionStateChanged; + } /// public void Dispose() From e2974f1617a834fcbb56c285b15b2c246c52d0af Mon Sep 17 00:00:00 2001 From: Vectron Date: Mon, 15 Dec 2025 16:23:19 +0100 Subject: [PATCH 3/5] Add SumFallbackmode to sum writer and reader construction --- .../TwincatAbstractions/SumSymbolReadAbstraction.cs | 2 +- .../TwincatAbstractions/SumSymbolWriteAbstraction.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PlcInterface.Ads/TwincatAbstractions/SumSymbolReadAbstraction.cs b/src/PlcInterface.Ads/TwincatAbstractions/SumSymbolReadAbstraction.cs index 531c14e..bc818e4 100644 --- a/src/PlcInterface.Ads/TwincatAbstractions/SumSymbolReadAbstraction.cs +++ b/src/PlcInterface.Ads/TwincatAbstractions/SumSymbolReadAbstraction.cs @@ -10,7 +10,7 @@ namespace PlcInterface.Ads.TwinCATAbstractions; /// internal sealed class SumSymbolReadAbstraction(IAdsConnection connection, IList symbols) : ISumSymbolRead { - private readonly SumSymbolRead backend = new(connection, symbols); + private readonly SumSymbolRead backend = new(connection, symbols, SumFallbackMode.All); /// public object[] Read() diff --git a/src/PlcInterface.Ads/TwincatAbstractions/SumSymbolWriteAbstraction.cs b/src/PlcInterface.Ads/TwincatAbstractions/SumSymbolWriteAbstraction.cs index 1002c58..adf9944 100644 --- a/src/PlcInterface.Ads/TwincatAbstractions/SumSymbolWriteAbstraction.cs +++ b/src/PlcInterface.Ads/TwincatAbstractions/SumSymbolWriteAbstraction.cs @@ -10,7 +10,7 @@ namespace PlcInterface.Ads.TwinCATAbstractions; /// internal sealed class SumSymbolWriteAbstraction(IAdsConnection connection, IList symbols) : ISumSymbolWrite { - private readonly SumSymbolWrite backend = new(connection, symbols); + private readonly SumSymbolWrite backend = new(connection, symbols, SumFallbackMode.All); /// public void Write(object[] values) From dec92d8ccbd191ead783ba60b2bda6453be4c296 Mon Sep 17 00:00:00 2001 From: Vectron Date: Mon, 15 Dec 2025 16:26:11 +0100 Subject: [PATCH 4/5] Fix DI setup --- src/PlcInterface.Ads/IServiceCollectionExtension.cs | 3 +-- src/PlcInterface.Sandbox/Program.cs | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/PlcInterface.Ads/IServiceCollectionExtension.cs b/src/PlcInterface.Ads/IServiceCollectionExtension.cs index ab540f7..d9bed9b 100644 --- a/src/PlcInterface.Ads/IServiceCollectionExtension.cs +++ b/src/PlcInterface.Ads/IServiceCollectionExtension.cs @@ -1,6 +1,5 @@ using System.IO.Abstractions; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using PlcInterface.Ads.TwinCATAbstractions; namespace PlcInterface.Ads; @@ -25,7 +24,7 @@ public static IServiceCollection AddAdsPLC(this IServiceCollection serviceDescri .AddSingletonFactory, IAdsPlcConnection>() .AddSingleton(x => x.GetRequiredService()) .AddTransient() - .AddSingleton(x => new TwinCAT.Ads.AdsClient(x.GetRequiredService>())) + .AddSingleton() .AddSingleton() .AddSingleton() .AddSingleton() diff --git a/src/PlcInterface.Sandbox/Program.cs b/src/PlcInterface.Sandbox/Program.cs index 182a29e..29e458d 100644 --- a/src/PlcInterface.Sandbox/Program.cs +++ b/src/PlcInterface.Sandbox/Program.cs @@ -1,7 +1,5 @@ -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; using PlcInterface.Ads; using PlcInterface.OpcUa; using PlcInterface.Sandbox.PLCCommands; @@ -58,7 +56,7 @@ private static async Task Main(string[] args) _ = builder.Services .AddAdsPLC() - .AddSingleton(x => new AmsTcpIpRouter(x.GetRequiredService>(), x.GetRequiredService())) + .AddSingleton() .AddOptions() .BindConfiguration(AdsConnectionSettingsSection) .Services From b2ea7a4a442ca3f20d54495a50485b003be1dc10 Mon Sep 17 00:00:00 2001 From: Vectron Date: Mon, 15 Dec 2025 16:35:11 +0100 Subject: [PATCH 5/5] Fix tests after disconnect changes --- test/PlcInterface.Ads.Tests/PlcConnectionTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/PlcInterface.Ads.Tests/PlcConnectionTests.cs b/test/PlcInterface.Ads.Tests/PlcConnectionTests.cs index 5f0de2f..6fd286c 100644 --- a/test/PlcInterface.Ads.Tests/PlcConnectionTests.cs +++ b/test/PlcInterface.Ads.Tests/PlcConnectionTests.cs @@ -141,7 +141,7 @@ public void DisconnectCallsDisconnectOnClient() connection.Disconnect(); // Assert - adsClientMock.Verify(x => x.Disconnect(), Times.Once); + adsClientMock.Verify(x => x.DisconnectAsync(It.IsAny()), Times.Once); } [TestMethod] @@ -161,7 +161,7 @@ public async Task DisconnectCallsDisconnectOnClientAsync() await connection.DisconnectAsync(); // Assert - adsClientMock.Verify(x => x.Disconnect(), Times.Once); + adsClientMock.Verify(x => x.DisconnectAsync(It.IsAny()), Times.Once); } [TestMethod]