working version

This commit is contained in:
Ayzen
2026-05-18 17:27:00 +03:00
parent 907dbf29ce
commit 0da8b1283c
23 changed files with 1479 additions and 133 deletions
@@ -88,6 +88,7 @@ class AppWindowLiveProcessingMixin:
gpr_background_subtract_enabled=gpr_background_enabled,
gpr_background_mean_count=gpr_background_mean_count,
gpr_remove_sidelobe_objects_enabled=bool(self._gpr_remove_sidelobe_objects_enabled.isChecked()),
gpr_imaging_plane_y_m=float(self._gpr_imaging_plane_y_m.value()),
reprocess_current_result=bool(reprocess_current_result),
history_command_seq=int(self._history_command_seq),
history_command=str(history_command),
@@ -213,6 +214,7 @@ class AppWindowLiveProcessingMixin:
"Processing mode selected: pass_through "
f"(show_magnitude={self._show_magnitude_checkbox.isChecked()}, "
f"show_phase={self._show_phase_checkbox.isChecked()}, "
f"combos={self._pass_through_combo_filter_input.text().strip() or '<all>'}, "
f"fixed_y={self._pass_through_fixed_y_enabled.isChecked()}, "
f"y_range={self._pass_through_y_min_db.value():g}..{self._pass_through_y_max_db.value():g} dB)"
)
@@ -239,6 +241,7 @@ class AppWindowLiveProcessingMixin:
f"background_subtract={self._gpr_background_subtract_enabled.isChecked()}, "
f"mean_count={self._gpr_background_mean_count.value()}, "
f"remove_sidelobes={self._gpr_remove_sidelobe_objects_enabled.isChecked()}, "
f"imaging_plane_y={self._gpr_imaging_plane_y_m.value():g} m, "
f"render_mode={self._gpr_render_mode.currentText()}, "
f"min_score={self._gpr_min_visible_score.value():g}, "
f"max_draw={self._gpr_max_detected_objects_to_draw.value()}, "
@@ -235,6 +235,7 @@ class AppWindowConfigProfileIOMixin:
self._processing_mode,
self._show_magnitude_checkbox,
self._show_phase_checkbox,
self._pass_through_combo_filter_input,
self._pass_through_fixed_y_enabled,
self._pass_through_y_min_db,
self._pass_through_y_max_db,
@@ -262,6 +263,7 @@ class AppWindowConfigProfileIOMixin:
self._gpr_background_subtract_enabled,
self._gpr_background_mean_count,
self._gpr_remove_sidelobe_objects_enabled,
self._gpr_imaging_plane_y_m,
self._gpr_render_mode,
self._gpr_min_visible_score,
self._gpr_visible_x_min_m,
@@ -378,6 +380,7 @@ class AppWindowConfigProfileIOMixin:
self._set_combo_current_text(self._processing_mode, gui_state.processing.selected_mode)
self._show_magnitude_checkbox.setChecked(bool(gui_state.processing.pass_through.show_magnitude))
self._show_phase_checkbox.setChecked(bool(gui_state.processing.pass_through.show_phase))
self._pass_through_combo_filter_input.setText(str(gui_state.processing.pass_through.combo_filter))
self._pass_through_fixed_y_enabled.setChecked(bool(gui_state.processing.pass_through.fixed_y_enabled))
self._pass_through_y_min_db.setValue(float(gui_state.processing.pass_through.y_min_db))
self._pass_through_y_max_db.setValue(float(gui_state.processing.pass_through.y_max_db))
@@ -423,6 +426,7 @@ class AppWindowConfigProfileIOMixin:
self._gpr_remove_sidelobe_objects_enabled.setChecked(
bool(gui_state.processing.gpr.remove_sidelobe_objects_enabled)
)
self._gpr_imaging_plane_y_m.setValue(float(gui_state.processing.gpr.imaging_plane_y_m))
self._set_combo_current_text(self._gpr_render_mode, gui_state.processing.gpr.render_mode)
self._gpr_min_visible_score.setValue(float(gui_state.processing.gpr.min_visible_score))
self._gpr_visible_x_min_m.setValue(float(gui_state.processing.gpr.visible_x_min_m))
@@ -65,41 +65,49 @@ class AppWindowConfigStateBuildersMixin:
env[key] = value
return env
@staticmethod
def _parse_geometry_line_coordinates(parts: list[str]) -> tuple[float, float, float]:
"""Parse 1/2/3 trailing coordinate fields into (x, y, z); missing axes default to 0."""
x_m = float(parts[0])
y_m = float(parts[1]) if len(parts) >= 2 else 0.0
z_m = float(parts[2]) if len(parts) >= 3 else 0.0
return x_m, y_m, z_m
@staticmethod
def _parse_gpr_tx_geometry_text(text: str) -> list[GprTxGeometryModel]:
"""Parse line-based Tx geometry editor text."""
"""Parse line-based Tx geometry editor text: `output_pos x_m [y_m] [z_m]`."""
entries: list[GprTxGeometryModel] = []
for line_number, raw_line in enumerate(text.splitlines(), start=1):
line = raw_line.strip()
if not line:
continue
parts = line.split()
if len(parts) != 2:
raise ValueError(f"Invalid Tx geometry line {line_number}: expected `output_pos x_m`")
entries.append(
GprTxGeometryModel(
output_pos=int(parts[0]),
x_m=float(parts[1]),
if len(parts) < 2 or len(parts) > 4:
raise ValueError(
f"Invalid Tx geometry line {line_number}: expected `output_pos x_m [y_m] [z_m]`"
)
x_m, y_m, z_m = AppWindowConfigStateBuildersMixin._parse_geometry_line_coordinates(parts[1:])
entries.append(
GprTxGeometryModel(output_pos=int(parts[0]), x_m=x_m, y_m=y_m, z_m=z_m)
)
return entries
@staticmethod
def _parse_gpr_rx_geometry_text(text: str) -> list[GprRxGeometryModel]:
"""Parse line-based Rx geometry editor text."""
"""Parse line-based Rx geometry editor text: `input_pos x_m [y_m] [z_m]`."""
entries: list[GprRxGeometryModel] = []
for line_number, raw_line in enumerate(text.splitlines(), start=1):
line = raw_line.strip()
if not line:
continue
parts = line.split()
if len(parts) != 2:
raise ValueError(f"Invalid Rx geometry line {line_number}: expected `input_pos x_m`")
entries.append(
GprRxGeometryModel(
input_pos=int(parts[0]),
x_m=float(parts[1]),
if len(parts) < 2 or len(parts) > 4:
raise ValueError(
f"Invalid Rx geometry line {line_number}: expected `input_pos x_m [y_m] [z_m]`"
)
x_m, y_m, z_m = AppWindowConfigStateBuildersMixin._parse_geometry_line_coordinates(parts[1:])
entries.append(
GprRxGeometryModel(input_pos=int(parts[0]), x_m=x_m, y_m=y_m, z_m=z_m)
)
return entries
@@ -175,6 +183,7 @@ class AppWindowConfigStateBuildersMixin:
pass_through=GuiPassThroughStateModel(
show_magnitude=True,
show_phase=True,
combo_filter="",
fixed_y_enabled=False,
y_min_db=-100.0,
y_max_db=0.0,
@@ -203,6 +212,7 @@ class AppWindowConfigStateBuildersMixin:
background_subtract_enabled=True,
background_mean_count=10,
remove_sidelobe_objects_enabled=True,
imaging_plane_y_m=0.0,
render_mode="heatmap",
min_visible_score=0.0,
visible_x_min_m=default_gpr_x_min_m,
@@ -287,6 +297,7 @@ class AppWindowConfigStateBuildersMixin:
pass_through=GuiPassThroughStateModel(
show_magnitude=bool(self._show_magnitude_checkbox.isChecked()),
show_phase=bool(self._show_phase_checkbox.isChecked()),
combo_filter=self._pass_through_combo_filter_input.text().strip(),
fixed_y_enabled=bool(self._pass_through_fixed_y_enabled.isChecked()),
y_min_db=float(self._pass_through_y_min_db.value()),
y_max_db=float(self._pass_through_y_max_db.value()),
@@ -315,6 +326,7 @@ class AppWindowConfigStateBuildersMixin:
background_subtract_enabled=bool(self._gpr_background_subtract_enabled.isChecked()),
background_mean_count=int(self._gpr_background_mean_count.value()),
remove_sidelobe_objects_enabled=bool(self._gpr_remove_sidelobe_objects_enabled.isChecked()),
imaging_plane_y_m=float(self._gpr_imaging_plane_y_m.value()),
render_mode=self._gpr_render_mode.currentText(),
min_visible_score=float(self._gpr_min_visible_score.value()),
visible_x_min_m=float(self._gpr_visible_x_min_m.value()),
@@ -7,6 +7,7 @@ import numpy as np
import pyqtgraph as pg
from python_app.models.dataset_model import ResultCollection, TraceData
from python_app.models.run_config_model import parse_combos_from_text
class AppWindowTracePlotMixin:
@@ -26,6 +27,24 @@ class AppWindowTracePlotMixin:
y_max = float(self._pass_through_y_max_db.value())
return bool(self._pass_through_fixed_y_enabled.isChecked()), min(y_min, y_max), max(y_min, y_max)
def _pass_through_combo_filter(self) -> set[tuple[int, int]] | None:
"""Return selected pass-through switch combos, or `None` when all are visible."""
text = self._pass_through_combo_filter_input.text().strip()
if not text:
return None
try:
return {
(int(combo.input), int(combo.output))
for combo in parse_combos_from_text(text)
}
except Exception as exc: # noqa: BLE001
self._log_warning(
"Invalid pass-through switch-combo filter.",
details=f"{exc}\nExpected format: input:output,input:output",
once_key=f"pass_through_combo_filter_invalid_{text}",
)
return set()
def _configure_pass_through_magnitude_axis(self, plot: pg.PlotWidget) -> None:
"""Apply pass-through magnitude-axis autorange or fixed Y window."""
fixed_y_enabled, y_min, y_max = self._pass_through_fixed_y_range()
@@ -91,6 +110,7 @@ class AppWindowTracePlotMixin:
if not show_magnitude and not show_phase:
self._clear_trace_plots()
return False
combo_filter = self._pass_through_combo_filter()
if show_magnitude:
mag_item = magnitude_plot.getPlotItem()
@@ -133,6 +153,8 @@ class AppWindowTracePlotMixin:
x_max = -np.inf
for block in collection.blocks:
combo_key = (int(block.combo.input_pos), int(block.combo.output_pos))
if combo_filter is not None and combo_key not in combo_filter:
continue
if combo_key not in combo_colors:
combo_colors[combo_key] = palette[len(combo_colors) % len(palette)]
color = combo_colors[combo_key]
@@ -480,10 +480,10 @@ class AppWindowPreprocessMixin:
try:
capture_result = session.capture_current_combo()
self._record_preprocess_capture(session, capture_result)
except Exception as exc: # noqa: BLE001
self._show_exception("Failed to capture preprocess combo", exc)
self._abort_capture_sequence()
self._on_capture_combo_failed(session, exc)
return
self._record_preprocess_capture(session, capture_result)
def _capture_all_remaining(self) -> None:
"""Capture all remaining combos for the active preprocess session."""
@@ -505,13 +505,36 @@ class AppWindowPreprocessMixin:
f"{display_name} batch capture started: remaining="
f"{session.state().total_count - session.state().captured_count}"
)
try:
while not session.is_complete():
while not session.is_complete():
try:
capture_result = session.capture_current_combo()
self._record_preprocess_capture(session, capture_result)
except Exception as exc: # noqa: BLE001
self._show_exception("Failed to capture preprocess combo", exc)
self._abort_capture_sequence()
except Exception as exc: # noqa: BLE001
self._on_capture_combo_failed(session, exc)
return
self._record_preprocess_capture(session, capture_result)
def _on_capture_combo_failed(
self,
session: SequentialCaptureSession | MultiRadarSequentialCaptureSession,
exc: BaseException,
) -> None:
"""Report a failed combo capture while preserving the session and prior captures."""
state = session.state()
combo = state.current_combo
combo_text = (
f"input={combo.input}, output={combo.output}" if combo is not None else "<unknown>"
)
self._show_exception(
f"Failed to capture combo {combo_text}; previous captures kept, retry when ready",
exc,
)
display_name = preprocess_asset_display_name(session.kind)
dialog = self._ensure_preprocess_dialog()
dialog.set_status(
f"{display_name} capture failed at {combo_text}: "
f"{state.captured_count}/{state.total_count} kept, ready to retry"
)
self._update_capture_dialog_state()
def _record_preprocess_capture(
self,
@@ -696,7 +719,11 @@ class AppWindowPreprocessMixin:
next_output=next_output,
can_undo=state.can_undo,
can_finalize=state.is_complete,
can_capture_all=(not state.is_complete and state.current_combo is not None),
can_capture_all=(
state.supports_batch_capture
and not state.is_complete
and state.current_combo is not None
),
variant_count=state.variant_count,
)
@@ -20,10 +20,19 @@ from PyQt6.QtWidgets import (
from python_app.gui.controllers.sections.layout_helpers import FormRow, build_two_column_form_widget
def _format_geometry_row(position: int, x_m: float, y_m: float, z_m: float) -> str:
"""Render one geometry row, trimming trailing zero y/z so 1D layouts stay compact."""
if z_m != 0.0:
return f"{position} {x_m:g} {y_m:g} {z_m:g}"
if y_m != 0.0:
return f"{position} {x_m:g} {y_m:g}"
return f"{position} {x_m:g}"
def _format_tx_geometry(owner) -> str:
"""Render Tx geometry defaults into editable line-based text."""
return "\n".join(
f"{int(entry.output_pos)} {float(entry.x_m):g}"
_format_geometry_row(int(entry.output_pos), float(entry.x_m), float(entry.y_m), float(entry.z_m))
for entry in owner._defaults_config.gpr.tx_geometry
)
@@ -31,7 +40,7 @@ def _format_tx_geometry(owner) -> str:
def _format_rx_geometry(owner) -> str:
"""Render Rx geometry defaults into editable line-based text."""
return "\n".join(
f"{int(entry.input_pos)} {float(entry.x_m):g}"
_format_geometry_row(int(entry.input_pos), float(entry.x_m), float(entry.y_m), float(entry.z_m))
for entry in owner._defaults_config.gpr.rx_geometry
)
@@ -71,6 +80,9 @@ def build_processing_group(owner) -> QGroupBox:
owner._show_phase_checkbox = QCheckBox("Show phase")
owner._show_phase_checkbox.setChecked(bool(pass_defaults.show_phase))
owner._pass_through_combo_filter_input = QLineEdit(str(pass_defaults.combo_filter))
owner._pass_through_combo_filter_input.setPlaceholderText("empty = all, e.g. 0:0,1:0")
owner._pass_through_fixed_y_enabled = QCheckBox("Fix magnitude Y range")
owner._pass_through_fixed_y_enabled.setChecked(bool(pass_defaults.fixed_y_enabled))
@@ -93,11 +105,12 @@ def build_processing_group(owner) -> QGroupBox:
[
owner._show_magnitude_checkbox,
owner._show_phase_checkbox,
("Switch combos", owner._pass_through_combo_filter_input),
owner._pass_through_fixed_y_enabled,
("Y min dB", owner._pass_through_y_min_db),
("Y max dB", owner._pass_through_y_max_db),
],
split_index=3,
split_index=4,
)
owner._processing_mode_pages.addWidget(pass_through_page)
@@ -162,11 +175,11 @@ def build_processing_group(owner) -> QGroupBox:
owner._gpr_relative_permittivity.setValue(float(gpr_defaults.relative_permittivity))
owner._gpr_tx_geometry_input = QPlainTextEdit(_format_tx_geometry(owner))
owner._gpr_tx_geometry_input.setPlaceholderText("output_pos x_m")
owner._gpr_tx_geometry_input.setPlaceholderText("output_pos x_m [y_m] [z_m]")
owner._gpr_tx_geometry_input.setFixedHeight(78)
owner._gpr_rx_geometry_input = QPlainTextEdit(_format_rx_geometry(owner))
owner._gpr_rx_geometry_input.setPlaceholderText("input_pos x_m")
owner._gpr_rx_geometry_input.setPlaceholderText("input_pos x_m [y_m] [z_m]")
owner._gpr_rx_geometry_input.setFixedHeight(78)
owner._gpr_common_page = _build_processing_mode_page(
@@ -277,6 +290,15 @@ def build_processing_group(owner) -> QGroupBox:
owner._gpr_visible_z_max_m.setSingleStep(0.1)
owner._gpr_visible_z_max_m.setValue(float(gpr_live_defaults.visible_z_max_m))
owner._gpr_imaging_plane_y_m = QDoubleSpinBox()
owner._gpr_imaging_plane_y_m.setDecimals(3)
owner._gpr_imaging_plane_y_m.setRange(-50.0, 50.0)
owner._gpr_imaging_plane_y_m.setSingleStep(0.05)
owner._gpr_imaging_plane_y_m.setValue(float(gpr_live_defaults.imaging_plane_y_m))
owner._gpr_imaging_plane_y_m.setToolTip(
"Y coordinate of the BP imaging slice (m). Use 0 for legacy 1D antenna layouts."
)
gpr_page = _build_processing_mode_page(
owner._processing_mode_pages,
[
@@ -293,6 +315,7 @@ def build_processing_group(owner) -> QGroupBox:
("Draw top M objects", owner._gpr_draw_top_m_objects),
("Start MHz", owner._gpr_start_freq_mhz),
("Stop MHz", owner._gpr_stop_freq_mhz),
("Imaging plane Y m", owner._gpr_imaging_plane_y_m),
("Visible X min m", owner._gpr_visible_x_min_m),
("Visible X max m", owner._gpr_visible_x_max_m),
("Visible Z min m", owner._gpr_visible_z_min_m),
@@ -445,6 +468,7 @@ def build_processing_group(owner) -> QGroupBox:
owner._processing_mode.currentTextChanged.connect(owner._on_processing_mode_changed)
owner._show_magnitude_checkbox.toggled.connect(owner._on_trace_visibility_changed)
owner._show_phase_checkbox.toggled.connect(owner._on_trace_visibility_changed)
owner._pass_through_combo_filter_input.editingFinished.connect(owner._on_trace_visibility_changed)
owner._pass_through_fixed_y_enabled.toggled.connect(owner._sync_pass_through_y_controls)
owner._pass_through_fixed_y_enabled.toggled.connect(owner._on_processing_live_settings_changed)
owner._pass_through_y_min_db.valueChanged.connect(owner._on_processing_live_settings_changed)
@@ -472,6 +496,7 @@ def build_processing_group(owner) -> QGroupBox:
owner._gpr_background_subtract_enabled.toggled.connect(owner._on_processing_live_settings_changed)
owner._gpr_background_mean_count.valueChanged.connect(owner._on_processing_live_settings_changed)
owner._gpr_remove_sidelobe_objects_enabled.toggled.connect(owner._on_processing_live_settings_changed)
owner._gpr_imaging_plane_y_m.valueChanged.connect(owner._on_processing_live_settings_changed)
owner._gpr_render_mode.currentTextChanged.connect(owner._on_gpr_visual_settings_changed)
owner._gpr_min_visible_score.valueChanged.connect(owner._on_gpr_locator_threshold_changed)
owner._gpr_max_detected_objects_to_draw.valueChanged.connect(owner._on_gpr_locator_threshold_changed)
@@ -49,10 +49,10 @@ def build_switch_group(owner) -> QGroupBox:
single_row = QHBoxLayout()
single_row.setSpacing(8)
single_row.addWidget(QLabel("Single combo"))
single_row.addWidget(QLabel("Output"))
single_row.addWidget(owner._single_combo_output)
single_row.addWidget(QLabel("Input"))
single_row.addWidget(owner._single_combo_input)
single_row.addWidget(QLabel("Output"))
single_row.addWidget(owner._single_combo_output)
single_row.addWidget(owner._single_combo_select_button)
layout.addLayout(single_row)
@@ -93,6 +93,14 @@ class MultiDeviceVnaController:
if not self._reference_configuration_applied:
self._configure_reference_clocks()
# Even when the device-side configuration matches and we skip reconfiguration,
# the host-side packet queue has been accumulating datapoints from cycles that
# ran between calls. Draining here guarantees the next collect_running_sweep_cycles
# returns a freshly-arriving cycle (the cycle tracker waits for point_index==0).
# Without this drain, callers would receive whichever stale cycle happened to be
# at the head of the queue — e.g. data from before a manual cable swap.
self._drain_all_received_packets()
if (
self._sweep_is_running
and self._last_applied_sweep_configuration == sweep_configuration
@@ -104,7 +112,6 @@ class MultiDeviceVnaController:
self._send_idle_to_all_devices()
time.sleep(self._reconfigure_delay_s)
self._drain_all_received_packets()
self._configure_sweep_on_all_devices(
sweep_configuration,
master_stimulus_ports=stimulus_ports,
+14
View File
@@ -180,6 +180,12 @@ def gui_profile_from_dict(payload: dict[str, Any]) -> GuiProfileModel:
gui.processing.pass_through.show_phase,
"gui.processing.pass_through",
),
combo_filter=_optional_string(
pass_through_object,
"combo_filter",
gui.processing.pass_through.combo_filter,
"gui.processing.pass_through",
),
fixed_y_enabled=_optional_bool(
pass_through_object,
"fixed_y_enabled",
@@ -313,6 +319,12 @@ def gui_profile_from_dict(payload: dict[str, Any]) -> GuiProfileModel:
gui.processing.gpr.remove_sidelobe_objects_enabled,
"gui.processing.gpr",
),
imaging_plane_y_m=_optional_float(
gpr_object,
"imaging_plane_y_m",
gui.processing.gpr.imaging_plane_y_m,
"gui.processing.gpr",
),
render_mode=_optional_string(
gpr_object,
"render_mode",
@@ -482,6 +494,7 @@ def gui_profile_to_dict(model: GuiProfileModel) -> dict[str, Any]:
"pass_through": {
"show_magnitude": gui.processing.pass_through.show_magnitude,
"show_phase": gui.processing.pass_through.show_phase,
"combo_filter": gui.processing.pass_through.combo_filter,
"fixed_y_enabled": gui.processing.pass_through.fixed_y_enabled,
"y_min_db": gui.processing.pass_through.y_min_db,
"y_max_db": gui.processing.pass_through.y_max_db,
@@ -510,6 +523,7 @@ def gui_profile_to_dict(model: GuiProfileModel) -> dict[str, Any]:
"background_subtract_enabled": gui.processing.gpr.background_subtract_enabled,
"background_mean_count": gui.processing.gpr.background_mean_count,
"remove_sidelobe_objects_enabled": gui.processing.gpr.remove_sidelobe_objects_enabled,
"imaging_plane_y_m": gui.processing.gpr.imaging_plane_y_m,
"render_mode": gui.processing.gpr.render_mode,
"min_visible_score": gui.processing.gpr.min_visible_score,
"visible_x_min_m": gui.processing.gpr.visible_x_min_m,
+2
View File
@@ -27,6 +27,7 @@ class GuiPassThroughStateModel:
show_magnitude: bool = True
show_phase: bool = True
combo_filter: str = ""
fixed_y_enabled: bool = False
y_min_db: float = -100.0
y_max_db: float = 0.0
@@ -63,6 +64,7 @@ class GuiGprStateModel:
background_subtract_enabled: bool = True
background_mean_count: int = 10
remove_sidelobe_objects_enabled: bool = True
imaging_plane_y_m: float = 0.0
render_mode: str = "heatmap"
min_visible_score: float = 0.0
visible_x_min_m: float = -2.0
+8
View File
@@ -327,6 +327,8 @@ def run_config_from_dict(payload: dict[str, Any]) -> RunConfigModel:
GprTxGeometryModel(
output_pos=int(entry_payload.get("output_pos", 0)),
x_m=float(entry_payload.get("x_m", 0.0)),
y_m=float(entry_payload.get("y_m", 0.0)),
z_m=float(entry_payload.get("z_m", 0.0)),
)
)
model.gpr.rx_geometry = []
@@ -338,6 +340,8 @@ def run_config_from_dict(payload: dict[str, Any]) -> RunConfigModel:
GprRxGeometryModel(
input_pos=int(entry_payload.get("input_pos", 0)),
x_m=float(entry_payload.get("x_m", 0.0)),
y_m=float(entry_payload.get("y_m", 0.0)),
z_m=float(entry_payload.get("z_m", 0.0)),
)
)
model.apply_device_model_constraints()
@@ -519,6 +523,8 @@ def run_config_to_dict(model: RunConfigModel) -> dict[str, Any]:
{
"output_pos": entry.output_pos,
"x_m": entry.x_m,
"y_m": entry.y_m,
"z_m": entry.z_m,
}
for entry in model.gpr.tx_geometry
],
@@ -526,6 +532,8 @@ def run_config_to_dict(model: RunConfigModel) -> dict[str, Any]:
{
"input_pos": entry.input_pos,
"x_m": entry.x_m,
"y_m": entry.y_m,
"z_m": entry.z_m,
}
for entry in model.gpr.rx_geometry
],
+8 -1
View File
@@ -223,10 +223,15 @@ class PreprocessModel:
@dataclass(slots=True)
class GprTxGeometryModel:
"""One transmitter geometry record keyed by output switch position."""
"""One transmitter geometry record keyed by output switch position.
y_m / z_m default to 0 so 1D antenna layouts keep their pre-3D semantics.
"""
output_pos: int = 0
x_m: float = 0.0
y_m: float = 0.0
z_m: float = 0.0
@dataclass(slots=True)
@@ -235,6 +240,8 @@ class GprRxGeometryModel:
input_pos: int = 0
x_m: float = 0.0
y_m: float = 0.0
z_m: float = 0.0
@dataclass(slots=True)
@@ -43,6 +43,7 @@ class ProcessingLiveConfig:
gpr_background_subtract_enabled: bool = True
gpr_background_mean_count: int = 10
gpr_remove_sidelobe_objects_enabled: bool = True
gpr_imaging_plane_y_m: float = 0.0
reprocess_current_result: bool = True
history_command_seq: int = 0
history_command: str = "none"
@@ -93,6 +94,7 @@ class ProcessingLiveConfig:
"gpr_background_subtract_enabled": bool(self.gpr_background_subtract_enabled),
"gpr_background_mean_count": int(self.gpr_background_mean_count),
"gpr_remove_sidelobe_objects_enabled": bool(self.gpr_remove_sidelobe_objects_enabled),
"gpr_imaging_plane_y_m": float(self.gpr_imaging_plane_y_m),
"reprocess_current_result": bool(self.reprocess_current_result),
"history_command_seq": int(self.history_command_seq),
"history_command": str(self.history_command),
@@ -0,0 +1,35 @@
"""Tests for GUI profile persistence."""
from __future__ import annotations
import unittest
from python_app.models.gui_profile_model import (
GuiPassThroughStateModel,
GuiProcessingStateModel,
GuiProfileModel,
GuiStateModel,
)
class GuiProfileCodecTest(unittest.TestCase):
def test_pass_through_combo_filter_round_trips(self) -> None:
profile = GuiProfileModel(
gui=GuiStateModel(
processing=GuiProcessingStateModel(
pass_through=GuiPassThroughStateModel(combo_filter="0:0,1:0")
)
)
)
encoded = profile.to_dict()
decoded = GuiProfileModel.from_dict(encoded)
self.assertIsNotNone(decoded.gui)
assert decoded.gui is not None
self.assertEqual(decoded.gui.processing.pass_through.combo_filter, "0:0,1:0")
self.assertEqual(encoded["gui"]["processing"]["pass_through"]["combo_filter"], "0:0,1:0")
if __name__ == "__main__":
unittest.main()
@@ -176,6 +176,7 @@ class MultiRadarSequentialCaptureSession:
can_undo=bool(self._captured_batches),
is_complete=self.is_complete(),
variant_count=len(self._radar_variants),
supports_batch_capture=not self._manual_multi_device_capture,
)
def capture_current_combo(self) -> MultiRadarCaptureBatch:
@@ -186,9 +187,11 @@ class MultiRadarSequentialCaptureSession:
if combo is None:
raise RuntimeError("Capture session is already complete")
pending_traces_by_radar_key: dict[str, list[TraceData]] = {}
display_traces: list[TraceData] = []
variant_labels: list[str] = []
if self._is_multi_device:
traces: list[TraceData] = []
variant_labels: list[str] = []
for variant in self._radar_variants:
self._radar.configure(variant.config.radar.sweep)
if self._base_config.runtime.settling_ms > 0:
@@ -198,56 +201,47 @@ class MultiRadarSequentialCaptureSession:
raise RuntimeError(f"Multi-device variant {variant.display_name} returned no traces")
if self._manual_multi_device_capture:
trace = select_trace_for_combo(collection, combo)
self._traces_by_radar_key[variant.radar_key].append(trace)
traces.append(trace)
pending_traces_by_radar_key[variant.radar_key] = [trace]
display_traces.append(trace)
else:
self._traces_by_radar_key[variant.radar_key].extend(collection.traces)
traces.append(collection.traces[-1])
pending_traces_by_radar_key[variant.radar_key] = list(collection.traces)
display_traces.append(collection.traces[-1])
variant_labels.append(variant.display_name)
batch = MultiRadarCaptureBatch(
combo=combo,
traces=tuple(traces),
variant_labels=tuple(variant_labels),
)
self._captured_batches.append(batch)
if self._manual_multi_device_capture:
self._next_index += 1
else:
self._next_index = len(self._combos)
return batch
assert self._input_switch is not None
assert self._output_switch is not None
self._output_switch.switch_to(combo.output)
self._input_switch.switch_to(combo.input)
if self._base_config.runtime.settling_ms > 0:
time.sleep(self._base_config.runtime.settling_ms / 1000.0)
traces: list[TraceData] = []
variant_labels: list[str] = []
for variant in self._radar_variants:
self._radar.configure(variant.config.radar.sweep)
else:
assert self._input_switch is not None
assert self._output_switch is not None
self._output_switch.switch_to(combo.output)
self._input_switch.switch_to(combo.input)
if self._base_config.runtime.settling_ms > 0:
time.sleep(self._base_config.runtime.settling_ms / 1000.0)
sweep = self._radar.acquire()
trace = TraceData(
combo=ComboKey(input_pos=combo.input, output_pos=combo.output),
frequency_hz=np.asarray(sweep.x, dtype=np.float32),
s11=np.asarray(sweep.trace("s11"), dtype=np.complex64),
s21=np.asarray(sweep.trace("s21"), dtype=np.complex64),
)
traces.append(trace)
variant_labels.append(variant.display_name)
self._traces_by_radar_key[variant.radar_key].append(trace)
for variant in self._radar_variants:
self._radar.configure(variant.config.radar.sweep)
if self._base_config.runtime.settling_ms > 0:
time.sleep(self._base_config.runtime.settling_ms / 1000.0)
sweep = self._radar.acquire()
trace = TraceData(
combo=ComboKey(input_pos=combo.input, output_pos=combo.output),
frequency_hz=np.asarray(sweep.x, dtype=np.float32),
s11=np.asarray(sweep.trace("s11"), dtype=np.complex64),
s21=np.asarray(sweep.trace("s21"), dtype=np.complex64),
)
pending_traces_by_radar_key[variant.radar_key] = [trace]
display_traces.append(trace)
variant_labels.append(variant.display_name)
for radar_key, traces in pending_traces_by_radar_key.items():
self._traces_by_radar_key[radar_key].extend(traces)
batch = MultiRadarCaptureBatch(
combo=combo,
traces=tuple(traces),
traces=tuple(display_traces),
variant_labels=tuple(variant_labels),
)
self._captured_batches.append(batch)
self._next_index += 1
if self._is_multi_device and not self._manual_multi_device_capture:
self._next_index = len(self._combos)
else:
self._next_index += 1
return batch
def undo_last_capture(self) -> MultiRadarCaptureBatch:
@@ -30,6 +30,7 @@ class SequentialCaptureState:
can_undo: bool
is_complete: bool
variant_count: int = 1
supports_batch_capture: bool = True
class SequentialCaptureSession:
@@ -141,6 +142,7 @@ class SequentialCaptureSession:
current_combo=current_combo,
can_undo=bool(self._traces),
is_complete=self.is_complete(),
supports_batch_capture=not self._manual_multi_device_capture,
)
def capture_current_combo(self) -> TraceData:
@@ -153,6 +155,8 @@ class SequentialCaptureSession:
if self._is_multi_device:
collection = self._radar.acquire_collection(collection_id=1)
if not collection.traces:
raise RuntimeError("Multi-device capture returned no traces")
if self._manual_multi_device_capture:
trace = select_trace_for_combo(collection, combo)
self._traces.append(trace)
@@ -161,8 +165,6 @@ class SequentialCaptureSession:
self._traces.extend(collection.traces)
self._next_index = len(self._combos)
if not collection.traces:
raise RuntimeError("Multi-device capture returned no traces")
return collection.traces[-1]
assert self._input_switch is not None