added multidevice support
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
import json
|
||||
from pathlib import Path
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from typing import Iterable
|
||||
from typing import Sequence
|
||||
@@ -83,6 +85,7 @@ class ProcessSupervisor:
|
||||
if self.is_running():
|
||||
raise RuntimeError("Acquisition processes are already running")
|
||||
|
||||
acquisition_command = self._acquisition_command(config_path)
|
||||
command_specs = {
|
||||
"data_processor": [
|
||||
str(self._project_root / "build/bin/data_processor"),
|
||||
@@ -94,11 +97,7 @@ class ProcessSupervisor:
|
||||
"--config",
|
||||
str(config_path),
|
||||
],
|
||||
"sweep_orchestrator": [
|
||||
str(self._project_root / "build/bin/sweep_orchestrator"),
|
||||
"--config",
|
||||
str(config_path),
|
||||
],
|
||||
"sweep_orchestrator": acquisition_command,
|
||||
}
|
||||
processor_was_running = self.is_processor_running()
|
||||
required_processes: list[str] = ["data_preprocessor"]
|
||||
@@ -168,6 +167,34 @@ class ProcessSupervisor:
|
||||
handle=handle,
|
||||
)
|
||||
|
||||
def _acquisition_command(self, config_path: Path) -> list[str]:
|
||||
"""Return acquisition producer command selected by radar.model."""
|
||||
radar_model = self._read_radar_model(config_path)
|
||||
if radar_model == "librevna_multi":
|
||||
return [
|
||||
sys.executable,
|
||||
"-m",
|
||||
"python_app.scripts.multi_device_raw_producer",
|
||||
"--config",
|
||||
str(config_path),
|
||||
]
|
||||
return [
|
||||
str(self._project_root / "build/bin/sweep_orchestrator"),
|
||||
"--config",
|
||||
str(config_path),
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def _read_radar_model(config_path: Path) -> str:
|
||||
"""Read `radar.model` cheaply without constructing the full config model."""
|
||||
payload = json.loads(config_path.read_text(encoding="utf-8"))
|
||||
if not isinstance(payload, dict):
|
||||
return "librevna"
|
||||
radar_payload = payload.get("radar")
|
||||
if not isinstance(radar_payload, dict):
|
||||
return "librevna"
|
||||
return str(radar_payload.get("model", "librevna"))
|
||||
|
||||
def _stop_processes(self, names: Iterable[str]) -> None:
|
||||
"""Gracefully terminate processes, then force-kill on timeout."""
|
||||
ordered_names = list(names)
|
||||
|
||||
Reference in New Issue
Block a user