Rework radar system

This commit is contained in:
Ayzen
2026-10-06 12:32:26 +03:00
parent 552cdc688a
commit 5bb86b7165
299 changed files with 13537 additions and 27763 deletions
+10 -17
View File
@@ -21,7 +21,7 @@ from python_app.hardware_full.kamil_adc.protocol import (
MAIN_MARKER,
REFERENCE_MARKER,
)
from python_app.models.run_config_model import RunConfigModel
from python_app.models.run_config_schema import RunConfigModel
from python_app.orchestration.process_supervisor import ProcessSupervisor
@@ -235,24 +235,16 @@ class KamilAdcConfigTest(unittest.TestCase):
)
service = KamilAdcService(config)
class _UnreapableProcess:
pid = 2_000_000_000 # implausible; killpg is patched out below anyway
def poll(self) -> None:
return None # always "alive"
def wait(self, timeout: float | None = None) -> int:
raise subprocess.TimeoutExpired(cmd="kamil_adc_collector", timeout=timeout)
service._process = _UnreapableProcess() # type: ignore[assignment]
process = mock.Mock(spec=subprocess.Popen, pid=2_000_000_000)
process.poll.return_value = None # always "alive"
process.wait.side_effect = subprocess.TimeoutExpired("kamil_adc_collector", timeout=3.0)
service._process = process
with mock.patch("python_app.hardware_full.kamil_adc.service.os.killpg"):
service.close() # must not raise
def test_drain_after_switch_waits_for_fresh_sweeps(self) -> None:
"""After a switch change, drain must skip the configured number of freshly
published sweeps before returning, so the next capture is post-switch."""
import types
from python_app.hardware_full.kamil_adc import service as service_module
with tempfile.TemporaryDirectory() as tmp_dir:
@@ -272,18 +264,19 @@ class KamilAdcConfigTest(unittest.TestCase):
}
)
service = KamilAdcService(config)
service._reader = types.SimpleNamespace(published_count=10) # type: ignore[assignment]
service._process = types.SimpleNamespace(poll=lambda: None) # type: ignore[assignment]
reader = mock.Mock(spec=KamilAdcTtyReader, published_count=10)
service._reader = reader
service._process = mock.Mock(poll=mock.Mock(return_value=None))
# Each poll-sleep advances the published count, as the reader thread would.
def _advance(_seconds: float) -> None:
service._reader.published_count += 1
reader.published_count += 1
with mock.patch.object(service_module.time, "sleep", _advance):
service.drain_after_switch(sweeps=3)
# Started at 10, must have waited for at least 3 more sweeps.
self.assertGreaterEqual(service._reader.published_count, 13)
self.assertGreaterEqual(reader.published_count, 13)
def test_drain_after_switch_is_noop_when_not_open(self) -> None:
with tempfile.TemporaryDirectory() as tmp_dir: