Auto: s7-c4 — deadband / on-change with thresholds

Closes #297
This commit is contained in:
Joseph Doherty
2026-04-26 01:14:59 -04:00
parent 8909302929
commit 06b39a28fa
5 changed files with 555 additions and 4 deletions

View File

@@ -90,7 +90,9 @@ public static class S7DriverFactoryExtensions
Writable: t.Writable ?? true,
StringLength: t.StringLength ?? 254,
WriteIdempotent: t.WriteIdempotent ?? false,
ScanGroup: string.IsNullOrWhiteSpace(t.ScanGroup) ? null : t.ScanGroup);
ScanGroup: string.IsNullOrWhiteSpace(t.ScanGroup) ? null : t.ScanGroup,
DeadbandAbsolute: t.DeadbandAbsolute,
DeadbandPercent: t.DeadbandPercent);
private static T ParseEnum<T>(string? raw, string driverInstanceId, string field,
string? tagName = null, T? fallback = null) where T : struct, Enum
@@ -167,6 +169,23 @@ public static class S7DriverFactoryExtensions
/// default publishing interval).
/// </summary>
public string? ScanGroup { get; init; }
/// <summary>
/// PR-S7-C4 — optional absolute deadband threshold. Numeric tags whose
/// <c>|new - prev|</c> is strictly less than this value are suppressed at
/// the driver layer before <c>OnDataChange</c> fires. Ignored for non-numeric
/// types. NaN / ±Infinity samples bypass the filter and always publish.
/// </summary>
public double? DeadbandAbsolute { get; init; }
/// <summary>
/// PR-S7-C4 — optional percent deadband (0..100). Numeric tags whose
/// <c>|new - prev|</c> is strictly less than <c>|prev| * pct / 100</c> are
/// suppressed. Falls back to <see cref="DeadbandAbsolute"/> when
/// <c>|prev| &lt; 1e-6</c> (near-zero baseline rule). When both deadbands are
/// set the filters are OR'd — publish if EITHER threshold triggers.
/// </summary>
public double? DeadbandPercent { get; init; }
}
internal sealed class S7ProbeDto