namespace ZB.MOM.WW.OtOpcUa.Driver.TwinCAT;
///
/// One device's probe-sampled PLC facts, surfaced through the driver's
/// bag to the /hosts page. Every field is
/// best-effort: a runtime that does not export a system symbol leaves that field at its last known value
/// (null if never seen).
///
/// The ADS device state name (Run, Stop, Config, …).
/// The running PLC application's name (_AppInfo.AppName).
/// How many online changes the application has taken (_AppInfo.OnlineChangeCnt).
/// The first PLC task's configured cycle time in milliseconds.
/// How long the task's last cycle took to execute, in milliseconds.
/// When the snapshot was taken.
internal sealed record TwinCATDeviceDiagnostics(
string? AdsState,
string? AppName,
uint? OnlineChangeCnt,
double? CycleTimeMs,
double? LastExecTimeMs,
DateTime UpdatedUtc)
{
/// Gets cycle time minus last execution time: how much of the cycle was spare. Negative means the
/// task overran its cycle. (Not jitter — that needs the variation across cycles.)
public double? HeadroomMs => CycleTimeMs is { } c && LastExecTimeMs is { } x ? c - x : null;
}