fix(twincat): review fixes for sum-read and diagnostics (#645)

Strict width+kind eligibility for sum-batched scalars (others read singly); latch only on ADS
1793/1794, split 1792/1797/1798 without latching; 32 KiB per-command budget and 500-item ceiling;
short sum response handled per item. Diagnostics: opt-in diagnosticsEnabled (default off), reuse the
probe's ReadState, sample after the host-state transition, JitterMs renamed HeadroomMs, compact
per-device line so many devices fit the 16-entry cap, unavailable-symbol latch cleared on reconnect.
AdminUI: min/max on sum-read max, diagnostics checkbox. Pure planner extracted and unit-tested.

Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
Joseph Doherty
2026-10-08 19:29:35 -04:00
parent af19db4ed1
commit fbcb521d1b
16 changed files with 470 additions and 138 deletions
@@ -54,8 +54,16 @@
<div class="col-md-4 mb-3">
<label class="form-label" for="tcSumReadMax">Sum-read max items</label>
<InputNumber id="tcSumReadMax" @bind-Value="_form.SumReadMaxItems" @bind-Value:after="EmitAsync"
class="form-control form-control-sm" />
<div class="form-text">Symbols per sum-read command (default 200).</div>
min="1" max="500" class="form-control form-control-sm" />
<div class="form-text">Symbols per sum-read command (1-500, default 200).</div>
</div>
<div class="col-md-4 mb-3">
<div class="form-check form-switch mt-4">
<InputCheckbox id="tcDiagnostics" @bind-Value="_form.DiagnosticsEnabled" @bind-Value:after="EmitAsync"
class="form-check-input" />
<label class="form-check-label" for="tcDiagnostics">PLC diagnostics on /hosts</label>
</div>
<div class="form-text">Up to 4 extra reads per device per probe tick. Default off (not yet live-gated).</div>
</div>
</div>
</div>
@@ -167,6 +175,7 @@
public int NotificationMaxDelayMs { get; set; } = 0;
public bool UseSumRead { get; set; } = false;
public int SumReadMaxItems { get; set; } = 200;
public bool DiagnosticsEnabled { get; set; } = false;
// Probe
public bool ProbeEnabled { get; set; } = true;
@@ -186,6 +195,7 @@
NotificationMaxDelayMs = o.NotificationMaxDelayMs,
UseSumRead = o.UseSumRead,
SumReadMaxItems = o.SumReadMaxItems,
DiagnosticsEnabled = o.DiagnosticsEnabled,
ProbeEnabled = o.Probe.Enabled,
ProbeIntervalSeconds = (int)o.Probe.Interval.TotalSeconds,
ProbeTimeoutSeconds = (int)o.Probe.Timeout.TotalSeconds,
@@ -201,6 +211,7 @@
NotificationMaxDelayMs = NotificationMaxDelayMs,
UseSumRead = UseSumRead,
SumReadMaxItems = SumReadMaxItems,
DiagnosticsEnabled = DiagnosticsEnabled,
Probe = new TwinCATProbeOptions
{
Enabled = ProbeEnabled,