推进 INI 面板 machine file summary helper
This commit is contained in:
@@ -22,6 +22,12 @@ import {
|
||||
loadMachineSessionSnapshot,
|
||||
saveMachineSessionSnapshot,
|
||||
} from "../../opfs/snapshot-store.js";
|
||||
import {
|
||||
createMachineFileLoadSummary,
|
||||
createMachineFileSaveSummary,
|
||||
machineFileLoadLogLines,
|
||||
machineFileSaveLogLines,
|
||||
} from "./machine-file-summary.js";
|
||||
import {
|
||||
createRunSummary,
|
||||
summarizeRunResult,
|
||||
@@ -546,13 +552,11 @@ document.getElementById("save-machine-files").addEventListener("click", async ()
|
||||
parameters: DEFAULT_PARAMETERS,
|
||||
});
|
||||
const gcodePath = await saveGcodeProgram(UI_SESSION.defaultGcodeFilename, DEFAULT_GCODE);
|
||||
const summary = createMachineFileSaveSummary(paths, gcodePath);
|
||||
setLog(
|
||||
[
|
||||
"Saved machine text files to OPFS.",
|
||||
`INI: ${paths.ini}`,
|
||||
`Tool table: ${paths.toolTable}`,
|
||||
`Parameters: ${paths.parameters}`,
|
||||
`G-code: ${gcodePath}`,
|
||||
...machineFileSaveLogLines(summary),
|
||||
].join("\n"),
|
||||
);
|
||||
} catch (error) {
|
||||
@@ -765,12 +769,11 @@ document.getElementById("load-machine-files").addEventListener("click", async ()
|
||||
try {
|
||||
const files = await loadMachineTextFiles(MACHINE_ID);
|
||||
editor.value = files.ini;
|
||||
const summary = createMachineFileLoadSummary(files);
|
||||
setLog(
|
||||
[
|
||||
"Loaded machine text files from OPFS.",
|
||||
`INI bytes: ${files.ini.length}`,
|
||||
`Tool table bytes: ${files.toolTable.length}`,
|
||||
`Parameter bytes: ${files.parameters.length}`,
|
||||
...machineFileLoadLogLines(summary),
|
||||
].join("\n"),
|
||||
);
|
||||
} catch (error) {
|
||||
|
||||
33
wasm-port/runtime/ui/ini-panel/machine-file-summary.js
Normal file
33
wasm-port/runtime/ui/ini-panel/machine-file-summary.js
Normal file
@@ -0,0 +1,33 @@
|
||||
export function createMachineFileSaveSummary(paths, gcodePath = null) {
|
||||
return {
|
||||
iniOpfsPath: paths?.ini ?? null,
|
||||
toolTableOpfsPath: paths?.toolTable ?? null,
|
||||
parameterOpfsPath: paths?.parameters ?? null,
|
||||
gcodeOpfsPath: gcodePath ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
export function machineFileSaveLogLines(summary) {
|
||||
return [
|
||||
`INI: ${summary.iniOpfsPath ?? "-"}`,
|
||||
`Tool table: ${summary.toolTableOpfsPath ?? "-"}`,
|
||||
`Parameters: ${summary.parameterOpfsPath ?? "-"}`,
|
||||
`G-code: ${summary.gcodeOpfsPath ?? "-"}`,
|
||||
];
|
||||
}
|
||||
|
||||
export function createMachineFileLoadSummary(files) {
|
||||
return {
|
||||
iniBytes: files?.ini?.length ?? 0,
|
||||
toolTableBytes: files?.toolTable?.length ?? 0,
|
||||
parameterBytes: files?.parameters?.length ?? 0,
|
||||
};
|
||||
}
|
||||
|
||||
export function machineFileLoadLogLines(summary) {
|
||||
return [
|
||||
`INI bytes: ${summary.iniBytes}`,
|
||||
`Tool table bytes: ${summary.toolTableBytes}`,
|
||||
`Parameter bytes: ${summary.parameterBytes}`,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
createMachineFileLoadSummary,
|
||||
createMachineFileSaveSummary,
|
||||
machineFileLoadLogLines,
|
||||
machineFileSaveLogLines,
|
||||
} from "../../../runtime/ui/ini-panel/machine-file-summary.js";
|
||||
|
||||
const saveSummary = createMachineFileSaveSummary({
|
||||
ini: "linuxcnc/machines/xyzab-tdr/machine.ini",
|
||||
toolTable: "linuxcnc/machines/xyzab-tdr/tool.tbl",
|
||||
parameters: "linuxcnc/machines/xyzab-tdr/linuxcnc.var",
|
||||
}, "linuxcnc/gcode/ui-session.ngc");
|
||||
|
||||
assert.deepEqual(saveSummary, {
|
||||
iniOpfsPath: "linuxcnc/machines/xyzab-tdr/machine.ini",
|
||||
toolTableOpfsPath: "linuxcnc/machines/xyzab-tdr/tool.tbl",
|
||||
parameterOpfsPath: "linuxcnc/machines/xyzab-tdr/linuxcnc.var",
|
||||
gcodeOpfsPath: "linuxcnc/gcode/ui-session.ngc",
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
machineFileSaveLogLines(saveSummary),
|
||||
[
|
||||
"INI: linuxcnc/machines/xyzab-tdr/machine.ini",
|
||||
"Tool table: linuxcnc/machines/xyzab-tdr/tool.tbl",
|
||||
"Parameters: linuxcnc/machines/xyzab-tdr/linuxcnc.var",
|
||||
"G-code: linuxcnc/gcode/ui-session.ngc",
|
||||
],
|
||||
);
|
||||
|
||||
const loadSummary = createMachineFileLoadSummary({
|
||||
ini: "[EMC]\nMACHINE = xyzab-tdr\n",
|
||||
toolTable: "T2 P7 Z3.125\n",
|
||||
parameters: "5220 1\n",
|
||||
});
|
||||
|
||||
assert.deepEqual(loadSummary, {
|
||||
iniBytes: 26,
|
||||
toolTableBytes: 13,
|
||||
parameterBytes: 7,
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
machineFileLoadLogLines(loadSummary),
|
||||
[
|
||||
"INI bytes: 26",
|
||||
"Tool table bytes: 13",
|
||||
"Parameter bytes: 7",
|
||||
],
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
createMachineFileSaveSummary(null),
|
||||
{
|
||||
iniOpfsPath: null,
|
||||
toolTableOpfsPath: null,
|
||||
parameterOpfsPath: null,
|
||||
gcodeOpfsPath: null,
|
||||
},
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
createMachineFileLoadSummary(null),
|
||||
{
|
||||
iniBytes: 0,
|
||||
toolTableBytes: 0,
|
||||
parameterBytes: 0,
|
||||
},
|
||||
);
|
||||
|
||||
console.log("ini_panel_machine_file_summary_node_smoke=ok");
|
||||
6
wasm-port/tests/ui/node/verify_ini_panel_machine_file_summary.sh
Executable file
6
wasm-port/tests/ui/node/verify_ini_panel_machine_file_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_machine_file_summary.mjs"
|
||||
@@ -5,5 +5,6 @@ ROOT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)"
|
||||
|
||||
"$ROOT_DIR/tests/ui/node/verify_ini_panel_run_summary.sh"
|
||||
"$ROOT_DIR/tests/ui/node/verify_ini_panel_session_summary.sh"
|
||||
"$ROOT_DIR/tests/ui/node/verify_ini_panel_machine_file_summary.sh"
|
||||
|
||||
echo "ui_node_smokes=ok"
|
||||
|
||||
Reference in New Issue
Block a user