refactor(driver-twincat): extract TwinCATDriverOptions to .Contracts
Move TwinCATDriverOptions and TwinCATDataType enum to a new Driver.TwinCAT.Contracts sibling project. TwinCATDataTypeExtensions (which uses DriverDataType from Core.Abstractions) stays in the runtime driver as TwinCATDataTypeExtensions.cs. Replace two doc-comment references: <see cref="Core.Abstractions.PollGroupEngine"/> → <c>PollGroupEngine</c> <see cref="TwinCATAmsAddress.TryParse"/> → <c>TwinCATAmsAddress.TryParse</c> per the approved decision — no compilable usings were present. The runtime Driver.TwinCAT project gains a ProjectReference to .Contracts; the .slnx is updated accordingly.
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
<Project Path="src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.csproj" />
|
||||
<Project Path="src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts.csproj" />
|
||||
<Project Path="src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.csproj" />
|
||||
<Project Path="src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Contracts/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Contracts.csproj" />
|
||||
<Project Path="src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.csproj" />
|
||||
<Project Path="src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.csproj" />
|
||||
</Folder>
|
||||
|
||||
-29
@@ -1,5 +1,3 @@
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Driver.TwinCAT;
|
||||
|
||||
/// <summary>
|
||||
@@ -34,30 +32,3 @@ public enum TwinCATDataType
|
||||
/// <summary>UDT / FB instance. Resolved per member at discovery time.</summary>
|
||||
Structure,
|
||||
}
|
||||
|
||||
/// <summary>Extension methods for TwinCATDataType.</summary>
|
||||
public static class TwinCATDataTypeExtensions
|
||||
{
|
||||
/// <summary>Maps a TwinCAT data type to the equivalent driver data type.</summary>
|
||||
/// <param name="t">The TwinCAT data type to convert.</param>
|
||||
/// <returns>The corresponding driver data type.</returns>
|
||||
public static DriverDataType ToDriverDataType(this TwinCATDataType t) => t switch
|
||||
{
|
||||
TwinCATDataType.Bool => DriverDataType.Boolean,
|
||||
TwinCATDataType.SInt => DriverDataType.Int16, // signed 8-bit — no narrower OPC UA atom
|
||||
TwinCATDataType.USInt => DriverDataType.UInt16, // unsigned 8-bit — no narrower OPC UA atom
|
||||
TwinCATDataType.Int => DriverDataType.Int16,
|
||||
TwinCATDataType.UInt => DriverDataType.UInt16,
|
||||
TwinCATDataType.DInt => DriverDataType.Int32,
|
||||
TwinCATDataType.UDInt => DriverDataType.UInt32,
|
||||
TwinCATDataType.LInt => DriverDataType.Int64,
|
||||
TwinCATDataType.ULInt => DriverDataType.UInt64,
|
||||
TwinCATDataType.Real => DriverDataType.Float32,
|
||||
TwinCATDataType.LReal => DriverDataType.Float64,
|
||||
TwinCATDataType.String or TwinCATDataType.WString => DriverDataType.String,
|
||||
TwinCATDataType.Time or TwinCATDataType.Date
|
||||
or TwinCATDataType.DateTime or TwinCATDataType.TimeOfDay => DriverDataType.UInt32,
|
||||
TwinCATDataType.Structure => DriverDataType.String,
|
||||
_ => DriverDataType.Int32,
|
||||
};
|
||||
}
|
||||
+2
-2
@@ -22,7 +22,7 @@ public sealed class TwinCATDriverOptions
|
||||
/// rather than the driver polling. Strictly better for latency + CPU when the target
|
||||
/// supports it (TC2 + TC3 PLC runtimes always do; some soft-PLC / third-party ADS
|
||||
/// implementations may not). When <c>false</c>, the driver falls through to the shared
|
||||
/// <see cref="Core.Abstractions.PollGroupEngine"/> — same semantics as the other
|
||||
/// <c>PollGroupEngine</c> — same semantics as the other
|
||||
/// libplctag-backed drivers. Set <c>false</c> for deployments where the AMS router has
|
||||
/// notification limits you can't raise.
|
||||
/// </summary>
|
||||
@@ -50,7 +50,7 @@ public sealed class TwinCATDriverOptions
|
||||
|
||||
/// <summary>
|
||||
/// One TwinCAT target. <paramref name="HostAddress"/> must parse via
|
||||
/// <see cref="TwinCATAmsAddress.TryParse"/>; misconfigured devices fail driver initialisation.
|
||||
/// <c>TwinCATAmsAddress.TryParse</c>; misconfigured devices fail driver initialisation.
|
||||
/// </summary>
|
||||
public sealed record TwinCATDeviceOptions(
|
||||
string HostAddress,
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<!-- NO PackageReference. -->
|
||||
</Project>
|
||||
@@ -0,0 +1,30 @@
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Driver.TwinCAT;
|
||||
|
||||
/// <summary>Extension methods for TwinCATDataType.</summary>
|
||||
public static class TwinCATDataTypeExtensions
|
||||
{
|
||||
/// <summary>Maps a TwinCAT data type to the equivalent driver data type.</summary>
|
||||
/// <param name="t">The TwinCAT data type to convert.</param>
|
||||
/// <returns>The corresponding driver data type.</returns>
|
||||
public static DriverDataType ToDriverDataType(this TwinCATDataType t) => t switch
|
||||
{
|
||||
TwinCATDataType.Bool => DriverDataType.Boolean,
|
||||
TwinCATDataType.SInt => DriverDataType.Int16, // signed 8-bit — no narrower OPC UA atom
|
||||
TwinCATDataType.USInt => DriverDataType.UInt16, // unsigned 8-bit — no narrower OPC UA atom
|
||||
TwinCATDataType.Int => DriverDataType.Int16,
|
||||
TwinCATDataType.UInt => DriverDataType.UInt16,
|
||||
TwinCATDataType.DInt => DriverDataType.Int32,
|
||||
TwinCATDataType.UDInt => DriverDataType.UInt32,
|
||||
TwinCATDataType.LInt => DriverDataType.Int64,
|
||||
TwinCATDataType.ULInt => DriverDataType.UInt64,
|
||||
TwinCATDataType.Real => DriverDataType.Float32,
|
||||
TwinCATDataType.LReal => DriverDataType.Float64,
|
||||
TwinCATDataType.String or TwinCATDataType.WString => DriverDataType.String,
|
||||
TwinCATDataType.Time or TwinCATDataType.Date
|
||||
or TwinCATDataType.DateTime or TwinCATDataType.TimeOfDay => DriverDataType.UInt32,
|
||||
TwinCATDataType.Structure => DriverDataType.String,
|
||||
_ => DriverDataType.Int32,
|
||||
};
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Contracts\ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Contracts.csproj"/>
|
||||
<ProjectReference Include="..\..\Core\ZB.MOM.WW.OtOpcUa.Core.Abstractions\ZB.MOM.WW.OtOpcUa.Core.Abstractions.csproj"/>
|
||||
<ProjectReference Include="..\..\Core\ZB.MOM.WW.OtOpcUa.Core\ZB.MOM.WW.OtOpcUa.Core.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user