diff --git a/src/svelte-components/src/dialogs/ProbeDialog.svelte b/src/svelte-components/src/dialogs/ProbeDialog.svelte index 4f34554..075f6c5 100644 --- a/src/svelte-components/src/dialogs/ProbeDialog.svelte +++ b/src/svelte-components/src/dialogs/ProbeDialog.svelte @@ -12,7 +12,8 @@ probingComplete, probingFailed, probingStarted, - systemReady + systemReady, + homeMachineComplete } from "$lib/ControllerState"; import { numberWithUnit } from "$lib/RegexHelpers"; import TextFieldWithOptions from "$components/TextFieldWithOptions.svelte"; @@ -131,11 +132,18 @@ async function begin() { try { - if (!get(systemReady)) { + // Wait for both system ready and home machine completion + if (!get(systemReady) || !get(homeMachineComplete)) { await new Promise(resolve => { - const unsubscribe = systemReady.subscribe(ready => { - if (ready) { - unsubscribe(); + const unsubscribeSystem = systemReady.subscribe(ready => { + if (ready && get(homeMachineComplete)) { + unsubscribeSystem(); + resolve(true); + } + }); + const unsubscribeHome = homeMachineComplete.subscribe(homeComplete => { + if (homeComplete && get(systemReady)) { + unsubscribeHome(); resolve(true); } }); diff --git a/src/svelte-components/src/lib/ControllerState.ts b/src/svelte-components/src/lib/ControllerState.ts index a732b76..1e90933 100644 --- a/src/svelte-components/src/lib/ControllerState.ts +++ b/src/svelte-components/src/lib/ControllerState.ts @@ -9,13 +9,18 @@ export const probingFailed = writable(false); export const probingStarted = writable(false); export const probingComplete = writable(false); export const systemReady = writable(false); +export const homeMachineComplete = writable(false); export function handleControllerStateUpdate(state: Record) { if (!get(systemReady)) { systemReady.set(true); } - if (get(probingActive) && get(systemReady)) { + if (state.xx === "READY" && !get(homeMachineComplete)) { + homeMachineComplete.set(true); + } + + if (get(probingActive) && get(systemReady) && get(homeMachineComplete)) { if (state.pw === 0) { probeContacted.set(true); }