added s11 collections

This commit is contained in:
Ayzen
2026-03-26 15:48:16 +03:00
parent 9581730e41
commit 24f7ebb2fb
22 changed files with 184 additions and 859 deletions
@@ -6,7 +6,7 @@ from pathlib import Path
import time
from PyQt6.QtWidgets import QFileDialog
from python_app.gui.runtime.history import record_result_history
from python_app.gui.runtime.history import record_result_history, remove_last_aligned_histories
class AppWindowSnapshotMixin:
@@ -90,16 +90,27 @@ class AppWindowSnapshotMixin:
except Exception as exc: # noqa: BLE001
self._show_error(f"Failed to save VNA history JSON: {exc}")
def _remove_last_runtime_history(self) -> None:
"""Remove the newest runtime measurement from all stages and processor replay state."""
self._apply_runtime_history_deletion(remove_last_only=True)
def _clear_all_runtime_history(self) -> None:
"""Clear all runtime histories, ring backlogs, and processor replay state."""
self._apply_runtime_history_deletion(remove_last_only=False)
def _apply_runtime_history_deletion(self, *, remove_last_only: bool) -> None:
"""Apply destructive runtime-history deletion across readers, caches, and processor replay state."""
if self._capture_session is not None:
self._show_error("Cannot clear runtime history during active capture sequence")
self._show_error("Cannot modify runtime history during active capture sequence")
return
resume_acquisition = self._supervisor.is_running()
dropped_raw = 0
dropped_pre = 0
dropped_results = 0
history_command = "remove_last" if remove_last_only else "clear_all"
action_label = "last runtime measurement removed" if remove_last_only else "runtime history fully cleared"
error_action = "remove last runtime measurement" if remove_last_only else "clear runtime history"
try:
if resume_acquisition:
@@ -109,23 +120,36 @@ class AppWindowSnapshotMixin:
dropped_pre = self._pre_reader.drop_all() if self._pre_reader is not None else 0
dropped_results = self._result_reader.drop_all() if self._result_reader is not None else 0
self._replace_runtime_history(retained_raw=[], retained_pre=[], retained_result=[])
if remove_last_only:
retained_raw, retained_pre, retained_result = remove_last_aligned_histories(
list(self._raw_history),
list(self._pre_history),
list(self._result_history),
)
else:
retained_raw = []
retained_pre = []
retained_result = []
self._replace_runtime_history(
retained_raw=retained_raw,
retained_pre=retained_pre,
retained_result=retained_result,
)
self._bscan_history_floor_collection_id = 0
self._clear_history_mode_caches()
# Clear processor-side replay cache so newly rendered B-scan starts clean.
self._write_live_processing_config(history_command="clear_all", bump_history_seq=True)
self._write_live_processing_config(history_command=history_command, bump_history_seq=True)
if self._supervisor.is_processor_running():
self._drain_results_until_quiet(timeout_s=0.25, poll_s=0.01)
self._drain_results_until_quiet(timeout_s=0.35, poll_s=0.01)
if self._result_reader is not None:
dropped_results += self._result_reader.drop_all()
self._result_history.clear()
self._update_history_indicator()
self._redraw_after_history_deletion()
self._log(
"Runtime history fully cleared: "
f"{action_label}: "
f"dropped raw={dropped_raw}, "
f"preprocessed={dropped_pre}, "
f"results={dropped_results}"
@@ -134,7 +158,7 @@ class AppWindowSnapshotMixin:
if resume_acquisition:
self._start_run()
except Exception as exc: # noqa: BLE001
self._show_error(f"Failed to clear runtime history: {exc}")
self._show_error(f"Failed to {error_action}: {exc}")
def _browse_save_path(self) -> None:
"""Open directory picker for snapshot output path."""