Refactor radar system
This commit is contained in:
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user