init commit
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
"""Runtime helpers for GUI polling, history management, and constraints."""
|
||||
|
||||
from python_app.gui.runtime.constraints import validate_processing_mode_constraints
|
||||
from python_app.gui.runtime.history import (
|
||||
build_run_history_signature,
|
||||
record_result_history,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"build_run_history_signature",
|
||||
"record_result_history",
|
||||
"validate_processing_mode_constraints",
|
||||
]
|
||||
@@ -0,0 +1,21 @@
|
||||
"""Validation helpers for GUI processing mode constraints."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from python_app.models.run_config_model import RunConfigModel
|
||||
|
||||
|
||||
def validate_processing_mode_constraints(processing_mode: str, config: RunConfigModel) -> None:
|
||||
"""Validate mode-specific constraints for current run configuration."""
|
||||
if processing_mode != "bscan":
|
||||
return
|
||||
|
||||
any_native_switch = config.input_switch.driver_mode == "native" or config.output_switch.driver_mode == "native"
|
||||
if not any_native_switch:
|
||||
return
|
||||
|
||||
combo_count = len({(int(combo.input), int(combo.output)) for combo in config.combos})
|
||||
if combo_count != 1:
|
||||
raise RuntimeError(
|
||||
f"B-scan with native switches requires exactly one run combo (now {combo_count})"
|
||||
)
|
||||
@@ -0,0 +1,53 @@
|
||||
"""Helpers for GUI-side runtime history management."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections import deque
|
||||
|
||||
from python_app.models.dataset_model import ResultCollection
|
||||
from python_app.models.run_config_model import RunConfigModel
|
||||
|
||||
|
||||
def record_result_history(
|
||||
result_history: deque[ResultCollection],
|
||||
collection: ResultCollection,
|
||||
) -> bool:
|
||||
"""Append new result or replace existing entry by stable collection key."""
|
||||
for index in range(len(result_history) - 1, -1, -1):
|
||||
existing = result_history[index]
|
||||
if (
|
||||
existing.collection_id == collection.collection_id
|
||||
and existing.monotonic_ns == collection.monotonic_ns
|
||||
):
|
||||
result_history[index] = collection
|
||||
return True
|
||||
|
||||
result_history.append(collection)
|
||||
return True
|
||||
|
||||
|
||||
def build_run_history_signature(
|
||||
config: RunConfigModel,
|
||||
) -> tuple[object, ...]:
|
||||
"""Build deterministic signature to detect run-settings changes (excluding live processing params)."""
|
||||
combos_signature = tuple((int(combo.input), int(combo.output)) for combo in config.combos)
|
||||
return (
|
||||
str(config.radar.driver_mode),
|
||||
str(config.radar.serial),
|
||||
float(config.radar.sweep.start_hz),
|
||||
float(config.radar.sweep.stop_hz),
|
||||
int(config.radar.sweep.points),
|
||||
float(config.radar.sweep.if_bandwidth_hz),
|
||||
float(config.radar.sweep.power_dbm),
|
||||
str(config.input_switch.driver_mode),
|
||||
str(config.input_switch.driver),
|
||||
int(config.input_switch.positions),
|
||||
bool(config.input_switch.invert_logic),
|
||||
str(config.output_switch.driver_mode),
|
||||
str(config.output_switch.driver),
|
||||
int(config.output_switch.positions),
|
||||
bool(config.output_switch.invert_logic),
|
||||
str(config.preprocess.calibration_set),
|
||||
str(config.preprocess.reference_set),
|
||||
combos_signature,
|
||||
)
|
||||
Reference in New Issue
Block a user