66 lines
1.6 KiB
JavaScript
66 lines
1.6 KiB
JavaScript
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),
|
|
};
|
|
}
|