Document source UI gates, explicit native live-plot clearing, and remaining parity boundaries. Fix pause/resume transport continuity, repeated stepping, coordinate previews, and spindle override state. Optimize large program snapshots and rendering, and cover the control flows with native Tcl, WASM, and browser checks. Validation: 22 native tests and source/browser checks pass. Worker/App regression: 113 of 123 pass; 10 pre-existing failures remain documented with no new failures.
28 lines
2.7 KiB
JavaScript
28 lines
2.7 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { axisState, AXIS_STATES, LINUXCNC_STATE_CONSTANTS, validateAxisTransition } from "./axis-state.mjs";
|
|
|
|
assert.deepEqual(AXIS_STATES, ["ESTOP", "ESTOP_RESET", "OFF", "ON", "HOME", "IDLE", "RUNNING", "PAUSED"]);
|
|
assert.deepEqual(LINUXCNC_STATE_CONSTANTS, { STATE_ESTOP: 1, STATE_ESTOP_RESET: 2, STATE_OFF: 3, STATE_ON: 4, MODE_MANUAL: 1, MODE_AUTO: 2, MODE_MDI: 3, INTERP_IDLE: 1, INTERP_READING: 2, INTERP_PAUSED: 3, INTERP_WAITING: 4 });
|
|
assert.equal(axisState({ task: { state: "NEW" }, action: "SESSION_ATTACH" }).state, "OFF");
|
|
assert.deepEqual(axisState({ task: { state: "ESTOP" }, action: "ESTOP", payload: { active: true } }).state, "ESTOP");
|
|
assert.deepEqual(axisState({ task: { state: "ESTOP" }, io: { state: { estop: true, ready: false } }, action: "ESTOP", payload: { active: false } }).state, "ESTOP");
|
|
assert.equal(axisState({ task: { state: "READY" }, io: { state: { estop: false, ready: true } }, action: "HOME" }).state, "IDLE");
|
|
assert.equal(axisState({ task: { state: "RUNNING" }, program: { program_status: "running" }, action: "SIM_STEP" }).state, "RUNNING");
|
|
assert.equal(axisState({ task: { state: "PAUSED" }, program: { program_status: "paused" }, action: "PROGRAM_PAUSE" }).state, "PAUSED");
|
|
assert.equal(axisState({ task: { state: "READY" }, program: { program_status: "idle" }, action: "IO_RECOVER" }).state, "IDLE");
|
|
assert.equal(axisState({ task: { state: "RUNNING", mode: "AUTO" }, program: { program_status: "running" } }).source_interp_state, "INTERP_READING");
|
|
assert.equal(axisState({ task: { state: "PAUSED", mode: "AUTO" }, program: { program_status: "paused" } }).source_interp_state, "INTERP_PAUSED");
|
|
assert.equal(axisState({ task: { state: "STOPPED" }, io: { state: { estop: false, ready: false, last_error: 0 } } }).machine_state, "OFF");
|
|
for (const last_error of [0, -904, -903]) {
|
|
const state = axisState({ task: { state: "STOPPED" }, io: { state: { estop: false, ready: false, last_error } } });
|
|
assert.equal(state.machine_state, "OFF");
|
|
assert.equal(state.source_task_state, "STATE_ESTOP_RESET");
|
|
}
|
|
assert.equal(validateAxisTransition("ESTOP", "ESTOP_RESET").status, "accepted");
|
|
assert.equal(axisState({ task: { state: "FAULT" }, io: { state: { estop: false, ready: true } } }).source_task_state, "STATE_ON");
|
|
assert.equal(validateAxisTransition("ESTOP_RESET", "ON").status, "accepted");
|
|
assert.equal(validateAxisTransition("ON", "RUNNING").status, "accepted");
|
|
assert.equal(validateAxisTransition("RUNNING", "HOME").status, "blocked");
|
|
|
|
console.log(JSON.stringify({ schema: "axis-state-v1-sample", status: "verified", states: AXIS_STATES, cases: ["ESTOP", "ESTOP_RESET", "OFF", "ON", "HOME", "IDLE", "RUNNING", "PAUSED"] }));
|