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
@@ -38,21 +38,24 @@ class SwitchedMatrixRadarService:
def open(self) -> None:
"""Open the inner radar and both switches."""
self.inner.open()
if self.output_switch is not None:
self.output_switch.open()
if self.input_switch is not None:
self.input_switch.open()
try:
self.inner.open()
if self.output_switch is not None:
self.output_switch.open()
if self.input_switch is not None:
self.input_switch.open()
except Exception:
self.close()
raise
def close(self) -> None:
"""Close switches first, then the inner radar; never raises."""
for switch in (self.input_switch, self.output_switch):
if switch is not None:
for resource in (self.input_switch, self.output_switch, self.inner):
if resource is not None:
try:
switch.close()
resource.close()
except Exception as exc: # noqa: BLE001 — shutdown path
logger.warning("Switch close ignored error: %s", exc)
self.inner.close()
logger.warning("Switched matrix cleanup failed: %s", exc)
def configure(self, sweep: RadarSweepModel) -> None:
"""Apply sweep settings to the inner radar."""
@@ -211,4 +214,4 @@ def build_physical_switch(
driver_mode = "mock" if radar_driver_mode.strip().lower() == "mock" else "native"
return SwitchService.from_model(
replace(model, positions=physical_positions, driver_mode=driver_mode)
)
)