feat(focas): cnc_statinfo status flags as Status/ fixed-tree nodes (#257)
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
@@ -125,6 +125,17 @@ public interface IFocasClient : IDisposable
|
||||
/// <returns>The aggregate program + operation-mode snapshot.</returns>
|
||||
Task<FocasProgramInfo> GetProgramInfoAsync(CancellationToken cancellationToken);
|
||||
|
||||
// ---- Fixed-tree T2.5 (CNC status flags, Gitea #257) ----
|
||||
|
||||
/// <summary>
|
||||
/// Read the CNC status flags via <c>cnc_statinfo</c> (<c>ODBST</c>). Populates the
|
||||
/// <c>Status/*</c> subtree. Throws when the CNC refuses the call, which the driver's
|
||||
/// bootstrap probe reads as "this series has no status block" and suppresses the subtree.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>The CNC status flag snapshot.</returns>
|
||||
Task<FocasStatus> GetStatusAsync(CancellationToken cancellationToken);
|
||||
|
||||
// ---- Fixed-tree T3 (timers) ----
|
||||
|
||||
/// <summary>
|
||||
@@ -172,6 +183,38 @@ public interface IFocasClient : IDisposable
|
||||
Task<IReadOnlyList<double?>> GetSpindleMotorSpeedsAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CNC status flags from <c>cnc_statinfo</c> (<c>ODBST</c>) — raw FANUC codes, published verbatim as
|
||||
/// Int32 so a client sees exactly what the control reported. <see cref="Run"/> additionally has a
|
||||
/// text projection (<see cref="FocasRunState.ToText"/>).
|
||||
/// </summary>
|
||||
/// <param name="Auto">Automatic-operation mode code.</param>
|
||||
/// <param name="Run">Automatic-operation state (0 RESET, 1 STOP, 2 HOLD, 3 START, 4 MSTR).</param>
|
||||
/// <param name="Motion">Axis motion (0 none, 1 motion, 2 dwell).</param>
|
||||
/// <param name="Mstb">M/S/T/B function state (0 none, 1 executing).</param>
|
||||
/// <param name="Emergency">Emergency stop (0 not, 1 emergency, 2 reset).</param>
|
||||
/// <param name="Alarm">Alarm state (0 none, 1 alarm, 2 battery-low, 3 fan).</param>
|
||||
/// <param name="Edit">Program-edit state.</param>
|
||||
/// <param name="TmMode">T/M mode as reported by the control.</param>
|
||||
public sealed record FocasStatus(int Auto, int Run, int Motion, int Mstb, int Emergency, int Alarm, int Edit, int TmMode);
|
||||
|
||||
/// <summary>Human-readable text for <see cref="FocasStatus.Run"/>.</summary>
|
||||
public static class FocasRunState
|
||||
{
|
||||
/// <summary>Converts the <c>ODBST.run</c> code to its operator-facing label.</summary>
|
||||
/// <param name="run">The run-state code.</param>
|
||||
/// <returns>The label, or <c>Run{n}</c> for a code outside the documented set.</returns>
|
||||
public static string ToText(int run) => run switch
|
||||
{
|
||||
0 => "RESET",
|
||||
1 => "STOP",
|
||||
2 => "HOLD",
|
||||
3 => "START",
|
||||
4 => "MSTR",
|
||||
_ => $"Run{run}",
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// One servo-meter entry — one axis's current load percentage; null when the CNC's record
|
||||
/// described no usable value (never a fabricated 0).
|
||||
|
||||
Reference in New Issue
Block a user