推进 INI 面板运行结果摘要 helper
This commit is contained in:
64
text10.txt
64
text10.txt
@@ -1226,3 +1226,67 @@ host_wasm_opfs_browser_smokes=ok
|
|||||||
result 轻量统计也收敛到可导出的 helper,例如 `summarizeRunResult(resultText, snapshots)`,
|
result 轻量统计也收敛到可导出的 helper,例如 `summarizeRunResult(resultText, snapshots)`,
|
||||||
并补 Node 侧纯函数测试;保持只统计 LinuxCNC-owned runtime 输出行和 UI 已解析 motion
|
并补 Node 侧纯函数测试;保持只统计 LinuxCNC-owned runtime 输出行和 UI 已解析 motion
|
||||||
snapshot 数量,不解释或改写 G-code、tool、parameter、planner 等 CNC 语义。
|
snapshot 数量,不解释或改写 G-code、tool、parameter、planner 等 CNC 语义。
|
||||||
|
|
||||||
|
十七、2026-06-14 继续执行记录:INI panel run result summary helper
|
||||||
|
|
||||||
|
本轮继续沿 OPFS/session/UI boundary 推进,把 runtime result 的轻量统计收敛到可导出的
|
||||||
|
纯 helper,方便后续 SDK/API 或其他 UI panel 复用。
|
||||||
|
|
||||||
|
完成内容:
|
||||||
|
|
||||||
|
- 在 `wasm-port/runtime/ui/ini-panel/run-summary.js` 新增
|
||||||
|
`summarizeRunResult(resultText, snapshots)`;
|
||||||
|
- helper 返回:
|
||||||
|
- `canonicalEventCount`;
|
||||||
|
- `motionSnapshotCount`;
|
||||||
|
- `canonicalEventCount` 只统计 LinuxCNC interpreter 输出中以 `canon_event=` 开头的行;
|
||||||
|
- `motionSnapshotCount` 只取 UI 已解析 motion snapshots 数量;
|
||||||
|
- `wasm-port/runtime/ui/ini-panel/app.js` 移除本地 `countCanonicalEvents(...)`,改为调用
|
||||||
|
`summarizeRunResult(...)`;
|
||||||
|
- `Run G-code` 成功路径继续复用同一份 motion snapshots 进行 summary 与 playback;
|
||||||
|
- Node smoke 增加纯函数覆盖:
|
||||||
|
- canonical event 前缀计数;
|
||||||
|
- 非前缀文本不计数;
|
||||||
|
- 空输出与空 snapshots;
|
||||||
|
- browser INI panel smoke 继续覆盖真实 UI run summary;
|
||||||
|
- 未改变 OPFS path model、snapshot envelope、G-code 文本、interpreter run API、
|
||||||
|
canonical-event 文本输出、motion playback 行为或 LinuxCNC-owned runtime semantics。
|
||||||
|
|
||||||
|
验证已通过:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git diff --check
|
||||||
|
wasm-port/tests/ui/node/verify_ini_panel_run_summary.sh
|
||||||
|
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
|
||||||
|
ini_panel_run_summary_node_smoke=ok
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
下一步建议:
|
||||||
|
|
||||||
|
继续沿 OPFS/session/UI boundary 推进。优先把 run summary helper 的 Node smoke 纳入
|
||||||
|
host smoke 或新增统一 UI node smoke wrapper,让这类 UI/API helper 在常规 gate 中自动执行;
|
||||||
|
仍只覆盖 host/runtime 边界 helper,不触碰 interpreter、OPFS bridge 或 LinuxCNC-owned
|
||||||
|
runtime semantics。
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
} from "../../opfs/snapshot-store.js";
|
} from "../../opfs/snapshot-store.js";
|
||||||
import {
|
import {
|
||||||
createRunSummary,
|
createRunSummary,
|
||||||
|
summarizeRunResult,
|
||||||
} from "./run-summary.js";
|
} from "./run-summary.js";
|
||||||
|
|
||||||
const SAMPLE_PATH =
|
const SAMPLE_PATH =
|
||||||
@@ -305,10 +306,6 @@ function playRunMotion(resultText, programText, snapshots = parseRunMotion(resul
|
|||||||
}, 220);
|
}, 220);
|
||||||
}
|
}
|
||||||
|
|
||||||
function countCanonicalEvents(resultText) {
|
|
||||||
return resultText.split("\n").filter((line) => line.startsWith("canon_event=")).length;
|
|
||||||
}
|
|
||||||
|
|
||||||
function requireIniSdk() {
|
function requireIniSdk() {
|
||||||
if (!iniSdk) {
|
if (!iniSdk) {
|
||||||
throw new Error("INI WASM module is not ready yet.");
|
throw new Error("INI WASM module is not ready yet.");
|
||||||
@@ -671,13 +668,13 @@ document.getElementById("run-gcode").addEventListener("click", async () => {
|
|||||||
const result = interp.runFileWithIni(program.wasmPath, loadedSession.ini.wasmPath);
|
const result = interp.runFileWithIni(program.wasmPath, loadedSession.ini.wasmPath);
|
||||||
const trimmedResult = result.trim();
|
const trimmedResult = result.trim();
|
||||||
const motionSnapshots = parseRunMotion(trimmedResult, program.text);
|
const motionSnapshots = parseRunMotion(trimmedResult, program.text);
|
||||||
|
const runResultSummary = summarizeRunResult(trimmedResult, motionSnapshots);
|
||||||
setField("sessionGcode", program.opfsPath);
|
setField("sessionGcode", program.opfsPath);
|
||||||
setField("runStatus", "ok");
|
setField("runStatus", "ok");
|
||||||
setLastRunSummary(program, {
|
setLastRunSummary(program, {
|
||||||
runStatus: "ok",
|
runStatus: "ok",
|
||||||
iniWasmPath: loadedSession.ini.wasmPath,
|
iniWasmPath: loadedSession.ini.wasmPath,
|
||||||
canonicalEventCount: countCanonicalEvents(trimmedResult),
|
...runResultSummary,
|
||||||
motionSnapshotCount: motionSnapshots.length,
|
|
||||||
});
|
});
|
||||||
setCanonicalEvents(trimmedResult);
|
setCanonicalEvents(trimmedResult);
|
||||||
playRunMotion(trimmedResult, program.text, motionSnapshots);
|
playRunMotion(trimmedResult, program.text, motionSnapshots);
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
export function summarizeRunResult(resultText, snapshots = []) {
|
||||||
|
return {
|
||||||
|
canonicalEventCount: resultText.split("\n").filter((line) => line.startsWith("canon_event=")).length,
|
||||||
|
motionSnapshotCount: snapshots.length,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function createRunSummary(program, runtime = {}, snapshot = null) {
|
export function createRunSummary(program, runtime = {}, snapshot = null) {
|
||||||
const metadata = snapshot?.metadata ?? {};
|
const metadata = snapshot?.metadata ?? {};
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
createRunSummary,
|
createRunSummary,
|
||||||
|
summarizeRunResult,
|
||||||
} from "../../../runtime/ui/ini-panel/run-summary.js";
|
} from "../../../runtime/ui/ini-panel/run-summary.js";
|
||||||
|
|
||||||
const program = {
|
const program = {
|
||||||
@@ -63,4 +64,26 @@ assert.equal(
|
|||||||
"override-session/override.json",
|
"override-session/override.json",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
summarizeRunResult([
|
||||||
|
"canon_event=STRAIGHT_TRAVERSE line=1 x=1 y=2",
|
||||||
|
"run_step phase=execute line=1",
|
||||||
|
"canon_event=STRAIGHT_FEED line=2 x=3 y=4",
|
||||||
|
"message=canon_event=not-a-canonical-prefix",
|
||||||
|
"",
|
||||||
|
].join("\n"), [{}, {}]),
|
||||||
|
{
|
||||||
|
canonicalEventCount: 2,
|
||||||
|
motionSnapshotCount: 2,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
summarizeRunResult("", []),
|
||||||
|
{
|
||||||
|
canonicalEventCount: 0,
|
||||||
|
motionSnapshotCount: 0,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
console.log("ini_panel_run_summary_node_smoke=ok");
|
console.log("ini_panel_run_summary_node_smoke=ok");
|
||||||
|
|||||||
Reference in New Issue
Block a user