From 615ab256802966e23aa818dbdfe7112c27238715 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sat, 25 Apr 2026 17:04:43 -0400 Subject: [PATCH] =?UTF-8?q?Auto:=20twincat-1.1=20=E2=80=94=20Int64=20fidel?= =?UTF-8?q?ity=20for=20LINT/ULINT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Map LInt/ULInt to DriverDataType.Int64/UInt64 instead of truncating to Int32. AdsTwinCATClient.MapToClrType already returns long/ulong so the wire-level read returns the correct boxed types. Closes #305 --- src/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT/TwinCATDataType.cs | 3 ++- .../TwinCATDriverTests.cs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT/TwinCATDataType.cs b/src/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT/TwinCATDataType.cs index a11fc56..d123451 100644 --- a/src/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT/TwinCATDataType.cs +++ b/src/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT/TwinCATDataType.cs @@ -37,7 +37,8 @@ public static class TwinCATDataTypeExtensions TwinCATDataType.SInt or TwinCATDataType.USInt or TwinCATDataType.Int or TwinCATDataType.UInt or TwinCATDataType.DInt or TwinCATDataType.UDInt => DriverDataType.Int32, - TwinCATDataType.LInt or TwinCATDataType.ULInt => DriverDataType.Int32, // matches Int64 gap + TwinCATDataType.LInt => DriverDataType.Int64, + TwinCATDataType.ULInt => DriverDataType.UInt64, TwinCATDataType.Real => DriverDataType.Float32, TwinCATDataType.LReal => DriverDataType.Float64, TwinCATDataType.String or TwinCATDataType.WString => DriverDataType.String, diff --git a/tests/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Tests/TwinCATDriverTests.cs b/tests/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Tests/TwinCATDriverTests.cs index 0b264fc..caa97d1 100644 --- a/tests/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Tests/TwinCATDriverTests.cs +++ b/tests/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Tests/TwinCATDriverTests.cs @@ -83,6 +83,8 @@ public sealed class TwinCATDriverTests { TwinCATDataType.Bool.ToDriverDataType().ShouldBe(DriverDataType.Boolean); TwinCATDataType.DInt.ToDriverDataType().ShouldBe(DriverDataType.Int32); + TwinCATDataType.LInt.ToDriverDataType().ShouldBe(DriverDataType.Int64); + TwinCATDataType.ULInt.ToDriverDataType().ShouldBe(DriverDataType.UInt64); TwinCATDataType.Real.ToDriverDataType().ShouldBe(DriverDataType.Float32); TwinCATDataType.LReal.ToDriverDataType().ShouldBe(DriverDataType.Float64); TwinCATDataType.String.ToDriverDataType().ShouldBe(DriverDataType.String);