changes done to manage pw state
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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<string, any>) {
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user