added s11!

This commit is contained in:
Ayzen
2026-03-26 18:29:42 +03:00
parent 9ddbde22bd
commit 077542cbd0
43 changed files with 713 additions and 347 deletions
@@ -3,11 +3,17 @@
from __future__ import annotations
from python_app.gui.preprocess_dialog import PreprocessDialog
from python_app.orchestration.preprocess_assets import (
PREPROCESS_ASSET_KEYS,
PREPROCESS_ASSET_SPECS,
preprocess_asset_channel,
preprocess_asset_display_name,
)
from python_app.workflows.sequential_capture_workflow import SequentialCaptureSession
class AppWindowPreprocessMixin:
"""Handles calibration/reference set management and capture workflow."""
"""Handles preprocess set management and sequential capture workflows."""
def _open_preprocess_panel(self) -> None:
"""Open preprocessing dialog and refresh available sets."""
@@ -38,39 +44,39 @@ class AppWindowPreprocessMixin:
self._update_capture_dialog_state()
return dialog
def _on_preprocess_selection_changed(self, calibration_set: str, reference_set: str) -> None:
def _on_preprocess_selection_changed(self) -> None:
"""Persist selected preprocessing set names from dialog."""
self._selected_s21_calibration_set = calibration_set.strip()
self._selected_s21_reference_set = reference_set.strip()
dialog = self._ensure_preprocess_dialog()
self._selected_preprocess_sets = dialog.selection_snapshot()
self._refresh_preprocess_summary_labels()
def _refresh_preprocess_summary_labels(self) -> None:
"""Update compact summary labels in the main window."""
self._selected_calibration_label.setText(self._selected_s21_calibration_set or "<not selected>")
self._selected_reference_label.setText(self._selected_s21_reference_set or "<not selected>")
for key in PREPROCESS_ASSET_KEYS:
self._selected_preprocess_labels[key].setText(self._selected_preprocess_sets.get(key, "") or "<not selected>")
def _refresh_sets(self) -> None:
"""Refresh calibration/reference set lists for current radar key."""
"""Refresh preprocess set lists for current radar key."""
config = self._build_config()
radar_key = self._radar_key(config)
calibration_sets = self._store.list_sets("calibration", radar_key)
reference_sets = self._store.list_sets("reference", radar_key)
dialog = self._ensure_preprocess_dialog()
dialog.set_calibration_sets(calibration_sets)
dialog.set_reference_sets(reference_sets)
if self._selected_s21_calibration_set not in calibration_sets:
self._selected_s21_calibration_set = calibration_sets[0] if calibration_sets else ""
if self._selected_s21_reference_set not in reference_sets:
self._selected_s21_reference_set = reference_sets[0] if reference_sets else ""
available_sets = {
key: self._store.list_sets(PREPROCESS_ASSET_SPECS[key].set_kind, radar_key)
for key in PREPROCESS_ASSET_KEYS
}
dialog.set_available_sets(available_sets)
dialog.set_selected_sets(self._selected_s21_calibration_set, self._selected_s21_reference_set)
for key, names in available_sets.items():
if self._selected_preprocess_sets.get(key, "") not in names:
self._selected_preprocess_sets[key] = names[0] if names else ""
dialog.set_selected_sets(self._selected_preprocess_sets)
self._refresh_preprocess_summary_labels()
self._log(f"Set lists refreshed for key={radar_key}")
self._log(f"Preprocess set lists refreshed for key={radar_key}")
def _start_capture_sequence(self, kind: str) -> None:
"""Start sequential capture session for requested preprocessing kind."""
"""Start sequential capture session for requested preprocess asset."""
if self._capture_session is not None:
self._show_error("Another capture sequence is already active")
return
@@ -91,18 +97,19 @@ class AppWindowPreprocessMixin:
try:
config = self._build_config()
radar_key = self._radar_key(config)
existing_sets = self._store.list_sets(kind, radar_key)
existing_sets = self._store.list_sets(PREPROCESS_ASSET_SPECS[kind].set_kind, radar_key)
display_name = preprocess_asset_display_name(kind)
if set_name in existing_sets:
raise RuntimeError(f"Set '{set_name}' already exists for {kind} and cannot be overwritten")
raise RuntimeError(f"Set '{set_name}' already exists for {display_name} and cannot be overwritten")
session = SequentialCaptureSession(config=config, kind=kind, set_name=set_name)
session.open()
self._capture_session = session
dialog.clear_capture_log()
dialog.set_status(f"{kind.title()} sequence started")
dialog.set_status(f"{display_name} sequence started")
self._update_capture_dialog_state()
self._log(f"{kind.title()} sequence started for set={set_name}; fill all N*M combos")
self._log(f"{display_name} sequence started for set={set_name}; fill all N*M combos")
except Exception as exc: # noqa: BLE001
self._cleanup_capture_session()
self._show_error(f"Failed to start {kind} sequence: {exc}")
@@ -121,9 +128,11 @@ class AppWindowPreprocessMixin:
trace = session.capture_current_combo()
state = session.state()
tx_label, rx_label = dialog.antenna_labels()
display_name = preprocess_asset_display_name(session.kind)
channel = preprocess_asset_channel(session.kind)
dialog.append_capture_log_entry(
kind=session.kind,
kind=display_name,
captured_count=state.captured_count,
total_count=state.total_count,
input_pos=trace.combo.input_pos,
@@ -132,11 +141,11 @@ class AppWindowPreprocessMixin:
rx_label=rx_label,
)
dialog.draw_last_trace(trace, title=f"{session.kind.title()} captured")
self._draw_single_trace(trace, title=f"{session.kind.title()} last trace")
dialog.draw_last_trace(trace, title=f"{display_name} captured", channel=channel)
self._draw_single_trace(trace, title=f"{display_name} last trace", channel=channel)
self._log(
f"{session.kind.title()} capture: {state.captured_count}/{state.total_count} | "
f"{display_name} capture: {state.captured_count}/{state.total_count} | "
f"input={trace.combo.input_pos} output={trace.combo.output_pos}"
)
@@ -144,16 +153,13 @@ class AppWindowPreprocessMixin:
radar_key, collection = session.finalize(self._store)
set_name = session.set_name
kind = session.kind
display_name = preprocess_asset_display_name(kind)
self._cleanup_capture_session()
if kind == "calibration":
self._selected_s21_calibration_set = set_name
else:
self._selected_s21_reference_set = set_name
self._selected_preprocess_sets[kind] = set_name
self._refresh_sets()
dialog.set_status(f"{kind.title()} set saved: {set_name} ({len(collection.traces)} traces)")
self._log(f"{kind.title()} sequence completed and saved: set={set_name}, key={radar_key}")
dialog.set_status(f"{display_name} set saved: {set_name} ({len(collection.traces)} traces)")
self._log(f"{display_name} sequence completed and saved: set={set_name}, key={radar_key}")
self._resume_pipeline_if_needed()
else:
self._update_capture_dialog_state()
@@ -166,11 +172,11 @@ class AppWindowPreprocessMixin:
if self._capture_session is None:
return
kind = self._capture_session.kind
display_name = preprocess_asset_display_name(self._capture_session.kind)
self._cleanup_capture_session()
dialog = self._ensure_preprocess_dialog()
dialog.set_status(f"{kind.title()} sequence aborted")
self._log(f"{kind.title()} sequence aborted")
dialog.set_status(f"{display_name} sequence aborted")
self._log(f"{display_name} sequence aborted")
if resume_pipeline:
self._resume_pipeline_if_needed()