推进 INI 面板运行摘要 helper
This commit is contained in:
@@ -22,6 +22,9 @@ import {
|
||||
loadMachineSessionSnapshot,
|
||||
saveMachineSessionSnapshot,
|
||||
} from "../../opfs/snapshot-store.js";
|
||||
import {
|
||||
createRunSummary,
|
||||
} from "./run-summary.js";
|
||||
|
||||
const SAMPLE_PATH =
|
||||
"../../../vendor/linuxcnc/configs/sim/axis/vismach/5axis/table-dual-rotary/xyzab-tdr.ini";
|
||||
@@ -368,19 +371,14 @@ function clearLastRunSummary() {
|
||||
}
|
||||
|
||||
function setLastRunSummary(program, runtime = {}, snapshot = restoredSessionSnapshot) {
|
||||
const snapshotLabel = snapshot ? sessionSnapshotLabel(snapshot.sessionId) : null;
|
||||
const metadata = snapshot?.metadata ?? {};
|
||||
const summary = {
|
||||
runStatus: runtime.runStatus ?? "ok",
|
||||
programSource: program.source,
|
||||
snapshotLabel,
|
||||
workflow: metadata.workflow ?? null,
|
||||
programOpfsPath: program.opfsPath,
|
||||
programWasmPath: program.wasmPath,
|
||||
iniWasmPath: runtime.iniWasmPath ?? null,
|
||||
canonicalEventCount: runtime.canonicalEventCount ?? 0,
|
||||
motionSnapshotCount: runtime.motionSnapshotCount ?? 0,
|
||||
};
|
||||
const summary = createRunSummary(
|
||||
program,
|
||||
{
|
||||
...runtime,
|
||||
snapshotLabel: snapshot ? sessionSnapshotLabel(snapshot.sessionId) : null,
|
||||
},
|
||||
snapshot,
|
||||
);
|
||||
window.linuxCncIniPanelLastRunSummary = summary;
|
||||
setField("runSource", summary.programSource);
|
||||
setField("runSnapshot", summary.snapshotLabel ?? "-");
|
||||
|
||||
14
wasm-port/runtime/ui/ini-panel/run-summary.js
Normal file
14
wasm-port/runtime/ui/ini-panel/run-summary.js
Normal file
@@ -0,0 +1,14 @@
|
||||
export function createRunSummary(program, runtime = {}, snapshot = null) {
|
||||
const metadata = snapshot?.metadata ?? {};
|
||||
return {
|
||||
runStatus: runtime.runStatus ?? "ok",
|
||||
programSource: program.source,
|
||||
snapshotLabel: runtime.snapshotLabel ?? metadata.snapshotLabel ?? null,
|
||||
workflow: metadata.workflow ?? null,
|
||||
programOpfsPath: program.opfsPath,
|
||||
programWasmPath: program.wasmPath,
|
||||
iniWasmPath: runtime.iniWasmPath ?? null,
|
||||
canonicalEventCount: runtime.canonicalEventCount ?? 0,
|
||||
motionSnapshotCount: runtime.motionSnapshotCount ?? 0,
|
||||
};
|
||||
}
|
||||
66
wasm-port/tests/ui/node/verify_ini_panel_run_summary.mjs
Normal file
66
wasm-port/tests/ui/node/verify_ini_panel_run_summary.mjs
Normal file
@@ -0,0 +1,66 @@
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
createRunSummary,
|
||||
} from "../../../runtime/ui/ini-panel/run-summary.js";
|
||||
|
||||
const program = {
|
||||
source: "snapshot",
|
||||
opfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
wasmPath: "/work/ui-session.ngc",
|
||||
};
|
||||
const snapshot = {
|
||||
sessionId: "ui-machine-session",
|
||||
metadata: {
|
||||
workflow: "save-session-snapshot",
|
||||
snapshotLabel: "ui-machine-session/ui-machine-session.json",
|
||||
},
|
||||
};
|
||||
|
||||
assert.deepEqual(
|
||||
createRunSummary(program, {
|
||||
runStatus: "ok",
|
||||
iniWasmPath: "/work/session-machine.ini",
|
||||
canonicalEventCount: 2,
|
||||
motionSnapshotCount: 2,
|
||||
}, snapshot),
|
||||
{
|
||||
runStatus: "ok",
|
||||
programSource: "snapshot",
|
||||
snapshotLabel: "ui-machine-session/ui-machine-session.json",
|
||||
workflow: "save-session-snapshot",
|
||||
programOpfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
programWasmPath: "/work/ui-session.ngc",
|
||||
iniWasmPath: "/work/session-machine.ini",
|
||||
canonicalEventCount: 2,
|
||||
motionSnapshotCount: 2,
|
||||
},
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
createRunSummary({
|
||||
source: "default",
|
||||
opfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
wasmPath: "/work/ui-session.ngc",
|
||||
}),
|
||||
{
|
||||
runStatus: "ok",
|
||||
programSource: "default",
|
||||
snapshotLabel: null,
|
||||
workflow: null,
|
||||
programOpfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
programWasmPath: "/work/ui-session.ngc",
|
||||
iniWasmPath: null,
|
||||
canonicalEventCount: 0,
|
||||
motionSnapshotCount: 0,
|
||||
},
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
createRunSummary(program, {
|
||||
snapshotLabel: "override-session/override.json",
|
||||
}, snapshot).snapshotLabel,
|
||||
"override-session/override.json",
|
||||
);
|
||||
|
||||
console.log("ini_panel_run_summary_node_smoke=ok");
|
||||
6
wasm-port/tests/ui/node/verify_ini_panel_run_summary.sh
Executable file
6
wasm-port/tests/ui/node/verify_ini_panel_run_summary.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)"
|
||||
|
||||
node "$ROOT_DIR/tests/ui/node/verify_ini_panel_run_summary.mjs"
|
||||
Reference in New Issue
Block a user