按建议,继续完成后续工作

结论:已新增 OPFS machine file store,支持 INI、tool table、parameter file 和 G-code 的纯文本保存/读取,并在 Node mock 与 Chromium smoke 中验证往返,不引入 CNC 文件格式语义。
This commit is contained in:
2026-06-08 03:34:24 +08:00
parent 72215f8400
commit 1a10e4f260
6 changed files with 114 additions and 9 deletions

View File

@@ -14,6 +14,12 @@
loadSessionSnapshot,
saveSessionSnapshot,
} from "../../runtime/opfs/snapshot-store.js";
import {
loadGcodeProgram,
loadMachineTextFiles,
saveGcodeProgram,
saveMachineTextFiles,
} from "../../runtime/opfs/machine-file-store.js";
const status = document.getElementById("status");
@@ -72,6 +78,18 @@ JOINTS = 3
assertEqual(loadedSnapshot.payload.files.ini, opfsPath, "snapshot payload");
assertEqual(loadedSnapshot.metadata.source, "browser-smoke", "snapshot metadata");
await saveMachineTextFiles("browser-smoke", {
ini: iniText,
toolTable: "T0 P0 ; no tool\n",
parameters: "5161 0.0\n",
});
const machineFiles = await loadMachineTextFiles("browser-smoke");
assertEqual(machineFiles.ini, iniText, "machine ini text");
assertEqual(machineFiles.toolTable, "T0 P0 ; no tool\n", "tool table text");
assertEqual(machineFiles.parameters, "5161 0.0\n", "parameter text");
await saveGcodeProgram("browser-smoke.ngc", "G0 X0 Y0\nM2\n");
assertEqual(await loadGcodeProgram("browser-smoke.ngc"), "G0 X0 Y0\nM2\n", "gcode text");
status.textContent = "browser_ini_opfs_smoke=ok";
} catch (error) {
status.textContent = `browser_ini_opfs_smoke=fail ${error.stack || error.message}`;