@@ -38,7 +38,10 @@ public static class AbLegacyDriverFactoryExtensions
|
||||
$"AB Legacy config for '{driverInstanceId}' has a device missing HostAddress"),
|
||||
PlcFamily: ParseEnum<AbLegacyPlcFamily>(d.PlcFamily, driverInstanceId, "PlcFamily",
|
||||
fallback: AbLegacyPlcFamily.Slc500),
|
||||
DeviceName: d.DeviceName))]
|
||||
DeviceName: d.DeviceName,
|
||||
// PR 9 — per-device timeout / retry overrides. Device-level wins over driver-wide.
|
||||
Timeout: d.TimeoutMs is int devMs ? TimeSpan.FromMilliseconds(devMs) : null,
|
||||
Retries: d.Retries))]
|
||||
: [],
|
||||
Tags = dto.Tags is { Count: > 0 }
|
||||
? [.. dto.Tags.Select(t => new AbLegacyTagDefinition(
|
||||
@@ -64,6 +67,9 @@ public static class AbLegacyDriverFactoryExtensions
|
||||
ProbeAddress = dto.Probe?.ProbeAddress ?? "S:0",
|
||||
},
|
||||
Timeout = TimeSpan.FromMilliseconds(dto.TimeoutMs ?? 2_000),
|
||||
// PR 9 — driver-wide retry default. null ≡ 0 retries (single attempt). Per-device
|
||||
// Retries on AbLegacyDeviceOptions still wins.
|
||||
Retries = dto.Retries,
|
||||
};
|
||||
|
||||
return new AbLegacyDriver(options, driverInstanceId);
|
||||
@@ -95,6 +101,12 @@ public static class AbLegacyDriverFactoryExtensions
|
||||
internal sealed class AbLegacyDriverConfigDto
|
||||
{
|
||||
public int? TimeoutMs { get; init; }
|
||||
/// <summary>
|
||||
/// PR 9 — driver-wide retry count for transient <c>BadCommunicationError</c> reads.
|
||||
/// <c>null</c> ≡ <c>0</c> (single attempt). A per-device override on
|
||||
/// <see cref="AbLegacyDeviceDto.Retries"/> wins.
|
||||
/// </summary>
|
||||
public int? Retries { get; init; }
|
||||
public List<AbLegacyDeviceDto>? Devices { get; init; }
|
||||
public List<AbLegacyTagDto>? Tags { get; init; }
|
||||
public AbLegacyProbeDto? Probe { get; init; }
|
||||
@@ -105,6 +117,20 @@ public static class AbLegacyDriverFactoryExtensions
|
||||
public string? HostAddress { get; init; }
|
||||
public string? PlcFamily { get; init; }
|
||||
public string? DeviceName { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// PR 9 — optional per-device timeout in ms. Wins over the driver-wide
|
||||
/// <see cref="AbLegacyDriverConfigDto.TimeoutMs"/>. Tune this per chassis: SLC 5/01
|
||||
/// RS-232 ≈ 5000, SLC 5/05 ≈ 2000, MicroLogix 1100 ≈ 3000.
|
||||
/// </summary>
|
||||
public int? TimeoutMs { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// PR 9 — optional per-device retry count for transient <c>BadCommunicationError</c>
|
||||
/// reads. Wins over the driver-wide <see cref="AbLegacyDriverConfigDto.Retries"/>.
|
||||
/// <c>null</c> at both levels = single attempt.
|
||||
/// </summary>
|
||||
public int? Retries { get; init; }
|
||||
}
|
||||
|
||||
internal sealed class AbLegacyTagDto
|
||||
|
||||
Reference in New Issue
Block a user