Implement AXIS parity UI and execution baseline

This commit is contained in:
2026-08-23 07:28:37 +08:00
parent 1325504544
commit 06f96f85e5
463 changed files with 84893 additions and 692 deletions

View File

@@ -0,0 +1,35 @@
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import createModule from "../../build-wasm/linuxcnc-sim-core.js";
import { SimSession, CONTEXT_ID } from "./sim-session.mjs";
const core = await createModule({ wasmBinary: await readFile(new URL("../../build-wasm/linuxcnc-sim-core.wasm", import.meta.url)) });
const session = new SimSession(core, { sessionId: "p304-state" });
const base = { schema_version: 1, context_id: CONTEXT_ID, session_id: "p304-state" };
const send = (kind, seq, operation_id, payload = {}) => session.accept({ ...base, kind, seq, operation_id, payload });
assert.equal(send("HELLO", 1).kind, "CAPABILITIES");
assert.equal(send("SESSION_ATTACH", 2, "attach").kind, "SESSION_READY");
send("LOAD_WORKSPACE", 3, "workspace", { root_path: "/workspace" });
send("PROGRAM_LOAD", 4, "load", { path: "state.ngc", source: "G21 G90\nG1 X2 F60\nM2\n" });
const run = send("PROGRAM_RUN", 5, "run");
assert.equal(run.payload.task.state, "RUNNING");
const replay = send("PROGRAM_RUN", 6, "run", { changed: true });
assert.equal(replay.replayed, true);
const checkpointResponse = send("CHECKPOINT", 7, "checkpoint-pre");
const checkpoint = checkpointResponse.payload.checkpoint;
const mdiBlocked = send("MDI_EXECUTE", 8, "mdi-blocked", { block: "G1 X9" });
assert.equal(mdiBlocked.kind, "ERROR");
assert.equal(mdiBlocked.payload.message_key, "mdi_while_program_active");
send("SIM_STEP", 9, "tick", { cycles: 1 });
assert.equal(send("PROGRAM_PAUSE", 10, "pause").payload.task.state, "PAUSED");
assert.equal(send("PROGRAM_RESUME", 11, "resume").payload.task.state, "RUNNING");
assert.equal(send("PROGRAM_ABORT", 12, "abort").payload.task.state, "STOPPED");
assert.equal(send("PROGRAM_RESTART", 13, "restart").payload.task.program_status, "loaded");
const single = send("PROGRAM_STEP", 14, "single");
assert.equal(single.payload.task.state, "PAUSED");
assert.equal(single.payload.task.program_status, "paused");
const recovered = session.restoreCheckpoint(checkpoint, null, (operation) => operation);
assert.equal(recovered.status, "recovered");
assert.equal(recovered.state.task.state, "RUNNING");
console.log(`task_program_state=passed replay=${replay.replayed} restart=${single.payload.task.program_status} recovery=${recovered.state.task.state}`);