Auto: twincat-3.2 — cycle-time / jitter / PLC-state diagnostics

Closes #314
This commit is contained in:
Joseph Doherty
2026-04-26 01:59:56 -04:00
parent 30e39a752a
commit 24a3cda56a
8 changed files with 642 additions and 1 deletions

View File

@@ -14,6 +14,28 @@ internal class FakeTwinCATClient : ITwinCATClient
public bool ThrowOnProbe { get; set; }
public Exception? Exception { get; set; }
public Dictionary<string, object?> Values { get; } = new(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Convenience seed for the well-known TwinCAT system symbols
/// (<c>TwinCAT_SystemInfoVarList._AppInfo.OnlineChangeCnt</c>,
/// <c>_AppInfo.AppName</c>, <c>_TaskInfo[1].CycleTime</c>,
/// <c>_TaskInfo[1].LastExecTime</c>) used by PR 3.2's probe-loop diagnostics.
/// Internally just writes to <see cref="Values"/>; provided as a named helper so tests
/// read clearly + so future schema changes (e.g. wrapping the system-symbol surface in
/// a typed snapshot) have one place to update.
/// </summary>
public void SetSystemSymbolValue(string name, object? value) => Values[name] = value;
/// <summary>
/// Force the next read of <paramref name="symbolPath"/> to fail with the supplied
/// <paramref name="status"/>. Subsequent reads after that fall back to the default
/// Good behaviour. Used by the PR 3.2 probe-loop tests to simulate a runtime that
/// doesn't expose <c>_TaskInfo[1]</c>.
/// </summary>
public void FailNextReadOf(string symbolPath, uint status = TwinCATStatusMapper.BadCommunicationError)
{
ReadStatuses[symbolPath] = status;
}
public Dictionary<string, uint> ReadStatuses { get; } = new(StringComparer.OrdinalIgnoreCase);
public Dictionary<string, uint> WriteStatuses { get; } = new(StringComparer.OrdinalIgnoreCase);
public List<(string symbol, TwinCATDataType type, int? bit, object? value)> WriteLog { get; } = new();