推进 INI 面板运行摘要结果计数
This commit is contained in:
@@ -282,9 +282,8 @@ function showRunSnapshot(snapshot, index, total) {
|
||||
);
|
||||
}
|
||||
|
||||
function playRunMotion(resultText, programText) {
|
||||
function playRunMotion(resultText, programText, snapshots = parseRunMotion(resultText, programText)) {
|
||||
clearRunPlayback();
|
||||
const snapshots = parseRunMotion(resultText, programText);
|
||||
if (snapshots.length === 0) {
|
||||
setRunMonitor(100, "100%", {}, "complete; no axis motion");
|
||||
return;
|
||||
@@ -303,6 +302,10 @@ function playRunMotion(resultText, programText) {
|
||||
}, 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.");
|
||||
@@ -364,15 +367,19 @@ function clearLastRunSummary() {
|
||||
setField("runWasmPath", "-");
|
||||
}
|
||||
|
||||
function setLastRunSummary(program, snapshot = restoredSessionSnapshot) {
|
||||
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,
|
||||
};
|
||||
window.linuxCncIniPanelLastRunSummary = summary;
|
||||
setField("runSource", summary.programSource);
|
||||
@@ -664,17 +671,24 @@ document.getElementById("run-gcode").addEventListener("click", async () => {
|
||||
setRunMonitor(5, "running", {}, "running");
|
||||
await nextFrame();
|
||||
const result = interp.runFileWithIni(program.wasmPath, loadedSession.ini.wasmPath);
|
||||
const trimmedResult = result.trim();
|
||||
const motionSnapshots = parseRunMotion(trimmedResult, program.text);
|
||||
setField("sessionGcode", program.opfsPath);
|
||||
setField("runStatus", "ok");
|
||||
setLastRunSummary(program);
|
||||
setCanonicalEvents(result.trim());
|
||||
playRunMotion(result.trim(), program.text);
|
||||
setLastRunSummary(program, {
|
||||
runStatus: "ok",
|
||||
iniWasmPath: loadedSession.ini.wasmPath,
|
||||
canonicalEventCount: countCanonicalEvents(trimmedResult),
|
||||
motionSnapshotCount: motionSnapshots.length,
|
||||
});
|
||||
setCanonicalEvents(trimmedResult);
|
||||
playRunMotion(trimmedResult, program.text, motionSnapshots);
|
||||
setLog(
|
||||
[
|
||||
"Ran G-code through LinuxCNC interpreter WASM.",
|
||||
...runSessionContextLogLines(program),
|
||||
`INI: ${loadedSession.ini.wasmPath}`,
|
||||
result.trim(),
|
||||
trimmedResult,
|
||||
].join("\n"),
|
||||
);
|
||||
} catch (error) {
|
||||
|
||||
@@ -437,6 +437,7 @@ TOOL_TABLE = browser-tool.tbl
|
||||
"UI fallback run WASM field",
|
||||
);
|
||||
const fallbackRunSummary = uiDocument.defaultView.linuxCncIniPanelLastRunSummary;
|
||||
assertEqual(fallbackRunSummary.runStatus, "ok", "UI fallback run summary status");
|
||||
assertEqual(fallbackRunSummary.programSource, "default", "UI fallback run summary source");
|
||||
assertEqual(fallbackRunSummary.snapshotLabel, null, "UI fallback run summary snapshot");
|
||||
assertEqual(fallbackRunSummary.workflow, null, "UI fallback run summary workflow");
|
||||
@@ -450,6 +451,21 @@ TOOL_TABLE = browser-tool.tbl
|
||||
"/work/ui-session.ngc",
|
||||
"UI fallback run summary WASM path",
|
||||
);
|
||||
assertEqual(
|
||||
fallbackRunSummary.iniWasmPath,
|
||||
"/work/session-machine.ini",
|
||||
"UI fallback run summary INI WASM path",
|
||||
);
|
||||
assertEqual(
|
||||
fallbackRunSummary.canonicalEventCount,
|
||||
2,
|
||||
"UI fallback run summary canonical event count",
|
||||
);
|
||||
assertEqual(
|
||||
fallbackRunSummary.motionSnapshotCount,
|
||||
2,
|
||||
"UI fallback run summary motion snapshot count",
|
||||
);
|
||||
uiDocument.getElementById("save-session-snapshot").click();
|
||||
await waitFor(
|
||||
() => uiDocument.getElementById("log")?.textContent.includes("Saved machine session snapshot"),
|
||||
@@ -607,6 +623,7 @@ TOOL_TABLE = browser-tool.tbl
|
||||
"UI snapshot run WASM field",
|
||||
);
|
||||
const snapshotRunSummary = uiDocument.defaultView.linuxCncIniPanelLastRunSummary;
|
||||
assertEqual(snapshotRunSummary.runStatus, "ok", "UI snapshot run summary status");
|
||||
assertEqual(snapshotRunSummary.programSource, "snapshot", "UI snapshot run summary source");
|
||||
assertEqual(
|
||||
snapshotRunSummary.snapshotLabel,
|
||||
@@ -628,6 +645,21 @@ TOOL_TABLE = browser-tool.tbl
|
||||
"/work/ui-session.ngc",
|
||||
"UI snapshot run summary WASM path",
|
||||
);
|
||||
assertEqual(
|
||||
snapshotRunSummary.iniWasmPath,
|
||||
"/work/session-machine.ini",
|
||||
"UI snapshot run summary INI WASM path",
|
||||
);
|
||||
assertEqual(
|
||||
snapshotRunSummary.canonicalEventCount,
|
||||
2,
|
||||
"UI snapshot run summary canonical event count",
|
||||
);
|
||||
assertEqual(
|
||||
snapshotRunSummary.motionSnapshotCount,
|
||||
2,
|
||||
"UI snapshot run summary motion snapshot count",
|
||||
);
|
||||
if (
|
||||
!runLog.includes("canon_event=STRAIGHT_TRAVERSE") ||
|
||||
!runLog.includes("canon_event=STRAIGHT_FEED")
|
||||
|
||||
Reference in New Issue
Block a user