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
@@ -122,6 +122,8 @@ class AppWindowPreprocessMixin:
def _capture_tmp_reference(self) -> None:
"""Capture, save, and select a temporary S21 reference with current sweep settings."""
if getattr(self, "_closing", False) or getattr(self, "_stopping_run", False):
return
if self._capture_session is not None:
self._show_error(
"Cannot capture tmp reference during active capture sequence",
@@ -138,12 +140,15 @@ class AppWindowPreprocessMixin:
pipeline_was_running = self._supervisor.is_running()
pipeline_was_paused = False
resume_seq = getattr(self, "_stop_request_seq", 0) + 1
try:
if pipeline_was_running:
self._log("Pipeline paused for tmp reference capture")
self._stop_run()
pipeline_was_paused = True
if not self._pipeline_resume_allowed(resume_seq):
return
config = self._build_config()
radar_key = self._radar_key(config)
@@ -194,7 +199,7 @@ class AppWindowPreprocessMixin:
except Exception as exc: # noqa: BLE001
self._show_exception("Failed to capture tmp reference", exc)
finally:
if pipeline_was_paused:
if pipeline_was_paused and self._pipeline_resume_allowed(resume_seq):
self._start_run()
self._control_button_busy = False
@@ -333,6 +338,8 @@ class AppWindowPreprocessMixin:
def _start_capture_sequence(self, kind: str) -> None:
"""Start sequential capture session for requested preprocess asset."""
if getattr(self, "_closing", False) or getattr(self, "_stopping_run", False):
return
if self._capture_session is not None:
self._show_error("Another capture sequence is already active", details=self._capture_state_details())
return
@@ -344,9 +351,12 @@ class AppWindowPreprocessMixin:
return
was_running = self._supervisor.is_running()
resume_seq = getattr(self, "_stop_request_seq", 0) + 1
if was_running:
self._log("Pipeline paused for exclusive hardware capture")
self._stop_run()
if not self._pipeline_resume_allowed(resume_seq):
return
self._resume_pipeline_after_capture = was_running
@@ -398,6 +408,8 @@ class AppWindowPreprocessMixin:
def _create_neutral_sets(self) -> None:
"""Save neutral S21 calibration/reference sets for the current radar settings."""
if getattr(self, "_closing", False) or getattr(self, "_stopping_run", False):
return
if self._capture_session is not None:
self._show_error(
"Cannot create neutral sets during active capture sequence",
@@ -412,11 +424,12 @@ class AppWindowPreprocessMixin:
return
pipeline_was_paused = False
resume_seq = getattr(self, "_stop_request_seq", 0) + 1
try:
config = self._build_config()
if not supports_neutral_preprocess_sets(config):
self._show_error(
"Neutral S21 sets are available only for kamil_adc and librevna_multi"
"Neutral S21 sets are not supported for this radar configuration"
)
return
@@ -435,11 +448,14 @@ class AppWindowPreprocessMixin:
self._log("Pipeline paused for neutral-set creation")
self._stop_run()
pipeline_was_paused = True
if not self._pipeline_resume_allowed(resume_seq):
return
calibration, reference = build_neutral_s21_sets(config)
point_count = int(calibration.traces[0].frequency_hz.size)
self._store.save_set("s21_calibration", radar_key, set_name, calibration)
self._store.save_set("s21_reference", radar_key, set_name, reference)
self._store.save_sets(radar_key, set_name, {
"s21_calibration": calibration, "s21_reference": reference,
})
self._selected_preprocess_sets["s21_calibration"] = set_name
self._selected_preprocess_sets["s21_reference"] = set_name
@@ -458,7 +474,7 @@ class AppWindowPreprocessMixin:
except Exception as exc: # noqa: BLE001
self._show_exception("Failed to create neutral S21 sets", exc)
finally:
if pipeline_was_paused:
if pipeline_was_paused and self._pipeline_resume_allowed(resume_seq):
self._start_run()
def _build_single_radar_capture_session(
@@ -556,19 +572,24 @@ class AppWindowPreprocessMixin:
display_name = preprocess_asset_display_name(session.kind)
dialog = self._ensure_preprocess_dialog()
stop_seq = getattr(self, "_stop_request_seq", 0)
dialog.set_status(f"{display_name} batch capture started")
self._log(
f"{display_name} batch capture started: remaining="
f"{session.state().total_count - session.state().captured_count}"
)
try:
while not session.is_complete():
while self._capture_session is session and self._pipeline_resume_allowed(stop_seq) and not session.is_complete():
try:
capture_result = session.capture_current_combo()
except Exception as exc: # noqa: BLE001
self._on_capture_combo_failed(session, exc)
return
self._record_preprocess_capture(session, capture_result)
if not session.is_complete():
self._pump_events_during_drain(0.01)
if self._capture_session is session and not session.is_complete():
dialog.set_status(f"{display_name} batch capture paused; previous captures kept")
finally:
self._end_preprocess_capture()
@@ -578,7 +599,7 @@ class AppWindowPreprocessMixin:
Returns False for a duplicate request (e.g. a click delivered while an
error dialog inside a capture pumps the event loop).
"""
if self._preprocess_capture_busy:
if getattr(self, "_closing", False) or self._preprocess_capture_busy:
self._log("Preprocess combo capture already in progress; ignoring duplicate request.")
return False
self._preprocess_capture_busy = True