fix(driver-s7): resolve Medium code-review finding (Driver.S7-012)

Remove the dead ProbeAddress config surface from S7ProbeOptions and the factory
DTO. ProbeLoopAsync uses Plc.ReadStatusAsync (CPU-status PDU), not a tag-address
read — ProbeAddress was never consumed. The XML doc on Probe is corrected to
describe the ReadStatusAsync-based probe. Existing configs that set probeAddress
are silently ignored by the JSON deserializer.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-05-22 10:16:54 -04:00
parent 19a2a81321
commit b827b0c0a2
3 changed files with 20 additions and 20 deletions

View File

@@ -64,7 +64,7 @@ public static class S7DriverFactoryExtensions
Enabled = dto.Probe?.Enabled ?? true,
Interval = TimeSpan.FromMilliseconds(dto.Probe?.IntervalMs ?? 5_000),
Timeout = TimeSpan.FromMilliseconds(dto.Probe?.TimeoutMs ?? 2_000),
ProbeAddress = dto.Probe?.ProbeAddress ?? "MW0",
// Driver.S7-012: ProbeAddress removed — probe uses ReadStatusAsync, not a tag read.
},
};
}
@@ -131,6 +131,8 @@ public static class S7DriverFactoryExtensions
public bool? Enabled { get; init; }
public int? IntervalMs { get; init; }
public int? TimeoutMs { get; init; }
public string? ProbeAddress { get; init; }
// Driver.S7-012: ProbeAddress removed from the configurable surface — the probe uses
// ReadStatusAsync (CPU status), not a tag-address read. Config documents that previously
// set probeAddress are safely ignored (unknown JSON fields are tolerated by the deserialiser).
}
}

View File

@@ -58,7 +58,7 @@ public sealed class S7DriverOptions
/// <summary>
/// Background connectivity-probe settings. When enabled, the driver runs a tick loop
/// that issues a cheap read against <see cref="S7ProbeOptions.ProbeAddress"/> every
/// that issues <c>S7.Net.Plc.ReadStatusAsync</c> (a CPU-status PDU) every
/// <see cref="S7ProbeOptions.Interval"/> and raises <c>OnHostStatusChanged</c> on
/// Running ↔ Stopped transitions.
/// </summary>
@@ -71,12 +71,10 @@ public sealed class S7ProbeOptions
public TimeSpan Interval { get; init; } = TimeSpan.FromSeconds(5);
public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(2);
/// <summary>
/// Address to probe for liveness. DB1.DBW0 is the convention if the PLC project
/// reserves a small fingerprint DB for health checks (per <c>docs/v2/s7.md</c>);
/// if not, pick any valid Merker word like <c>MW0</c>.
/// </summary>
public string ProbeAddress { get; init; } = "MW0";
// Driver.S7-012: ProbeAddress was configured and documented but was never read by the
// probe loop. ProbeLoopAsync uses S7.Net's ReadStatusAsync (a CPU-status PDU), not a
// DB/Merker read — it does not consume an explicit address. Rather than ship dead config
// surface, ProbeAddress has been removed. The liveness check is purely ReadStatusAsync-based.
}
/// <summary>