Refactor radar system
This commit is contained in:
@@ -10,6 +10,7 @@ from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
MAX_COMBOS = 4096
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
@@ -171,11 +172,7 @@ class RadarModel:
|
||||
|
||||
model: str = "librevna"
|
||||
serial: str = ""
|
||||
remote_host: str = "127.0.0.1"
|
||||
remote_port: int = 50209
|
||||
driver_mode: str = "mock"
|
||||
mock_signal_hz: float = 1_000_000.0
|
||||
visa_library: str = ""
|
||||
sweep: RadarSweepModel = field(default_factory=RadarSweepModel)
|
||||
multi_device: RadarMultiDeviceModel = field(default_factory=RadarMultiDeviceModel)
|
||||
replay: RadarReplayModel = field(default_factory=RadarReplayModel)
|
||||
@@ -377,9 +374,7 @@ class RunConfigModel:
|
||||
|
||||
LIBREVNA_MODEL = "librevna"
|
||||
LIBREVNA_MULTI_MODEL = "librevna_multi"
|
||||
COMPACT_M_K209_MODEL = "compact_m_k209"
|
||||
KAMIL_ADC_MODEL = "kamil_adc"
|
||||
SN9000_MODEL = "sn9000"
|
||||
MULTI_DEVICE_INPUT_POSITIONS = 4
|
||||
MULTI_DEVICE_OUTPUT_POSITIONS = 2
|
||||
# Stimulus ports the master itself owns. The virtual output axis is this times the
|
||||
@@ -390,39 +385,26 @@ class RunConfigModel:
|
||||
@staticmethod
|
||||
def build_full_combos(input_positions: int, output_positions: int) -> list[ComboModel]:
|
||||
"""Build full Cartesian product of input/output switch positions."""
|
||||
if any(isinstance(value, bool) or not isinstance(value, int) or value <= 0
|
||||
for value in (input_positions, output_positions)):
|
||||
raise ValueError("Switch positions must be positive integers")
|
||||
if input_positions * output_positions > MAX_COMBOS:
|
||||
raise ValueError(f"Too many combos: limit is {MAX_COMBOS}")
|
||||
return [
|
||||
ComboModel(input=input_pos, output=output_pos)
|
||||
for output_pos in range(output_positions)
|
||||
for input_pos in range(input_positions)
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def build_multi_device_virtual_combos(cls) -> list[ComboModel]:
|
||||
"""Build fixed virtual combo matrix for one master and two slave devices."""
|
||||
return cls.build_full_combos(
|
||||
cls.MULTI_DEVICE_INPUT_POSITIONS,
|
||||
cls.MULTI_DEVICE_OUTPUT_POSITIONS,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def build_matrix_radar_virtual_combos(cls) -> list[ComboModel]:
|
||||
"""Build the canonical 2x4 virtual combo matrix shared by matrix-mode radars."""
|
||||
return cls.build_multi_device_virtual_combos()
|
||||
|
||||
@property
|
||||
def is_multi_device(self) -> bool:
|
||||
"""Return whether this config targets synchronized multi-device acquisition."""
|
||||
return self.radar.model == self.LIBREVNA_MULTI_MODEL
|
||||
|
||||
@property
|
||||
def is_sn9000(self) -> bool:
|
||||
"""Return whether this config targets the SN9000 multi-port analyzer."""
|
||||
return self.radar.model == self.SN9000_MODEL
|
||||
|
||||
@property
|
||||
def is_matrix_radar(self) -> bool:
|
||||
"""Return whether this config acquires the full virtual switch matrix per sweep."""
|
||||
return self.is_multi_device or self.is_sn9000
|
||||
return self.is_multi_device
|
||||
|
||||
@property
|
||||
def matrix_output_switch_positions(self) -> int:
|
||||
|
||||
Reference in New Issue
Block a user