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
+8 -13
View File
@@ -5,6 +5,7 @@ from __future__ import annotations
import tempfile
import threading
import unittest
from unittest import mock
from dataclasses import dataclass
from pathlib import Path
from typing import List, Optional
@@ -134,6 +135,7 @@ class MonitorTest(unittest.TestCase):
assert reading is not None
self.assertEqual(reading.seq, 7)
self.assertAlmostEqual(reading.temp1, 28.01)
assert reading.temp_ext1 is not None and reading.current2 is not None
self.assertAlmostEqual(reading.temp_ext1, 22.0)
self.assertAlmostEqual(reading.current2, 35.0)
@@ -144,26 +146,19 @@ class MonitorTest(unittest.TestCase):
])
stop = threading.Event()
class _OneShotWriter:
def __init__(self) -> None:
self.written: List[TemperatureReading] = []
def write(self, reading: TemperatureReading) -> None:
self.written.append(reading)
stop.set() # stop after the first publish
writer = _OneShotWriter()
writer = mock.Mock(spec=ReadingWriter)
writer.write.side_effect = lambda _reading: stop.set()
monitor = LaserTemperatureMonitor(controller, writer, period_s=0.0)
monitor.run(stop)
self.assertEqual(len(writer.written), 1)
self.assertEqual(writer.written[0].seq, 0)
writer.write.assert_called_once()
self.assertEqual(writer.write.call_args.args[0].seq, 0)
class CheckerTest(unittest.TestCase):
def _checker(self, **kwargs: object) -> LaserTemperatureChecker:
def _checker(self, reminder_every: int = 0) -> LaserTemperatureChecker:
return LaserTemperatureChecker(target_temp1=28.0, target_temp2=28.9,
tolerance_c=0.03, **kwargs)
tolerance_c=0.03, reminder_every=reminder_every)
def _reading(self, t1: float, t2: float, seq: int = 0) -> TemperatureReading:
return TemperatureReading(seq=seq, mono_ns=seq, temp1=t1, temp2=t2)