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",
|
||||
);
|
||||
|
||||
@@ -151,6 +151,63 @@ function writeIniToolTableFixtureStaging(wasmDir, expectedWasmDir, targetInterp
|
||||
};
|
||||
}
|
||||
|
||||
function writeG92PersistenceStaging(wasmDir, expectedWasmDir, targetInterp = interp) {
|
||||
assert.equal(wasmDir, expectedWasmDir, "g92 persistence staging root drift");
|
||||
const files = ["test.ngc", "startup.var", "persist.ini", "disabled.ini"];
|
||||
assert.equal(new Set(files).size, files.length, "g92 persistence staging manifest duplicate");
|
||||
for (const file of files) {
|
||||
assert.equal(`${wasmDir}/${file}`, `${expectedWasmDir}/${file}`, `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`;
|
||||
|
||||
targetInterp.writeTextFile(
|
||||
programPath,
|
||||
[
|
||||
"(PRINT,Startup G92 params: #5210 #5211 #5212 #5213)",
|
||||
"M30",
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
targetInterp.writeTextFile(
|
||||
parameterPath,
|
||||
[
|
||||
"5210 1",
|
||||
"5211 1.25",
|
||||
"5212 2.5",
|
||||
"5213 3.75",
|
||||
"5220 1",
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
targetInterp.writeTextFile(
|
||||
iniPath,
|
||||
[
|
||||
"[RS274NGC]",
|
||||
"PARAMETER_FILE = startup.var",
|
||||
"[TRAJ]",
|
||||
"COORDINATES = X Y Z",
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
targetInterp.writeTextFile(
|
||||
disabledIniPath,
|
||||
[
|
||||
"[RS274NGC]",
|
||||
"PARAMETER_FILE = startup.var",
|
||||
"DISABLE_G92_PERSISTENCE = 1",
|
||||
"[TRAJ]",
|
||||
"COORDINATES = X Y Z",
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
return { disabledIniPath, iniPath, parameterPath, programPath };
|
||||
}
|
||||
|
||||
function stageInterpIniContext(name, programFile = "test.ngc") {
|
||||
const sourceRootRel = `tests/interp/${name}`;
|
||||
const iniText = readFileSync(
|
||||
@@ -3578,62 +3635,21 @@ verifyExpectedOutput(
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
const g92PersistenceDir = "/work/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(
|
||||
"/work/interp/g52/g92-persistence",
|
||||
"/work/interp/g52/g92-persistence",
|
||||
);
|
||||
verifyExpectedOutput(
|
||||
"interp_g92_persistence_enabled_wasm",
|
||||
runWithCapturedPrints(() =>
|
||||
interp.runFileWithIni(g92PersistenceProgramPath, g92PersistenceIniPath),
|
||||
interp.runFileWithIni(g92Persistence.programPath, g92Persistence.iniPath),
|
||||
).prints,
|
||||
"Startup G92 params: 1.000000 1.250000 2.500000 3.750000",
|
||||
);
|
||||
verifyExpectedOutput(
|
||||
"interp_g92_persistence_disabled_wasm",
|
||||
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