推进 INI 面板 machine file summary helper

This commit is contained in:
2026-06-14 18:39:27 +08:00
parent 083b117c21
commit a60826bfce
6 changed files with 189 additions and 7 deletions

View File

@@ -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) {

View 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}`,
];
}