Skip to content

Commit 0ec1962

Browse files
RickDnampsclaude
andcommitted
Fix: séquences — un seul script à la fois + reset servos + UI sync
script_engine.py: - run() appelle stop_all() avant de démarrer une nouvelle séquence - run() appelle close_all() sur dome_servo + servo (reset position fermée) - Un seul script actif à la fois, garanti côté serveur app.js: - run(): efface toutes les cartes running immédiatement dès confirmation - run(): met à jour la barre ACTIVE en temps réel (name#id) - Plus de cartes vertes fantômes après fin de séquence Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3a07920 commit 0ec1962

4 files changed

Lines changed: 37 additions & 3 deletions

File tree

android/app/src/main/assets/js/app.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,10 +989,19 @@ class ScriptEngine {
989989
run(name, loop) {
990990
api('/scripts/run', 'POST', { name, loop }).then(d => {
991991
if (d) {
992+
// Un seul script à la fois — effacer toutes les cartes immédiatement
993+
this._running.clear();
994+
document.querySelectorAll('.script-card').forEach(c => c.classList.remove('running'));
995+
const count = el('running-count');
996+
if (count) count.textContent = '1';
997+
const list = el('running-scripts');
998+
if (list) list.textContent = `${name}#${d.id}`;
999+
// Marquer uniquement la nouvelle carte
1000+
this._running.add(name);
9921001
const card = el(`script-card-${name}`);
9931002
if (card) card.classList.add('running');
9941003
toast(`${name.toUpperCase()} started${loop ? ' (loop)' : ''}`, 'ok');
995-
poller.poll(); // sync running state + bottom bar from server immediately
1004+
poller.poll();
9961005
}
9971006
});
9981007
}

android/compiled/R2-D2_Control.apk

0 Bytes
Binary file not shown.

master/script_engine.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,30 @@ def list_running(self) -> list[dict]:
8080

8181
def run(self, name: str, loop: bool = False) -> int | None:
8282
"""
83-
Lance un script.
83+
Lance un script — un seul à la fois.
84+
Arrête tous les scripts en cours et remet les servos en position fermée avant de démarrer.
8485
Retourne l'ID du script ou None si introuvable.
8586
"""
8687
path = os.path.join(SCRIPTS_DIR, name + '.scr')
8788
if not os.path.isfile(path):
8889
log.error(f"Script introuvable: {path}")
8990
return None
9091

92+
# Un seul script à la fois : stopper les précédents
93+
self.stop_all()
94+
95+
# Reset servos en position fermée avant la nouvelle séquence
96+
try:
97+
if self._dome_servo:
98+
self._dome_servo.close_all()
99+
except Exception as e:
100+
log.warning(f"run: close_all dome_servo: {e}")
101+
try:
102+
if self._servo:
103+
self._servo.close_all()
104+
except Exception as e:
105+
log.warning(f"run: close_all servo: {e}")
106+
91107
with self._lock:
92108
script_id = self._next_id
93109
self._next_id += 1

master/static/js/app.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,10 +989,19 @@ class ScriptEngine {
989989
run(name, loop) {
990990
api('/scripts/run', 'POST', { name, loop }).then(d => {
991991
if (d) {
992+
// Un seul script à la fois — effacer toutes les cartes immédiatement
993+
this._running.clear();
994+
document.querySelectorAll('.script-card').forEach(c => c.classList.remove('running'));
995+
const count = el('running-count');
996+
if (count) count.textContent = '1';
997+
const list = el('running-scripts');
998+
if (list) list.textContent = `${name}#${d.id}`;
999+
// Marquer uniquement la nouvelle carte
1000+
this._running.add(name);
9921001
const card = el(`script-card-${name}`);
9931002
if (card) card.classList.add('running');
9941003
toast(`${name.toUpperCase()} started${loop ? ' (loop)' : ''}`, 'ok');
995-
poller.poll(); // sync running state + bottom bar from server immediately
1004+
poller.poll();
9961005
}
9971006
});
9981007
}

0 commit comments

Comments
 (0)