Guard G92 persistence staging
This commit is contained in:
@@ -4383,6 +4383,69 @@
|
||||
};
|
||||
}
|
||||
|
||||
function writeG92PersistenceStaging(interp, wasmDir, expectedWasmDir) {
|
||||
if (wasmDir !== expectedWasmDir) {
|
||||
throw new Error("browser_g92_persistence_staging_root: path drift");
|
||||
}
|
||||
const files = ["test.ngc", "startup.var", "persist.ini", "disabled.ini"];
|
||||
if (files.length !== new Set(files).size) {
|
||||
throw new Error("browser_g92_persistence_staging_manifest: list drift");
|
||||
}
|
||||
for (const file of files) {
|
||||
if (`${wasmDir}/${file}` !== `${expectedWasmDir}/${file}`) {
|
||||
throw new Error(`browser_g92_persistence_${file}_staging: path drift`);
|
||||
}
|
||||
}
|
||||
|
||||
const programPath = `${wasmDir}/test.ngc`;
|
||||
const parameterPath = `${wasmDir}/startup.var`;
|
||||
const iniPath = `${wasmDir}/persist.ini`;
|
||||
const disabledIniPath = `${wasmDir}/disabled.ini`;
|
||||
|
||||
interp.writeTextFile(
|
||||
programPath,
|
||||
[
|
||||
"(PRINT,Startup G92 params: #5210 #5211 #5212 #5213)",
|
||||
"M30",
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
interp.writeTextFile(
|
||||
parameterPath,
|
||||
[
|
||||
"5210 1",
|
||||
"5211 1.25",
|
||||
"5212 2.5",
|
||||
"5213 3.75",
|
||||
"5220 1",
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
interp.writeTextFile(
|
||||
iniPath,
|
||||
[
|
||||
"[RS274NGC]",
|
||||
"PARAMETER_FILE = startup.var",
|
||||
"[TRAJ]",
|
||||
"COORDINATES = X Y Z",
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
interp.writeTextFile(
|
||||
disabledIniPath,
|
||||
[
|
||||
"[RS274NGC]",
|
||||
"PARAMETER_FILE = startup.var",
|
||||
"DISABLE_G92_PERSISTENCE = 1",
|
||||
"[TRAJ]",
|
||||
"COORDINATES = X Y Z",
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
return { disabledIniPath, iniPath, parameterPath, programPath };
|
||||
}
|
||||
|
||||
async function loadSimMachineFiles(machineRel, iniFile, programFile = null) {
|
||||
const iniText = await fetchText(
|
||||
`../../vendor/linuxcnc/configs/sim/${machineRel}/${iniFile}`,
|
||||
@@ -8633,62 +8696,22 @@
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
const g92PersistenceDir = "/work/browser-interp/g52/g92-persistence";
|
||||
const g92PersistenceProgramPath = `${g92PersistenceDir}/test.ngc`;
|
||||
const g92PersistenceParameterPath = `${g92PersistenceDir}/startup.var`;
|
||||
const g92PersistenceIniPath = `${g92PersistenceDir}/persist.ini`;
|
||||
const g92PersistenceDisabledIniPath = `${g92PersistenceDir}/disabled.ini`;
|
||||
interp.writeTextFile(
|
||||
g92PersistenceProgramPath,
|
||||
[
|
||||
"(PRINT,Startup G92 params: #5210 #5211 #5212 #5213)",
|
||||
"M30",
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
interp.writeTextFile(
|
||||
g92PersistenceParameterPath,
|
||||
[
|
||||
"5210 1",
|
||||
"5211 1.25",
|
||||
"5212 2.5",
|
||||
"5213 3.75",
|
||||
"5220 1",
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
interp.writeTextFile(
|
||||
g92PersistenceIniPath,
|
||||
[
|
||||
"[RS274NGC]",
|
||||
"PARAMETER_FILE = startup.var",
|
||||
"[TRAJ]",
|
||||
"COORDINATES = X Y Z",
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
interp.writeTextFile(
|
||||
g92PersistenceDisabledIniPath,
|
||||
[
|
||||
"[RS274NGC]",
|
||||
"PARAMETER_FILE = startup.var",
|
||||
"DISABLE_G92_PERSISTENCE = 1",
|
||||
"[TRAJ]",
|
||||
"COORDINATES = X Y Z",
|
||||
"",
|
||||
].join("\n"),
|
||||
const g92Persistence = writeG92PersistenceStaging(
|
||||
interp,
|
||||
"/work/browser-interp/g52/g92-persistence",
|
||||
"/work/browser-interp/g52/g92-persistence",
|
||||
);
|
||||
verifyExpectedOutput(
|
||||
"browser_interp_g92_persistence_enabled",
|
||||
runWithCapturedPrints(() =>
|
||||
interp.runFileWithIni(g92PersistenceProgramPath, g92PersistenceIniPath),
|
||||
interp.runFileWithIni(g92Persistence.programPath, g92Persistence.iniPath),
|
||||
).prints,
|
||||
"Startup G92 params: 1.000000 1.250000 2.500000 3.750000",
|
||||
);
|
||||
verifyExpectedOutput(
|
||||
"browser_interp_g92_persistence_disabled",
|
||||
runWithCapturedPrints(() =>
|
||||
interp.runFileWithIni(g92PersistenceProgramPath, g92PersistenceDisabledIniPath),
|
||||
interp.runFileWithIni(g92Persistence.programPath, g92Persistence.disabledIniPath),
|
||||
).prints,
|
||||
"Startup G92 params: 0.000000 0.000000 0.000000 0.000000",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user