推进 INI 面板 session snapshot workflow helper

This commit is contained in:
2026-06-14 21:21:17 +08:00
parent 48a0f61b4a
commit 4e4a9c667f
7 changed files with 356 additions and 71 deletions

View File

@@ -0,0 +1,65 @@
import {
createSessionSnapshotSummary,
sessionSnapshotSummaryLogLines,
} from "./session-summary.js";
export function createSessionSnapshotFieldState(summary) {
return {
sessionIni: summary.iniOpfsPath,
sessionParameters: summary.parameterOpfsPath,
sessionToolTable: summary.toolTableOpfsPath,
sessionGcode: summary.gcodeOpfsPath,
sessionSnapshot: summary.snapshotLabel,
};
}
export function sessionSnapshotSaveLogLines(summary) {
return [
...sessionSnapshotSummaryLogLines(summary),
`INI: ${summary.iniOpfsPath}`,
`Parameter file: ${summary.parameterOpfsPath}`,
`Tool table file: ${summary.toolTableOpfsPath}`,
`G-code: ${summary.gcodeOpfsPath}`,
];
}
export async function saveMachineSessionSnapshotWorkflow({
machineId,
snapshotId,
snapshotFilename,
snapshotLabel,
iniText,
toolTableText,
parameterText,
gcodeFilename,
gcodeText,
metadata,
saveMachineTextFiles,
saveGcodeProgram,
saveMachineSessionSnapshot,
}) {
await Promise.all([
saveMachineTextFiles(machineId, {
ini: iniText,
toolTable: toolTableText,
parameters: parameterText,
}),
saveGcodeProgram(gcodeFilename, gcodeText),
]);
const snapshot = await saveMachineSessionSnapshot(
snapshotId,
machineId,
{
filename: snapshotFilename,
gcodeFilename,
metadata,
},
);
const summary = createSessionSnapshotSummary(snapshot, snapshotLabel);
return {
snapshot,
summary,
fields: createSessionSnapshotFieldState(summary),
logLines: sessionSnapshotSaveLogLines(summary),
};
}