推进 INI 面板快照 G-code 运行选择
This commit is contained in:
61
text10.txt
61
text10.txt
@@ -611,3 +611,64 @@ host_wasm_opfs_browser_smokes=ok
|
|||||||
`GCODE_FILENAME` 收敛为“优先使用已恢复 snapshot 中的 G-code OPFS path,否则回退默认
|
`GCODE_FILENAME` 收敛为“优先使用已恢复 snapshot 中的 G-code OPFS path,否则回退默认
|
||||||
G-code”,并在 browser smoke 中验证 restore-and-load 后运行的程序来自 snapshot 文件清单。
|
G-code”,并在 browser smoke 中验证 restore-and-load 后运行的程序来自 snapshot 文件清单。
|
||||||
仍只做 OPFS/session/UI 编排,不解析或改写 G-code 语义。
|
仍只做 OPFS/session/UI 编排,不解析或改写 G-code 语义。
|
||||||
|
|
||||||
|
七、2026-06-14 继续执行记录:INI panel snapshot G-code run selection
|
||||||
|
|
||||||
|
本轮继续推进 browser/UI workflow 的实质能力,让 `Run G-code` 使用已恢复 machine
|
||||||
|
session snapshot 中的 G-code 文件清单,而不是始终只使用固定默认 filename。
|
||||||
|
|
||||||
|
完成内容:
|
||||||
|
|
||||||
|
- 在 `wasm-port/runtime/ui/ini-panel/app.js` 新增 `restoredSessionSnapshot` 状态,用于
|
||||||
|
保存最近一次 checked snapshot restore 结果;
|
||||||
|
- 新增 `gcodeFilenameFromSnapshotPath(...)`,将 snapshot 中的
|
||||||
|
`linuxcnc/gcode/<filename>` OPFS path 转成 `loadGcodeProgram(...)` 需要的 filename;
|
||||||
|
- 新增 `loadSelectedGcodeProgram()`:
|
||||||
|
- 优先读取 restored snapshot payload 中的 G-code OPFS path;
|
||||||
|
- 无 restored snapshot 或无 G-code path 时回退默认 `GCODE_FILENAME`;
|
||||||
|
- 仍通过既有 OPFS G-code store 读取文本;
|
||||||
|
- `Run G-code` 改为使用 selected program,并在日志中记录
|
||||||
|
`OPFS path -> WASM path`;
|
||||||
|
- `Session G-code` 字段在运行后保留 OPFS path,明确反映用户流程使用的 snapshot
|
||||||
|
文件清单;
|
||||||
|
- browser INI panel smoke 验证 restore-and-load 后运行的程序来自
|
||||||
|
`linuxcnc/gcode/ui-session.ngc`,并继续验证 LinuxCNC canonical events 与 run monitor;
|
||||||
|
- 未改变 G-code 文本内容、interpreter run API、canonical-event 解析、OPFS path model
|
||||||
|
或 LinuxCNC-owned runtime semantics。
|
||||||
|
|
||||||
|
验证已通过:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git diff --check
|
||||||
|
SKIP_INI_BUILD=1 SKIP_INTERP_BUILD=1 wasm-port/tests/browser/verify_ini_panel_browser.sh
|
||||||
|
wasm-port/tests/opfs/node/verify_file_service.sh
|
||||||
|
wasm-port/tools/verify_vendor_sync.sh
|
||||||
|
wasm-port/tools/verify_no_standalone_cnc_semantics.sh
|
||||||
|
SKIP_INTERP_BUILD=1 wasm-port/tests/wasm/node/verify_interp_wasm.sh
|
||||||
|
SKIP_INTERP_BUILD=1 wasm-port/tests/wasm/node/verify_sim_configs_inventory_wasm.sh
|
||||||
|
SKIP_INI_BUILD=1 SKIP_INTERP_BUILD=1 wasm-port/tests/browser/verify_interp_browser.sh
|
||||||
|
wasm-port/tests/host/verify_host_smokes.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
关键输出:
|
||||||
|
|
||||||
|
```text
|
||||||
|
browser_ini_opfs_smoke=ok
|
||||||
|
opfs_file_service_node_smoke=ok
|
||||||
|
vendor sync up to date
|
||||||
|
standalone CNC semantics guard complete
|
||||||
|
interp_wasm_node_smoke=ok
|
||||||
|
sim_configs_wasm_node_inventory_executed=28
|
||||||
|
sim_configs_wasm_node_inventory_passed=28
|
||||||
|
sim_configs_wasm_node_inventory_skipped=131
|
||||||
|
sim_configs_wasm_node_inventory_unexpected_fail=0
|
||||||
|
browser_interp_smoke=ok
|
||||||
|
host_wasm_opfs_browser_smokes=ok
|
||||||
|
```
|
||||||
|
|
||||||
|
下一步建议:
|
||||||
|
|
||||||
|
继续沿 UI workflow 做实质推进。优先补 fallback 覆盖:在 browser smoke 中增加不恢复
|
||||||
|
snapshot、只保存 machine files 并 `Load Machine Session` 后运行 G-code 的路径,验证
|
||||||
|
`Run G-code` 会回退默认 `linuxcnc/gcode/ui-session.ngc` 且保持 canonical-event flow。
|
||||||
|
仍只做 OPFS/session/UI 编排,不解析或改写 G-code 语义。
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ const fields = {
|
|||||||
let iniSdk = null;
|
let iniSdk = null;
|
||||||
let interpSdk = null;
|
let interpSdk = null;
|
||||||
let loadedSession = null;
|
let loadedSession = null;
|
||||||
|
let restoredSessionSnapshot = null;
|
||||||
let canonicalEventText = "";
|
let canonicalEventText = "";
|
||||||
let runPlaybackTimer = null;
|
let runPlaybackTimer = null;
|
||||||
|
|
||||||
@@ -310,6 +311,26 @@ function syncEditorToWasmFs() {
|
|||||||
requireIniSdk().writeTextFile(WASM_FILE, editor.value);
|
requireIniSdk().writeTextFile(WASM_FILE, editor.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gcodeFilenameFromSnapshotPath(path) {
|
||||||
|
const prefix = "linuxcnc/gcode/";
|
||||||
|
if (typeof path !== "string" || !path.startsWith(prefix)) {
|
||||||
|
return GCODE_FILENAME;
|
||||||
|
}
|
||||||
|
const filename = path.slice(prefix.length);
|
||||||
|
return filename || GCODE_FILENAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadSelectedGcodeProgram() {
|
||||||
|
const opfsPath = restoredSessionSnapshot?.payload?.files?.gcode;
|
||||||
|
const filename = gcodeFilenameFromSnapshotPath(opfsPath);
|
||||||
|
return {
|
||||||
|
filename,
|
||||||
|
opfsPath: opfsPath ?? `linuxcnc/gcode/${filename}`,
|
||||||
|
wasmPath: GCODE_WASM_FILE,
|
||||||
|
text: await loadGcodeProgram(filename),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
async function restoreSessionSnapshotToEditor() {
|
async function restoreSessionSnapshotToEditor() {
|
||||||
const snapshot = await loadMachineSessionSnapshot(
|
const snapshot = await loadMachineSessionSnapshot(
|
||||||
SESSION_SNAPSHOT_ID,
|
SESSION_SNAPSHOT_ID,
|
||||||
@@ -323,6 +344,7 @@ async function restoreSessionSnapshotToEditor() {
|
|||||||
setField("sessionToolTable", snapshot.payload.files.toolTable);
|
setField("sessionToolTable", snapshot.payload.files.toolTable);
|
||||||
setField("sessionGcode", snapshot.payload.files.gcode);
|
setField("sessionGcode", snapshot.payload.files.gcode);
|
||||||
setField("sessionSnapshot", `${snapshot.sessionId}/${SESSION_SNAPSHOT_FILENAME}`);
|
setField("sessionSnapshot", `${snapshot.sessionId}/${SESSION_SNAPSHOT_FILENAME}`);
|
||||||
|
restoredSessionSnapshot = snapshot;
|
||||||
return snapshot;
|
return snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,21 +578,21 @@ document.getElementById("run-gcode").addEventListener("click", async () => {
|
|||||||
throw new Error("Load a machine session before running G-code.");
|
throw new Error("Load a machine session before running G-code.");
|
||||||
}
|
}
|
||||||
const interp = requireInterpSdk();
|
const interp = requireInterpSdk();
|
||||||
const programText = await loadGcodeProgram(GCODE_FILENAME);
|
const program = await loadSelectedGcodeProgram();
|
||||||
interp.writeTextFile(GCODE_WASM_FILE, programText);
|
interp.writeTextFile(program.wasmPath, program.text);
|
||||||
clearRunPlayback();
|
clearRunPlayback();
|
||||||
setField("runStatus", "running");
|
setField("runStatus", "running");
|
||||||
setRunMonitor(5, "running", {}, "running");
|
setRunMonitor(5, "running", {}, "running");
|
||||||
await nextFrame();
|
await nextFrame();
|
||||||
const result = interp.runFileWithIni(GCODE_WASM_FILE, loadedSession.ini.wasmPath);
|
const result = interp.runFileWithIni(program.wasmPath, loadedSession.ini.wasmPath);
|
||||||
setField("sessionGcode", GCODE_WASM_FILE);
|
setField("sessionGcode", program.opfsPath);
|
||||||
setField("runStatus", "ok");
|
setField("runStatus", "ok");
|
||||||
setCanonicalEvents(result.trim());
|
setCanonicalEvents(result.trim());
|
||||||
playRunMotion(result.trim(), programText);
|
playRunMotion(result.trim(), program.text);
|
||||||
setLog(
|
setLog(
|
||||||
[
|
[
|
||||||
"Ran G-code through LinuxCNC interpreter WASM.",
|
"Ran G-code through LinuxCNC interpreter WASM.",
|
||||||
`Program: ${GCODE_WASM_FILE}`,
|
`Program: ${program.opfsPath} -> ${program.wasmPath}`,
|
||||||
`INI: ${loadedSession.ini.wasmPath}`,
|
`INI: ${loadedSession.ini.wasmPath}`,
|
||||||
result.trim(),
|
result.trim(),
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
|
|||||||
@@ -455,8 +455,8 @@ TOOL_TABLE = browser-tool.tbl
|
|||||||
);
|
);
|
||||||
assertEqual(
|
assertEqual(
|
||||||
uiDocument.getElementById("field-session-gcode").textContent,
|
uiDocument.getElementById("field-session-gcode").textContent,
|
||||||
"/work/ui-session.ngc",
|
"linuxcnc/gcode/ui-session.ngc",
|
||||||
"UI session G-code path",
|
"UI session snapshot G-code path",
|
||||||
);
|
);
|
||||||
assertEqual(
|
assertEqual(
|
||||||
uiDocument.getElementById("field-run-status").textContent,
|
uiDocument.getElementById("field-run-status").textContent,
|
||||||
@@ -464,6 +464,9 @@ TOOL_TABLE = browser-tool.tbl
|
|||||||
"UI G-code run status",
|
"UI G-code run status",
|
||||||
);
|
);
|
||||||
const runLog = uiDocument.getElementById("log").textContent;
|
const runLog = uiDocument.getElementById("log").textContent;
|
||||||
|
if (!runLog.includes("Program: linuxcnc/gcode/ui-session.ngc -> /work/ui-session.ngc")) {
|
||||||
|
throw new Error(`UI G-code run did not use snapshot OPFS program path: ${runLog}`);
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
!runLog.includes("canon_event=STRAIGHT_TRAVERSE") ||
|
!runLog.includes("canon_event=STRAIGHT_TRAVERSE") ||
|
||||||
!runLog.includes("canon_event=STRAIGHT_FEED")
|
!runLog.includes("canon_event=STRAIGHT_FEED")
|
||||||
|
|||||||
Reference in New Issue
Block a user