结论:补齐 INI 派生自定义工具表路径的浏览器 OPFS 保存读回验证,继续通过 vendored LinuxCNC tooldata_save 路径覆盖。
760 lines
24 KiB
HTML
760 lines
24 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>LinuxCNC Interpreter Browser Smoke</title>
|
|
</head>
|
|
<body>
|
|
<pre id="status">running</pre>
|
|
<script type="module">
|
|
import {
|
|
createLinuxCncIniSdk,
|
|
createLinuxCncInterpSdk,
|
|
} from "../../runtime/sdk/src/index.js";
|
|
import {
|
|
saveMachineParametersToOpfs,
|
|
} from "../../runtime/opfs/linuxcnc-parameter-bridge.js";
|
|
import {
|
|
loadTextFile,
|
|
saveTextFile,
|
|
} from "../../runtime/opfs/file-service.js";
|
|
import {
|
|
saveMachineToolTableToOpfs,
|
|
} from "../../runtime/opfs/linuxcnc-tool-table-bridge.js";
|
|
import {
|
|
loadMachineSessionFromOpfs,
|
|
} from "../../runtime/opfs/linuxcnc-machine-session-bridge.js";
|
|
import {
|
|
loadMachineTextFiles,
|
|
saveMachineTextFiles,
|
|
} from "../../runtime/opfs/machine-file-store.js";
|
|
import {
|
|
INTERP_BROWSER_FILE_FIXTURES,
|
|
INTERP_BROWSER_MDI_FIXTURES,
|
|
INTERP_ERROR_FIXTURES,
|
|
INTERP_INI_FIXTURE,
|
|
INTERP_POSITION_PARAMS_FILE_FIXTURE,
|
|
} from "../fixtures/interp-fixture-matrix.mjs";
|
|
|
|
const status = document.getElementById("status");
|
|
|
|
async function fetchText(path) {
|
|
const response = await fetch(path);
|
|
if (!response.ok) {
|
|
throw new Error(`${path}: HTTP ${response.status}`);
|
|
}
|
|
return response.text();
|
|
}
|
|
|
|
function verifyExpectedOutput(fixtureName, output, expectedText) {
|
|
const expectedLines = expectedText.split("\n").filter(Boolean);
|
|
for (const expectedLine of expectedLines) {
|
|
if (expectedLine.startsWith("absent=")) {
|
|
const forbidden = expectedLine.slice("absent=".length);
|
|
if (output.includes(forbidden)) {
|
|
throw new Error(`${fixtureName}: unexpected ${forbidden}`);
|
|
}
|
|
continue;
|
|
}
|
|
if (!output.includes(expectedLine)) {
|
|
throw new Error(`${fixtureName}: missing ${expectedLine}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
function verifyExpectedFileError(fixtureName, output, expectedText) {
|
|
if (!output.includes("file_open=0")) {
|
|
throw new Error(`${fixtureName}: missing file_open=0`);
|
|
}
|
|
|
|
const expectedLines = expectedText.split("\n").filter(Boolean);
|
|
for (const expectedLine of expectedLines) {
|
|
if (expectedLine.startsWith("absent=")) {
|
|
const forbidden = expectedLine.slice("absent=".length);
|
|
if (output.includes(forbidden)) {
|
|
throw new Error(`${fixtureName}: unexpected ${forbidden}`);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
if (expectedLine.startsWith("error_text=")) {
|
|
const message = expectedLine.slice("error_text=".length);
|
|
if (!output.includes(`file_error_text=${message}`)) {
|
|
throw new Error(`${fixtureName}: missing file error ${message}`);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
if (expectedLine.startsWith("canon_event=") && !output.includes(expectedLine)) {
|
|
throw new Error(`${fixtureName}: missing ${expectedLine}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
async function verifyRejects(fixtureName, operation, expectedPattern) {
|
|
try {
|
|
await operation();
|
|
} catch (error) {
|
|
if (!expectedPattern.test(error.message)) {
|
|
throw new Error(`${fixtureName}: unexpected error ${error.message}`);
|
|
}
|
|
return;
|
|
}
|
|
throw new Error(`${fixtureName}: expected rejection`);
|
|
}
|
|
|
|
try {
|
|
const interp = await createLinuxCncInterpSdk({
|
|
locateFile(path) {
|
|
if (path === "linuxcnc_interp.wasm") {
|
|
return "../../build/wasm/core/linuxcnc_interp.wasm";
|
|
}
|
|
return path;
|
|
},
|
|
print() {},
|
|
printErr(message) {
|
|
console.error(message);
|
|
},
|
|
});
|
|
const ini = await createLinuxCncIniSdk({
|
|
locateFile(path) {
|
|
if (path === "linuxcnc_ini.wasm") {
|
|
return "../../runtime/ui/ini-panel/linuxcnc_ini.wasm";
|
|
}
|
|
return path;
|
|
},
|
|
print() {},
|
|
printErr(message) {
|
|
console.error(message);
|
|
},
|
|
});
|
|
|
|
const namedParamIniPath = "/work/namedparams.ini";
|
|
interp.writeTextFile(namedParamIniPath, await fetchText("../fixtures/ini/namedparams.ini"));
|
|
|
|
verifyExpectedOutput(
|
|
"probe_init_and_synch",
|
|
interp.probeInitAndSynch(),
|
|
[
|
|
"init=0",
|
|
"setup.length_units=2",
|
|
"setup.origin_index=1",
|
|
"setup.distance_mode=0",
|
|
"setup.feed_mode=0",
|
|
"setup.motion_mode=800",
|
|
"canon_event=INIT_CANON",
|
|
"canon_event=USE_LENGTH_UNITS units=2",
|
|
"canon_event=SET_G5X_OFFSET index=1",
|
|
"canon_event=SET_G92_OFFSET x=0 y=0 z=0",
|
|
"canon_event=SET_XY_ROTATION rotation=0",
|
|
"canon_event=SET_FEED_REFERENCE reference=2",
|
|
"inch_init=0",
|
|
"inch_setup.length_units=1",
|
|
"inch_external_length_units=0.0393701",
|
|
"inch_canon_event=USE_LENGTH_UNITS units=1",
|
|
"synch=0",
|
|
"synch.current_pocket=2",
|
|
"synch.selected_pocket=2",
|
|
"synch.tool_0=2",
|
|
"synch.tool_2=2",
|
|
].join("\n"),
|
|
);
|
|
|
|
verifyExpectedOutput(
|
|
"probe_indexer",
|
|
interp.probeIndexer(),
|
|
[
|
|
"execute=0",
|
|
"post_a=90",
|
|
"canon_event=SET_MOTION_CONTROL_MODE mode=2 tolerance=0",
|
|
"canon_event=UNLOCK_ROTARY line=1 joint=0",
|
|
"canon_event=STRAIGHT_TRAVERSE line=1 x=0 y=0 z=0 a=90 b=0 c=0 u=0 v=0 w=0",
|
|
"canon_event=LOCK_ROTARY line=1 joint=0",
|
|
"canon_event=SET_MOTION_CONTROL_MODE mode=1 tolerance=0",
|
|
"canon_event=SET_NAIVECAM_TOLERANCE tolerance=0",
|
|
"canon_event=UPDATE_TAG line=1",
|
|
].join("\n"),
|
|
);
|
|
|
|
verifyExpectedOutput(
|
|
"probe_named_parameters",
|
|
interp.probeNamedParameters(namedParamIniPath),
|
|
[
|
|
"init_named_parameters=0",
|
|
"global_named_count=57",
|
|
"_metric_machine: rc=0 found=1 value=1",
|
|
"_motion_mode: rc=0 found=1 value=10",
|
|
"_metric: rc=0 found=1 value=1",
|
|
"_feed: rc=0 found=1 value=123.45",
|
|
"_rpm: rc=0 found=1 value=678.9",
|
|
"_x: rc=0 found=1 value=1.25",
|
|
"_current_tool: rc=0 found=1 value=12",
|
|
"_ini[traj]max_linear_velocity: rc=0 found=1 value=35",
|
|
"_hal[standalone.pin-bit]: rc=0 found=1 value=1",
|
|
"_hal[standalone.signal-float]: rc=0 found=1 value=98.25",
|
|
"_hal[standalone.param-s32]: rc=0 found=1 value=-17",
|
|
"_hal[standalone.pin-u32]: rc=0 found=1 value=1.23457e+08",
|
|
"_hal[standalone.signal-s64]: rc=0 found=1 value=-9e+09",
|
|
"_hal[standalone.param-u64]: rc=0 found=1 value=9e+09",
|
|
"_hal[standalone.disconnected-float]: rc=0 found=1 value=12.5",
|
|
"_hal[standalone.missing]: rc=0 found=0 value=0",
|
|
].join("\n"),
|
|
);
|
|
|
|
for (const fixtureName of INTERP_BROWSER_MDI_FIXTURES) {
|
|
const programText = await fetchText(`../fixtures/gcode/${fixtureName}.ngc`);
|
|
const expectedText = await fetchText(`../fixtures/canon/${fixtureName}.events`);
|
|
verifyExpectedOutput(fixtureName, interp.runProgram(programText), expectedText.trimEnd());
|
|
}
|
|
|
|
for (const errorFixtureName of INTERP_ERROR_FIXTURES) {
|
|
verifyExpectedOutput(
|
|
errorFixtureName,
|
|
interp.runProgram(await fetchText(`../fixtures/gcode_errors/${errorFixtureName}.ngc`)),
|
|
(await fetchText(`../fixtures/canon_errors/${errorFixtureName}.expected`)).trimEnd(),
|
|
);
|
|
}
|
|
|
|
for (const errorFixtureName of INTERP_ERROR_FIXTURES) {
|
|
const programPath = `/work/${errorFixtureName}-error.ngc`;
|
|
interp.writeTextFile(
|
|
programPath,
|
|
await fetchText(`../fixtures/gcode_errors/${errorFixtureName}.ngc`),
|
|
);
|
|
verifyExpectedFileError(
|
|
`${errorFixtureName}_file`,
|
|
interp.runFile(programPath),
|
|
(await fetchText(`../fixtures/canon_errors/${errorFixtureName}.expected`)).trimEnd(),
|
|
);
|
|
}
|
|
|
|
const namedParamProgramText = await fetchText(
|
|
`../fixtures/gcode/${INTERP_INI_FIXTURE}.ngc`,
|
|
);
|
|
const namedParamExpectedText = (
|
|
await fetchText(`../fixtures/canon/${INTERP_INI_FIXTURE}.events`)
|
|
).trimEnd();
|
|
verifyExpectedOutput(
|
|
INTERP_INI_FIXTURE,
|
|
interp.runProgramWithIni(namedParamProgramText, namedParamIniPath),
|
|
namedParamExpectedText,
|
|
);
|
|
|
|
const positionParamsText = await fetchText(
|
|
`../fixtures/gcode/${INTERP_POSITION_PARAMS_FILE_FIXTURE}.ngc`,
|
|
);
|
|
const positionParamsPath = `/work/${INTERP_POSITION_PARAMS_FILE_FIXTURE}.ngc`;
|
|
interp.writeTextFile(positionParamsPath, positionParamsText);
|
|
verifyExpectedOutput(
|
|
`${INTERP_POSITION_PARAMS_FILE_FIXTURE}_file`,
|
|
interp.runFile(positionParamsPath),
|
|
(
|
|
await fetchText(
|
|
`../fixtures/canon_file/${INTERP_POSITION_PARAMS_FILE_FIXTURE}.events`,
|
|
)
|
|
).trimEnd(),
|
|
);
|
|
|
|
for (const fileFixtureName of INTERP_BROWSER_FILE_FIXTURES) {
|
|
const programPath = `/work/${fileFixtureName}.ngc`;
|
|
interp.writeTextFile(programPath, await fetchText(`../fixtures/gcode/${fileFixtureName}.ngc`));
|
|
verifyExpectedOutput(
|
|
`${fileFixtureName}_file`,
|
|
interp.runFile(programPath),
|
|
(await fetchText(`../fixtures/canon/${fileFixtureName}.events`)).trimEnd(),
|
|
);
|
|
}
|
|
|
|
const namedParamPath = `/work/${INTERP_INI_FIXTURE}.ngc`;
|
|
interp.writeTextFile(namedParamPath, namedParamProgramText);
|
|
verifyExpectedOutput(
|
|
`${INTERP_INI_FIXTURE}_file`,
|
|
interp.runFileWithIni(namedParamPath, namedParamIniPath),
|
|
namedParamExpectedText,
|
|
);
|
|
|
|
verifyExpectedOutput(
|
|
"restore_parameters_missing_file",
|
|
interp.restoreParameters("/work/browser-missing.var"),
|
|
"restore_parameters=0",
|
|
);
|
|
const outOfOrderParameterFilePath = "/work/browser-out-of-order.var";
|
|
interp.writeTextFile(outOfOrderParameterFilePath, "5220 1\n5161 2\n");
|
|
verifyExpectedOutput(
|
|
"restore_parameters_out_of_order",
|
|
interp.restoreParameters(outOfOrderParameterFilePath),
|
|
[
|
|
"restore_parameters=5",
|
|
"restore_error_text=Parameter file out of order",
|
|
].join("\n"),
|
|
);
|
|
|
|
const missingRequiredParameterFilePath = "/work/browser-missing-required.var";
|
|
interp.writeTextFile(missingRequiredParameterFilePath, "5161 3.5\n5220 1\n");
|
|
verifyExpectedOutput(
|
|
"restore_parameters_missing_required",
|
|
interp.restoreParameters(missingRequiredParameterFilePath),
|
|
[
|
|
"restore_parameters=0",
|
|
"parameter_5161=3.5",
|
|
"parameter_5162=0",
|
|
].join("\n"),
|
|
);
|
|
|
|
await saveMachineTextFiles("browser-interp", {
|
|
ini: "[EMC]\nMACHINE = browser-interp\n",
|
|
toolTable: "T2 P7 Z3.125 D1.5 I12 J34 Q4 ;browser finish tool\n",
|
|
parameters: [
|
|
"5161 10.5",
|
|
"5162 20.25",
|
|
"5220 1",
|
|
"5221 2.25",
|
|
"5399 44",
|
|
"<_named_param> 123",
|
|
"",
|
|
].join("\n"),
|
|
});
|
|
const loadedSession = await loadMachineSessionFromOpfs(
|
|
interp,
|
|
"browser-interp",
|
|
{
|
|
iniWasmPath: "/work/browser-machine.ini",
|
|
parameterWasmPath: "/work/browser-linuxcnc.var",
|
|
toolTableWasmPath: "/work/browser-tool.tbl",
|
|
},
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_restore_parameters",
|
|
loadedSession.parameters.result,
|
|
[
|
|
"restore_parameters=0",
|
|
"parameter_5161=10.5",
|
|
"parameter_5162=20.25",
|
|
"parameter_5221=2.25",
|
|
"parameter_5399=44",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_load_tool_table",
|
|
loadedSession.toolTable.result,
|
|
[
|
|
"tooldata_load=0",
|
|
"tool_1.toolno=2",
|
|
"tool_1.pocketno=7",
|
|
"tool_1.z=3.125",
|
|
"tool_1.diameter=1.5",
|
|
"tool_1.frontangle=12",
|
|
"tool_1.backangle=34",
|
|
"tool_1.orientation=4",
|
|
"tool_1.comment=browser finish tool",
|
|
"tool_index_for_tool_2=1",
|
|
].join("\n"),
|
|
);
|
|
const savedParameters = await saveMachineParametersToOpfs(
|
|
interp,
|
|
"browser-interp",
|
|
{
|
|
5161: 12.34,
|
|
5162: 56.78,
|
|
5220: 1.0,
|
|
5221: 9.87,
|
|
5399: 66.6,
|
|
},
|
|
{ wasmPath: "/work/browser-linuxcnc.var" },
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_save_parameters",
|
|
savedParameters.result,
|
|
[
|
|
"save_parameters=0",
|
|
"parameter_5161=12.34",
|
|
"parameter_5162=56.78",
|
|
"parameter_5221=9.87",
|
|
"parameter_5399=66.6",
|
|
].join("\n"),
|
|
);
|
|
const machineFiles = await loadMachineTextFiles("browser-interp");
|
|
verifyExpectedOutput(
|
|
"opfs_saved_parameter_text",
|
|
machineFiles.parameters,
|
|
[
|
|
"5161\t12.340000",
|
|
"5162\t56.780000",
|
|
"5221\t9.870000",
|
|
"5399\t66.600000",
|
|
"absent=<_named_param>",
|
|
].join("\n"),
|
|
);
|
|
if (
|
|
savedParameters.backupOpfsPath !==
|
|
"linuxcnc/machines/browser-interp/linuxcnc.var.bak"
|
|
) {
|
|
throw new Error(`unexpected parameter backup path: ${savedParameters.backupOpfsPath}`);
|
|
}
|
|
verifyExpectedOutput(
|
|
"opfs_saved_parameter_backup_text",
|
|
await loadTextFile(savedParameters.backupOpfsPath),
|
|
[
|
|
"5161 10.5",
|
|
"5162 20.25",
|
|
"5221 2.25",
|
|
"5399 44",
|
|
"<_named_param> 123",
|
|
].join("\n"),
|
|
);
|
|
const savedToolTable = await saveMachineToolTableToOpfs(
|
|
interp,
|
|
"browser-interp",
|
|
{ wasmPath: "/work/browser-tool.tbl" },
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_save_tool_table",
|
|
savedToolTable.result,
|
|
[
|
|
"tooldata_save=0",
|
|
"tool_1.toolno=2",
|
|
"tool_1.pocketno=7",
|
|
].join("\n"),
|
|
);
|
|
const savedMachineFiles = await loadMachineTextFiles("browser-interp");
|
|
verifyExpectedOutput(
|
|
"opfs_saved_tool_table_text",
|
|
savedMachineFiles.toolTable,
|
|
[
|
|
"T2",
|
|
"P7",
|
|
"Z+3.125000",
|
|
"D+1.500000",
|
|
"I+12.000000",
|
|
"J+34.000000",
|
|
"Q4",
|
|
";browser finish tool",
|
|
].join("\n"),
|
|
);
|
|
|
|
await saveMachineTextFiles("browser-random-toolchanger", {
|
|
ini: [
|
|
"[EMC]",
|
|
"MACHINE = browser-random-toolchanger",
|
|
"",
|
|
"[EMCIO]",
|
|
"RANDOM_TOOLCHANGER = yes",
|
|
"",
|
|
].join("\n"),
|
|
toolTable: [
|
|
"T2 P7 Z3.125 D1.5 I12 J34 Q4 ;browser random finish tool",
|
|
"T5 P9 X1 Y2 Z3 ;browser random rough tool",
|
|
"",
|
|
].join("\n"),
|
|
parameters: [
|
|
"5161 10.5",
|
|
"5162 20.25",
|
|
"5220 1",
|
|
"5221 2.25",
|
|
"5399 44",
|
|
"",
|
|
].join("\n"),
|
|
});
|
|
const loadedRandomSession = await loadMachineSessionFromOpfs(
|
|
interp,
|
|
"browser-random-toolchanger",
|
|
{
|
|
iniSdk: ini,
|
|
iniWasmPath: "/work/browser-random-machine.ini",
|
|
parameterWasmPath: "/work/browser-random-linuxcnc.var",
|
|
toolTableWasmPath: "/work/browser-random-tool.tbl",
|
|
},
|
|
);
|
|
if (
|
|
loadedRandomSession.parameters.opfsPath !==
|
|
"linuxcnc/machines/browser-random-toolchanger/linuxcnc.var"
|
|
) {
|
|
throw new Error(`unexpected default parameter path: ${loadedRandomSession.parameters.opfsPath}`);
|
|
}
|
|
if (
|
|
loadedRandomSession.toolTable.opfsPath !==
|
|
"linuxcnc/machines/browser-random-toolchanger/tool.tbl"
|
|
) {
|
|
throw new Error(`unexpected default tool path: ${loadedRandomSession.toolTable.opfsPath}`);
|
|
}
|
|
verifyExpectedOutput(
|
|
"opfs_load_random_tool_table",
|
|
loadedRandomSession.toolTable.result,
|
|
[
|
|
"tooldata_random_toolchanger=1",
|
|
"tooldata_load=0",
|
|
"tool_pocket_7.toolno=2",
|
|
"tool_pocket_7.pocketno=7",
|
|
"tool_pocket_7.z=3.125",
|
|
"tool_pocket_7.diameter=1.5",
|
|
"tool_pocket_7.frontangle=12",
|
|
"tool_pocket_7.backangle=34",
|
|
"tool_pocket_7.orientation=4",
|
|
"tool_pocket_7.comment=browser random finish tool",
|
|
"tool_pocket_9.toolno=5",
|
|
"tool_pocket_9.pocketno=9",
|
|
"tool_index_for_tool_2=7",
|
|
].join("\n"),
|
|
);
|
|
const savedRandomToolTable = await saveMachineToolTableToOpfs(
|
|
interp,
|
|
"browser-random-toolchanger",
|
|
{ wasmPath: "/work/browser-random-tool.tbl" },
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_save_random_tool_table",
|
|
savedRandomToolTable.result,
|
|
[
|
|
"tooldata_save=0",
|
|
"tool_pocket_7.toolno=2",
|
|
"tool_pocket_9.toolno=5",
|
|
].join("\n"),
|
|
);
|
|
const savedRandomMachineFiles = await loadMachineTextFiles(
|
|
"browser-random-toolchanger",
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_saved_random_tool_table_text",
|
|
savedRandomMachineFiles.toolTable,
|
|
[
|
|
"T2",
|
|
"P7",
|
|
";browser random finish tool",
|
|
"T5",
|
|
"P9",
|
|
";browser random rough tool",
|
|
].join("\n"),
|
|
);
|
|
|
|
await saveMachineTextFiles("browser-ini-file-session", {
|
|
ini: [
|
|
"[EMC]",
|
|
"MACHINE = browser-ini-file-session",
|
|
"",
|
|
"[RS274NGC]",
|
|
"PARAMETER_FILE = browser-custom.var",
|
|
"",
|
|
"[EMCIO]",
|
|
"TOOL_TABLE = browser-custom-tool.tbl",
|
|
"",
|
|
].join("\n"),
|
|
});
|
|
await saveTextFile(
|
|
"linuxcnc/machines/browser-ini-file-session/browser-custom.var",
|
|
[
|
|
"5161 31.25",
|
|
"5162 62.5",
|
|
"5220 1",
|
|
"5221 4.5",
|
|
"5399 99",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
await saveTextFile(
|
|
"linuxcnc/machines/browser-ini-file-session/browser-custom-tool.tbl",
|
|
"T8 P8 Z4.5 D0.5 ;browser custom tool\n",
|
|
);
|
|
const loadedIniFileSession = await loadMachineSessionFromOpfs(
|
|
interp,
|
|
"browser-ini-file-session",
|
|
{
|
|
iniSdk: ini,
|
|
iniWasmPath: "/work/browser-ini-file-session.ini",
|
|
parameterWasmPath: "/work/browser-custom.var",
|
|
toolTableWasmPath: "/work/browser-custom-tool.tbl",
|
|
},
|
|
);
|
|
if (
|
|
loadedIniFileSession.parameters.opfsPath !==
|
|
"linuxcnc/machines/browser-ini-file-session/browser-custom.var"
|
|
) {
|
|
throw new Error(`unexpected custom parameter path: ${loadedIniFileSession.parameters.opfsPath}`);
|
|
}
|
|
if (
|
|
loadedIniFileSession.toolTable.opfsPath !==
|
|
"linuxcnc/machines/browser-ini-file-session/browser-custom-tool.tbl"
|
|
) {
|
|
throw new Error(`unexpected custom tool path: ${loadedIniFileSession.toolTable.opfsPath}`);
|
|
}
|
|
verifyExpectedOutput(
|
|
"opfs_load_ini_named_parameter_file",
|
|
loadedIniFileSession.parameters.result,
|
|
[
|
|
"restore_parameters=0",
|
|
"parameter_5161=31.25",
|
|
"parameter_5162=62.5",
|
|
"parameter_5221=4.5",
|
|
"parameter_5399=99",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_load_ini_named_tool_table",
|
|
loadedIniFileSession.toolTable.result,
|
|
[
|
|
"tooldata_load=0",
|
|
"tool_1.toolno=8",
|
|
"tool_1.pocketno=8",
|
|
"tool_1.z=4.5",
|
|
"tool_1.diameter=0.5",
|
|
"tool_1.comment=browser custom tool",
|
|
].join("\n"),
|
|
);
|
|
const savedIniNamedToolTable = await saveMachineToolTableToOpfs(
|
|
interp,
|
|
"browser-ini-file-session",
|
|
{
|
|
opfsPath: loadedIniFileSession.toolTable.opfsPath,
|
|
wasmPath: loadedIniFileSession.toolTable.wasmPath,
|
|
},
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_save_ini_named_tool_table",
|
|
savedIniNamedToolTable.result,
|
|
[
|
|
"tooldata_save=0",
|
|
"tool_1.toolno=8",
|
|
"tool_1.pocketno=8",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_saved_ini_named_tool_table_text",
|
|
await loadTextFile(loadedIniFileSession.toolTable.opfsPath),
|
|
[
|
|
"T8",
|
|
"P8",
|
|
"Z+4.500000",
|
|
"D+0.500000",
|
|
";browser custom tool",
|
|
].join("\n"),
|
|
);
|
|
|
|
await saveMachineTextFiles("browser-ini-override-session", {
|
|
ini: [
|
|
"[EMC]",
|
|
"MACHINE = browser-ini-override-session",
|
|
"",
|
|
"[RS274NGC]",
|
|
"PARAMETER_FILE = browser-ignored.var",
|
|
"",
|
|
"[EMCIO]",
|
|
"TOOL_TABLE = browser-ignored-tool.tbl",
|
|
"",
|
|
].join("\n"),
|
|
});
|
|
await saveTextFile(
|
|
"linuxcnc/machines/browser-ini-override-session/browser-explicit.var",
|
|
[
|
|
"5161 41.25",
|
|
"5162 82.5",
|
|
"5220 1",
|
|
"5221 6.5",
|
|
"5399 101",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
await saveTextFile(
|
|
"linuxcnc/machines/browser-ini-override-session/browser-explicit-tool.tbl",
|
|
"T9 P9 Z5.5 D0.625 ;browser explicit tool\n",
|
|
);
|
|
const loadedIniOverrideSession = await loadMachineSessionFromOpfs(
|
|
interp,
|
|
"browser-ini-override-session",
|
|
{
|
|
iniSdk: ini,
|
|
iniWasmPath: "/work/browser-ini-override-session.ini",
|
|
parameterFilename: "browser-explicit.var",
|
|
parameterWasmPath: "/work/browser-explicit.var",
|
|
toolTableFilename: "browser-explicit-tool.tbl",
|
|
toolTableWasmPath: "/work/browser-explicit-tool.tbl",
|
|
},
|
|
);
|
|
if (
|
|
loadedIniOverrideSession.parameters.opfsPath !==
|
|
"linuxcnc/machines/browser-ini-override-session/browser-explicit.var"
|
|
) {
|
|
throw new Error(`unexpected explicit parameter path: ${loadedIniOverrideSession.parameters.opfsPath}`);
|
|
}
|
|
if (
|
|
loadedIniOverrideSession.toolTable.opfsPath !==
|
|
"linuxcnc/machines/browser-ini-override-session/browser-explicit-tool.tbl"
|
|
) {
|
|
throw new Error(`unexpected explicit tool path: ${loadedIniOverrideSession.toolTable.opfsPath}`);
|
|
}
|
|
verifyExpectedOutput(
|
|
"opfs_load_explicit_parameter_file",
|
|
loadedIniOverrideSession.parameters.result,
|
|
[
|
|
"restore_parameters=0",
|
|
"parameter_5161=41.25",
|
|
"parameter_5162=82.5",
|
|
"parameter_5221=6.5",
|
|
"parameter_5399=101",
|
|
].join("\n"),
|
|
);
|
|
verifyExpectedOutput(
|
|
"opfs_load_explicit_tool_table",
|
|
loadedIniOverrideSession.toolTable.result,
|
|
[
|
|
"tooldata_load=0",
|
|
"tool_1.toolno=9",
|
|
"tool_1.pocketno=9",
|
|
"tool_1.z=5.5",
|
|
"tool_1.diameter=0.625",
|
|
"tool_1.comment=browser explicit tool",
|
|
].join("\n"),
|
|
);
|
|
|
|
await saveMachineTextFiles("browser-invalid-param-file-session", {
|
|
ini: [
|
|
"[EMC]",
|
|
"MACHINE = browser-invalid-param-file-session",
|
|
"",
|
|
"[RS274NGC]",
|
|
"PARAMETER_FILE = ../escape.var",
|
|
"",
|
|
].join("\n"),
|
|
});
|
|
await verifyRejects(
|
|
"opfs_reject_invalid_ini_parameter_file",
|
|
() => loadMachineSessionFromOpfs(
|
|
interp,
|
|
"browser-invalid-param-file-session",
|
|
{
|
|
iniSdk: ini,
|
|
iniWasmPath: "/work/browser-invalid-param-file-session.ini",
|
|
},
|
|
),
|
|
/Invalid parameter filename/,
|
|
);
|
|
|
|
await saveMachineTextFiles("browser-invalid-tool-file-session", {
|
|
ini: [
|
|
"[EMC]",
|
|
"MACHINE = browser-invalid-tool-file-session",
|
|
"",
|
|
"[EMCIO]",
|
|
"TOOL_TABLE = nested/tool.tbl",
|
|
"",
|
|
].join("\n"),
|
|
});
|
|
await verifyRejects(
|
|
"opfs_reject_invalid_ini_tool_table",
|
|
() => loadMachineSessionFromOpfs(
|
|
interp,
|
|
"browser-invalid-tool-file-session",
|
|
{
|
|
iniSdk: ini,
|
|
iniWasmPath: "/work/browser-invalid-tool-file-session.ini",
|
|
},
|
|
),
|
|
/Invalid tool table filename/,
|
|
);
|
|
|
|
status.textContent = "browser_interp_smoke=ok";
|
|
} catch (error) {
|
|
status.textContent = `browser_interp_smoke=fail ${error.stack || error.message}`;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|