Align pause resume and abort lifecycle
This commit is contained in:
@@ -219,10 +219,15 @@ export function App() {
|
||||
const startRunTimer = () => { if (runTimer.current) return; runTimer.current = setInterval(() => { if (runStepPending.current) return; runStepPending.current = true; operationController.execute("SIM_STEP", { cycles: 5, response: "motion_delta" }, { state: axisState, gate: false }).catch(() => undefined).finally(() => { runStepPending.current = false; }); }, 50); };
|
||||
const dispatch = (kind: string, payload: Record<string, unknown> = {}, gate = true, action: string | null = null): Promise<void> => {
|
||||
setCommandStatus(`${kind} pending`);
|
||||
// The AXIS task stops issuing servo/task polls before changing the
|
||||
// interpreter state. A SIM_STEP already in flight is allowed to finish,
|
||||
// but no new poll may race PROGRAM_PAUSE/PROGRAM_ABORT and consume the
|
||||
// protocol sequence reserved for RESUME.
|
||||
if (kind === "JOG_STOP") stopJogTimer();
|
||||
if (["PROGRAM_PAUSE", "PROGRAM_ABORT"].includes(kind)) stopRunTimer();
|
||||
const pending = operationController.execute(kind, payload, { state: axisState, gate, ...(action ? { action } : {}) });
|
||||
setOperationTrace(operationController.exportTrace());
|
||||
return pending.then(() => { setOperationTrace(operationController.exportTrace()); setCommandStatus(`${kind} acknowledged`); if (kind === "PROGRAM_RUN") startRunTimer(); if (kind === "PROGRAM_ABORT" || kind === "PROGRAM_RESTART") stopRunTimer(); if (kind === "JOG_START") startJogTimer(); if (kind === "JOG_STOP") stopJogTimer(); }).catch((error: Error) => {
|
||||
return pending.then(() => { setOperationTrace(operationController.exportTrace()); setCommandStatus(`${kind} acknowledged`); if (kind === "PROGRAM_RUN" || kind === "PROGRAM_RESUME") startRunTimer(); if (["PROGRAM_PAUSE", "PROGRAM_ABORT", "PROGRAM_RESTART"].includes(kind)) stopRunTimer(); if (kind === "JOG_START") startJogTimer(); if (kind === "JOG_STOP") stopJogTimer(); }).catch((error: Error) => {
|
||||
setOperationTrace(operationController.exportTrace());
|
||||
const code = error.message;
|
||||
setCommandStatus(`${kind} blocked: ${code}`);
|
||||
|
||||
Reference in New Issue
Block a user