Commit c5c1c80c authored by vertighel's avatar vertighel
Browse files

refactor: dependency-guard.js — ROOTS camere da GET /api/cameras



Rimosse le voci camera/camera2/scicam*/teccam* hardcoded da ROOTS.
Fetch /api/cameras al boot popola dinamicamente ROOTS[cam_id] = power_api.

Co-Authored-By: default avatarClaude Sonnet 4.6 <noreply@anthropic.com>
parent b00f5963
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -4,19 +4,12 @@

// Root endpoint path for each subsystem — the "gate" controlling the whole chain.
// null means the device is always available (no power endpoint); the guard never fires.
// Camera entries are populated at startup from GET /api/cameras (power_api field).
const ROOTS = {
    telescope: '/telescope/power',
    dome:      '/dome/connection',
    camera:    '/camera/power',
    camera2:   '/camera2/power',
    stage:     '/stage/connection',
    webcam:    '/webcam/clock',
    scicam1:   '/camera/power',   // STX camera — same gate as camera
    teccam1:   '/camera/power',   // STX guider — depends-on cam, same gate
    scicam2:   '/camera2/power',  // Atik — same gate as camera2
    teccam2:   null,              // Mako111 — depends-on cab only, always available
    scicam3:   null,              // not yet defined
    teccam3:   null,              // Mako115 — depends-on cab only, always available
};

const endpointStates = {};
@@ -85,3 +78,12 @@ document.addEventListener('state-diff', e => {
        }
    }
});

fetch('/api/cameras')
    .then(r => r.json())
    .then(cameras => {
        for (const [cam_id, cfg] of Object.entries(cameras)) {
            ROOTS[cam_id] = cfg.power_api ?? null;
        }
    })
    .catch(() => {});