Refactor radar system

This commit is contained in:
Ayzen
2026-10-05 16:46:28 +03:00
parent 515049d2ed
commit 8f097dfa2e
179 changed files with 8212 additions and 6676 deletions
+11 -16
View File
@@ -142,24 +142,19 @@ class GeneratorSweepRunner:
def _close(self) -> None:
"""Best-effort cleanup of PWM, GPIO, and device state."""
self._pwm.disable()
device = self._device
device, self._device = self._device, None
cleanup = [self._pwm.disable]
if device is not None:
cleanup.extend([
lambda: device.generator.set_idle(timeout_s=1.0) if device.is_connected else None,
device.disconnect,
])
cleanup.extend([self._markers.reset_to_idle, self._markers.close, self._pwm.close])
for action in cleanup:
try:
if device.is_connected:
device.generator.set_idle(timeout_s=1.0)
except Exception as exc: # noqa: BLE001
logger.warning("Failed to set LibreVNA idle mode during shutdown: %s", exc)
finally:
device.disconnect()
self._device = None
try:
self._markers.reset_to_idle()
finally:
self._markers.close()
self._pwm.close()
action()
except Exception as exc:
logger.warning("Generator sweep cleanup failed: %s", exc)
def _run_single_sweep(self) -> None:
"""Execute one pass from the first configured frequency to the last."""