Keep G-code matched to imported AC or BC machine type
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { programMachineMismatch } from "../workspace/program-machine-compatibility.mjs";
|
||||
import { exportNativeCheckpoint, restoreNativeCheckpoint, validateNativeCheckpoint } from "./native-checkpoint.mjs";
|
||||
import { ReplayTimeline, fnv1a64 } from "./replay.mjs";
|
||||
import { capabilities, validateLimit } from "./capabilities.mjs";
|
||||
@@ -373,6 +374,8 @@ export class SimSession {
|
||||
const path = `${basePath.replace(/\/demos$/, "")}/${suffix}`;
|
||||
const source = this.workspaceFiles[path];
|
||||
if (typeof source !== "string") return { status: "error", code: "program_subroutine_missing", path };
|
||||
const mismatch = programMachineMismatch(source, coordinates, path);
|
||||
if (mismatch) return { status: "error", code: "program_machine_mismatch", reason: mismatch, path };
|
||||
const added = this.xyzacProgram.addSubroutine(name, source, path);
|
||||
if (added.status !== "verified") return added;
|
||||
}
|
||||
@@ -604,6 +607,18 @@ export class SimSession {
|
||||
}
|
||||
|
||||
xyzacCommandGate(input) {
|
||||
const coordinates = this.machineDefinition?.coordinates ?? DEFAULT_MACHINE.coordinates;
|
||||
let mismatch = "";
|
||||
if (input.kind === "PROGRAM_LOAD") {
|
||||
mismatch = programMachineMismatch(input.payload?.source ?? input.payload?.text ?? input.payload?.program_source, coordinates, input.payload?.path);
|
||||
} else if (["PROGRAM_RUN", "PROGRAM_STEP", "PROGRAM_RESUME"].includes(input.kind)) {
|
||||
const source = this.xyzacProgram.executionSource || this.xyzacProgram.source;
|
||||
const path = this.xyzacProgram.path;
|
||||
const previous = this.programCompatibility;
|
||||
if (!previous || previous.source !== source || previous.path !== path || previous.coordinates !== coordinates) this.programCompatibility = { source, path, coordinates, mismatch: programMachineMismatch(source, coordinates, path) };
|
||||
mismatch = this.programCompatibility.mismatch;
|
||||
}
|
||||
if (mismatch) return { enabled: false, reason: mismatch, action: PANEL_GATE_ACTIONS[input.kind] ?? null };
|
||||
const task = this.task.export();
|
||||
const program = this.xyzacProgram.snapshot();
|
||||
const io = this.xyzacIo?.canonical?.() ?? {};
|
||||
|
||||
Reference in New Issue
Block a user