changes done to manage pw state
This commit is contained in:
@@ -12,7 +12,8 @@
|
|||||||
probingComplete,
|
probingComplete,
|
||||||
probingFailed,
|
probingFailed,
|
||||||
probingStarted,
|
probingStarted,
|
||||||
systemReady
|
systemReady,
|
||||||
|
homeMachineComplete
|
||||||
} from "$lib/ControllerState";
|
} from "$lib/ControllerState";
|
||||||
import { numberWithUnit } from "$lib/RegexHelpers";
|
import { numberWithUnit } from "$lib/RegexHelpers";
|
||||||
import TextFieldWithOptions from "$components/TextFieldWithOptions.svelte";
|
import TextFieldWithOptions from "$components/TextFieldWithOptions.svelte";
|
||||||
@@ -131,11 +132,18 @@
|
|||||||
|
|
||||||
async function begin() {
|
async function begin() {
|
||||||
try {
|
try {
|
||||||
if (!get(systemReady)) {
|
// Wait for both system ready and home machine completion
|
||||||
|
if (!get(systemReady) || !get(homeMachineComplete)) {
|
||||||
await new Promise(resolve => {
|
await new Promise(resolve => {
|
||||||
const unsubscribe = systemReady.subscribe(ready => {
|
const unsubscribeSystem = systemReady.subscribe(ready => {
|
||||||
if (ready) {
|
if (ready && get(homeMachineComplete)) {
|
||||||
unsubscribe();
|
unsubscribeSystem();
|
||||||
|
resolve(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const unsubscribeHome = homeMachineComplete.subscribe(homeComplete => {
|
||||||
|
if (homeComplete && get(systemReady)) {
|
||||||
|
unsubscribeHome();
|
||||||
resolve(true);
|
resolve(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,13 +9,18 @@ export const probingFailed = writable(false);
|
|||||||
export const probingStarted = writable(false);
|
export const probingStarted = writable(false);
|
||||||
export const probingComplete = writable(false);
|
export const probingComplete = writable(false);
|
||||||
export const systemReady = writable(false);
|
export const systemReady = writable(false);
|
||||||
|
export const homeMachineComplete = writable(false);
|
||||||
|
|
||||||
export function handleControllerStateUpdate(state: Record<string, any>) {
|
export function handleControllerStateUpdate(state: Record<string, any>) {
|
||||||
if (!get(systemReady)) {
|
if (!get(systemReady)) {
|
||||||
systemReady.set(true);
|
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) {
|
if (state.pw === 0) {
|
||||||
probeContacted.set(true);
|
probeContacted.set(true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user