按规划继续工作
结论:补齐 INI 派生参数文件和刀具表 OPFS 会话加载,扩大浏览器解释器 file-path fixture 覆盖,并通过 host/WASM/browser 聚合验证。
This commit is contained in:
@@ -14,6 +14,9 @@
|
||||
import {
|
||||
saveMachineParametersToOpfs,
|
||||
} from "../../runtime/opfs/linuxcnc-parameter-bridge.js";
|
||||
import {
|
||||
saveTextFile,
|
||||
} from "../../runtime/opfs/file-service.js";
|
||||
import {
|
||||
saveMachineToolTableToOpfs,
|
||||
} from "../../runtime/opfs/linuxcnc-tool-table-bridge.js";
|
||||
@@ -323,6 +326,80 @@
|
||||
].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"),
|
||||
);
|
||||
|
||||
status.textContent = "browser_interp_smoke=ok";
|
||||
} catch (error) {
|
||||
status.textContent = `browser_interp_smoke=fail ${error.stack || error.message}`;
|
||||
|
||||
@@ -70,11 +70,7 @@ export const INTERP_FILE_FIXTURES = [
|
||||
"oword_subroutine",
|
||||
];
|
||||
|
||||
export const INTERP_BROWSER_FILE_FIXTURES = [
|
||||
"file_open_reset",
|
||||
"percent_file_finish",
|
||||
"oword_subroutine",
|
||||
];
|
||||
export const INTERP_BROWSER_FILE_FIXTURES = INTERP_FILE_FIXTURES;
|
||||
|
||||
export const INTERP_INI_FIXTURE = "namedparam_semantics";
|
||||
export const INTERP_POSITION_PARAMS_FILE_FIXTURE = "position_params";
|
||||
|
||||
@@ -201,6 +201,23 @@ const bridgeIniSdk = {
|
||||
writeTextFile(path, text) {
|
||||
bridgeFiles.set(`ini:${path}`, text);
|
||||
},
|
||||
getString(path, section, tag) {
|
||||
if (
|
||||
path === "/work/ini-file-session.ini" &&
|
||||
section === "RS274NGC" &&
|
||||
tag === "PARAMETER_FILE"
|
||||
) {
|
||||
return "custom.var";
|
||||
}
|
||||
if (
|
||||
path === "/work/ini-file-session.ini" &&
|
||||
section === "EMCIO" &&
|
||||
tag === "TOOL_TABLE"
|
||||
) {
|
||||
return "custom-tool.tbl";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
getBool(path, section, tag) {
|
||||
if (
|
||||
path === "/work/ini-derived-session.ini" &&
|
||||
@@ -350,6 +367,55 @@ assert.equal(
|
||||
"tooldata_load=0\nload_tool_path=/work/ini-derived-session-tool.tbl\nrandom_toolchanger=1\n",
|
||||
);
|
||||
|
||||
await saveMachineTextFiles("ini-file-session", {
|
||||
ini: [
|
||||
"[EMC]",
|
||||
"MACHINE = ini-file-session",
|
||||
"",
|
||||
"[RS274NGC]",
|
||||
"PARAMETER_FILE = custom.var",
|
||||
"",
|
||||
"[EMCIO]",
|
||||
"TOOL_TABLE = custom-tool.tbl",
|
||||
"",
|
||||
].join("\n"),
|
||||
}, { storage });
|
||||
await saveTextFile(
|
||||
"linuxcnc/machines/ini-file-session/custom.var",
|
||||
"5161 77.0\n5162 88.0\n",
|
||||
storage,
|
||||
);
|
||||
await saveTextFile(
|
||||
"linuxcnc/machines/ini-file-session/custom-tool.tbl",
|
||||
"T8 P8 Z4.5 D0.5\n",
|
||||
storage,
|
||||
);
|
||||
const loadedIniFileSession = await loadMachineSessionFromOpfs(
|
||||
bridgeInterp,
|
||||
"ini-file-session",
|
||||
{
|
||||
storage,
|
||||
iniSdk: bridgeIniSdk,
|
||||
iniWasmPath: "/work/ini-file-session.ini",
|
||||
parameterWasmPath: "/work/ini-file-session.var",
|
||||
toolTableWasmPath: "/work/ini-file-session-tool.tbl",
|
||||
},
|
||||
);
|
||||
assert.equal(
|
||||
loadedIniFileSession.parameters.opfsPath,
|
||||
"linuxcnc/machines/ini-file-session/custom.var",
|
||||
);
|
||||
assert.equal(
|
||||
loadedIniFileSession.toolTable.opfsPath,
|
||||
"linuxcnc/machines/ini-file-session/custom-tool.tbl",
|
||||
);
|
||||
assert.equal(bridgeFiles.get("/work/ini-file-session.var"), "5161 77.0\n5162 88.0\n");
|
||||
assert.equal(bridgeFiles.get("/work/ini-file-session-tool.tbl"), "T8 P8 Z4.5 D0.5\n");
|
||||
assert.equal(
|
||||
loadedIniFileSession.toolTable.result,
|
||||
"tooldata_load=0\nload_tool_path=/work/ini-file-session-tool.tbl\nrandom_toolchanger=0\n",
|
||||
);
|
||||
|
||||
await assert.rejects(
|
||||
() => loadTextFile("linuxcnc/machines/missing.ini", storage),
|
||||
/missing file/,
|
||||
|
||||
Reference in New Issue
Block a user