推进 INI 面板运行结果摘要 helper
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
} from "../../opfs/snapshot-store.js";
|
||||
import {
|
||||
createRunSummary,
|
||||
summarizeRunResult,
|
||||
} from "./run-summary.js";
|
||||
|
||||
const SAMPLE_PATH =
|
||||
@@ -305,10 +306,6 @@ function playRunMotion(resultText, programText, snapshots = parseRunMotion(resul
|
||||
}, 220);
|
||||
}
|
||||
|
||||
function countCanonicalEvents(resultText) {
|
||||
return resultText.split("\n").filter((line) => line.startsWith("canon_event=")).length;
|
||||
}
|
||||
|
||||
function requireIniSdk() {
|
||||
if (!iniSdk) {
|
||||
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 trimmedResult = result.trim();
|
||||
const motionSnapshots = parseRunMotion(trimmedResult, program.text);
|
||||
const runResultSummary = summarizeRunResult(trimmedResult, motionSnapshots);
|
||||
setField("sessionGcode", program.opfsPath);
|
||||
setField("runStatus", "ok");
|
||||
setLastRunSummary(program, {
|
||||
runStatus: "ok",
|
||||
iniWasmPath: loadedSession.ini.wasmPath,
|
||||
canonicalEventCount: countCanonicalEvents(trimmedResult),
|
||||
motionSnapshotCount: motionSnapshots.length,
|
||||
...runResultSummary,
|
||||
});
|
||||
setCanonicalEvents(trimmedResult);
|
||||
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) {
|
||||
const metadata = snapshot?.metadata ?? {};
|
||||
return {
|
||||
|
||||
@@ -2,6 +2,7 @@ import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
createRunSummary,
|
||||
summarizeRunResult,
|
||||
} from "../../../runtime/ui/ini-panel/run-summary.js";
|
||||
|
||||
const program = {
|
||||
@@ -63,4 +64,26 @@ assert.equal(
|
||||
"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");
|
||||
|
||||
Reference in New Issue
Block a user