Commit 728ad4db authored by vertighel's avatar vertighel
Browse files

Fix subsystem guard: gate reopening non riattivava scicam1/scicam2/teccam1



dependency-guard.js: il listener state-diff riattivava applyGuard() solo
quando cambiava il valore del root del sub, non quando cambiava il suo
gate. Per scicam1/scicam2/teccam1 il root (la propria presa PDU) resta
false anche a gate aperto (la camera non si accende da sola), quindi il
guard non veniva mai ricontrollato dopo l'accensione del telescopio,
finché non si ricaricava la pagina. Ora si riattiva anche sul cambio
del gate, e i container esenti (root container a gate aperto) vengono
scardinati esplicitamente dalla classe subsystem-offline invece di
limitarsi a saltare il toggle.

cameras.ini: power_api per scicam3 (dipende da cab, non da una propria
presa PDU, come teccam2/teccam3).

base.html: corretto request.endpoint atteso per l'evidenziazione del
link Control nella navbar (control_page, non control).

Co-Authored-By: default avatarClaude Sonnet 5 <noreply@anthropic.com>
parent 69dbf815
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ small_frame = 0, 1500, 4008, 2000
[scicam3]
role        = sci
station     = 3
power_api   = /telescope/power
fits_path   = fits/scicam3.fits
pixel_scale = 0.283
orientation = -60
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@
                </li>

                <li class="nav-item">
                  <a class="nav-link {% if request.endpoint == 'web.control' %}active{% endif %}"
                  <a class="nav-link {% if request.endpoint == 'web.control_page' %}active{% endif %}"
                     href="{{ url_for('web.control_page') }}">
                    Control
                  </a>
+16 −4
Original line number Diff line number Diff line
@@ -61,9 +61,15 @@ function applyGuard(sub, offline) {
        const container = nearestContainer(btn);
        if (!container || container.dataset.subsystem || seen.has(container)) return;
        seen.add(container);
        // Root containers are exempt from being disabled (skip when going offline).
        // When going back online always remove the class, even from root containers.
        if (offline && isRootContainer(container, sub)) return;
        // Root containers are exempt from being disabled. Must actively clear
        // the class here (not just skip the toggle below): the gate can open
        // in a later event while `offline` itself stays true — the camera's
        // own switch hasn't changed, only its parent gate has — so a
        // previously-applied class would otherwise never get removed.
        if (offline && isRootContainer(container, sub)) {
            container.classList.remove('subsystem-offline');
            return;
        }
        container.classList.toggle('subsystem-offline', offline);
    });
}
@@ -73,7 +79,13 @@ document.addEventListener('state-diff', e => {
    Object.assign(endpointStates, diff);

    for (const [sub, rootPath] of Object.entries(ROOTS)) {
        if (rootPath in diff) {
        // Re-run the guard when the sub's own root changes, OR when its gate
        // does: a dependent root (e.g. /scicam1/power behind cab) can stay
        // at the same value (camera still switched off) while its gate opens
        // — isRootContainer()'s exemption needs to be re-evaluated even
        // though `offline` itself won't change.
        const gate = endpointGates[rootPath];
        if (rootPath in diff || (gate && gate in diff)) {
            applyGuard(sub, endpointStates[rootPath] === false);
        }
    }