Support long G-code preview and virtualized execution display

This commit is contained in:
2026-08-29 22:27:01 +08:00
parent 819015924b
commit d87366eb75
7 changed files with 179 additions and 35 deletions

View File

@@ -145,7 +145,7 @@ export class WasmProgramRuntime {
if (step.status !== "verified") return { status: "error", code: step.code, line: temporary.snapshot().current_line, segments };
if (step.has_control && [428, 429, 430].includes(step.control_code)) kinematicsMode = { 428: 1, 429: 0, 430: 2 }[step.control_code];
if (step.motion) segments.push({ id: segments.length + 1, kinematics_mode: kinematicsMode, ...step.motion });
if ([4, 5, 6].includes(temporary.snapshot().status)) break;
if ([4, 5, 6].includes(step.program.status)) break;
}
return { status: "verified", schema: "wasm-canonical-preview.v1", source: "linuxcnc-wasm-sim_program", path: this.path, source_hash: fnv1a64(this.source), line_count: this.snapshot().line_count, segments, preview_hash: fnv1a64(segments) };
} finally { temporary.destroy(); }
@@ -220,12 +220,12 @@ export class WasmProgramRuntime {
try {
const result = call(this.core, "sim_program_execute_block", "number", ["number", "number", "number"], [this.pointer, pointer, bytes.byteLength]);
if (result !== 0) return programError("program_execute", result);
return { status: "verified", program: this.snapshot(), motion: this.readMotion() };
const program = this.snapshot();
return { status: "verified", program, motion: this.readMotion(program) };
} finally { this.core._free(pointer); }
}
readMotion() {
const state = this.snapshot();
readMotion(state = this.snapshot()) {
if (!state.has_motion) return null;
const result = call(this.core, "sim_program_read_motion", "number", ["number", "number"], [this.pointer, this.motionPointer]);
if (result !== 0) return null;
@@ -254,7 +254,7 @@ export class WasmProgramRuntime {
const result = this.invoke("sim_program_step", [], "program_step");
if (result.status !== "verified") return result;
const state = this.snapshot();
return { status: "verified", program_status: state.status, line: state.current_line, control_code: state.control_code ?? 0, has_control: state.has_control === 1, program: state, motion: this.readMotion() };
return { status: "verified", program_status: state.status, line: state.current_line, control_code: state.control_code ?? 0, has_control: state.has_control === 1, program: state, motion: this.readMotion(state) };
}
snapshot() {