fix: make Pause button pause running program

This commit is contained in:
wangdequan
2026-07-05 21:55:17 -04:00
parent 220c15295c
commit 58854f9ecf
12 changed files with 1774 additions and 126 deletions

View File

@@ -313,11 +313,15 @@ for (const action of [
"run",
"pause",
"resume",
"pause-resume",
"step",
"stop",
"home-all",
"jog-plus",
"jog-minus",
"spindle-reverse",
"spindle-stop",
"spindle-forward",
"kins-identity",
"kins-tcp",
"kins-userk",
@@ -335,14 +339,61 @@ buttonStore.dispatch({ type: "TOGGLE_POWER" });
assert.equal(buttonStore.getState().machine.powerOn, true);
buttonStore.dispatch({ type: "HOME" });
assert.equal(buttonStore.getState().machine.allHomed, true);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.axes.joint.x, 43);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.axes.joint.y, -32.15);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.axes.joint.z, -11.306);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.axes.joint.x, 0);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.axes.joint.y, 0);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.axes.joint.z, 10);
await buttonStore.dispatch({ type: "RUN_FROM_OPERATOR" });
assert.equal(buttonStore.getState().machine.mode, "auto");
assert.equal(["running", "complete"].includes(buttonStore.getState().runState), true);
assert.equal(Boolean(buttonStore.getState().programRuntimeFeedback), true);
if (buttonStore.getState().runState === "running") {
buttonStore.dispatch({ type: "PAUSE_RESUME" });
assert.equal(buttonStore.getState().runState, "paused");
assert.equal(buttonStore.getState().machine.interpState, "paused");
buttonStore.dispatch({ type: "PAUSE_RESUME" });
assert.equal(buttonStore.getState().runState, "running");
assert.equal(buttonStore.getState().machine.interpState, "reading");
buttonStore.dispatch({ type: "PAUSE_RESUME" });
assert.equal(buttonStore.getState().runState, "paused");
assert.equal(buttonStore.getState().machine.interpState, "paused");
const beforeStepSample = buttonStore.getState().programExecutionSampleIndex;
buttonStore.dispatch({ type: "STEP" });
assert.equal(buttonStore.getState().runState, "stepping");
assert.equal(buttonStore.getState().machine.interpState, "paused");
assert.equal(buttonStore.getState().programExecutionSampleIndex > beforeStepSample, true);
buttonStore.dispatch({ type: "RESUME" });
assert.equal(buttonStore.getState().runState, "running");
assert.equal(buttonStore.getState().machine.interpState, "reading");
buttonStore.dispatch({ type: "PAUSE" });
assert.equal(buttonStore.getState().runState, "paused");
assert.equal(buttonStore.getState().machine.interpState, "paused");
buttonStore.dispatch({ type: "RESUME" });
assert.equal(buttonStore.getState().runState, "running");
assert.equal(buttonStore.getState().machine.interpState, "reading");
}
buttonStore.dispatch({ type: "STOP" });
const idleInterpRunningStore = createSimulationStore({
runState: "running",
machine: {
powerOn: true,
estopActive: false,
taskState: "on",
mode: "auto",
interpState: "idle",
interpResumeState: "reading",
taskPaused: false,
allHomed: true,
noForceHoming: false,
},
});
idleInterpRunningStore.dispatch({ type: "PAUSE" });
assert.equal(idleInterpRunningStore.getState().runState, "paused");
assert.equal(idleInterpRunningStore.getState().machine.interpState, "paused");
assert.equal(idleInterpRunningStore.getState().machine.taskPaused, true);
idleInterpRunningStore.dispatch({ type: "RESUME" });
assert.equal(idleInterpRunningStore.getState().runState, "running");
assert.equal(idleInterpRunningStore.getState().machine.interpState, "reading");
buttonStore.dispatch({ type: "SET_MODE", mode: "manual" });
buttonStore.dispatch({ type: "SET_MODE", mode: "mdi" });
buttonStore.dispatch({ type: "RUN_MDI", command: "M428" });
@@ -370,10 +421,28 @@ const feedBefore = buttonStore.getState().feed.feedOverride;
buttonStore.dispatch({ type: "ADJUST_OVERRIDE", target: "feed", delta: 10 });
assert.equal(buttonStore.getState().feed.feedOverride, feedBefore + 10);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.feed.feedOverridePercent, feedBefore + 10);
buttonStore.dispatch({ type: "SET_SPINDLE_DIRECTION", direction: "reverse" });
assert.equal(buttonStore.getState().spindle.direction, "reverse");
assert.equal(buttonStore.getState().linuxCncProcessMonitor.spindle.enabled, true);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.spindle.halPins.on, 1);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.spindle.halPins.forward, 0);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.spindle.halPins.reverse, 1);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.spindle.halPins.speedOut, 1600);
buttonStore.dispatch({ type: "SET_SPINDLE_DIRECTION", direction: "stop" });
assert.equal(buttonStore.getState().spindle.direction, "stop");
assert.equal(buttonStore.getState().linuxCncProcessMonitor.spindle.enabled, false);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.spindle.halPins.on, 0);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.spindle.halPins.forward, 0);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.spindle.halPins.reverse, 0);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.spindle.halPins.speedOut, 0);
buttonStore.dispatch({ type: "SET_SPINDLE_DIRECTION", direction: "forward" });
assert.equal(buttonStore.getState().spindle.direction, "forward");
assert.equal(buttonStore.getState().linuxCncProcessMonitor.spindle.enabled, true);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.spindle.actualRpm, 1600);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.spindle.halPins.on, 1);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.spindle.halPins.forward, 1);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.spindle.halPins.reverse, 0);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.spindle.halPins.speedOut, 1600);
buttonStore.dispatch({ type: "TOGGLE_COOLANT", kind: "flood" });
assert.equal(buttonStore.getState().coolant.flood, true);
assert.equal(buttonStore.getState().linuxCncProcessMonitor.coolant.flood, true);