From a61d25584d9ee6c85cf10e475f1b3c8e67224f9c Mon Sep 17 00:00:00 2001 From: ATATC Date: Sat, 30 Dec 2023 20:55:52 -0500 Subject: [PATCH] Fixing #20. --- leads/controller/controller.py | 7 +++++-- leads_dashboard/__init__.py | 2 +- leads_emulation/__init__.py | 8 ++++---- leads_raspberry_pi/raspberry_pi_4b.py | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/leads/controller/controller.py b/leads/controller/controller.py index 17f27994..3bd7a1b3 100644 --- a/leads/controller/controller.py +++ b/leads/controller/controller.py @@ -1,5 +1,5 @@ from abc import abstractmethod as _abstractmethod, ABCMeta as _ABCMeta -from typing import TypeVar as _TypeVar, Generic as _Generic +from typing import TypeVar as _TypeVar, Generic as _Generic, Any as _Any from leads.controller.device import Device @@ -19,5 +19,8 @@ def device(self, tag: str) -> [Device]: return self._devices[tag] @_abstractmethod - def collect_all(self) -> T: + def read(self) -> T: + raise NotImplementedError + + def write(self, payload: _Any) -> None: raise NotImplementedError diff --git a/leads_dashboard/__init__.py b/leads_dashboard/__init__.py index 62a16aff..00ce3860 100644 --- a/leads_dashboard/__init__.py +++ b/leads_dashboard/__init__.py @@ -22,7 +22,7 @@ def initialize(window: Window, window.runtime_data().frame_counter = 0 def on_refresh(_): - leads.push(main_controller.collect_all()) + leads.push(main_controller.read()) leads.update() window.set_on_refresh(on_refresh) diff --git a/leads_emulation/__init__.py b/leads_emulation/__init__.py index 5ce9ebea..131d1044 100644 --- a/leads_emulation/__init__.py +++ b/leads_emulation/__init__.py @@ -22,12 +22,12 @@ def generate_rear_wheel_speed(self, front_wheel_speed: int | float) -> int | flo class SRWRandom(_EmulatedController): - def collect_all(self) -> _SRWDataContainer: + def read(self) -> _SRWDataContainer: return _SRWDataContainer(fws := _randint(self.minimum, self.maximum), self.generate_rear_wheel_speed(fws)) class DRWRandom(_EmulatedController): - def collect_all(self) -> _DRWDataContainer: + def read(self) -> _DRWDataContainer: return _DRWDataContainer(fws := _randint(self.minimum, self.maximum), rws := self.generate_rear_wheel_speed(fws), rws) @@ -48,7 +48,7 @@ def __init__(self, class SRWSin(_SinController): - def collect_all(self) -> _SRWDataContainer: + def read(self) -> _SRWDataContainer: try: return _SRWDataContainer(fws := (_sin(self.counter) + .5) * self.magnitude + self.offset, self.generate_rear_wheel_speed(fws)) @@ -57,7 +57,7 @@ def collect_all(self) -> _SRWDataContainer: class DRWSin(_SinController): - def collect_all(self) -> _DRWDataContainer: + def read(self) -> _DRWDataContainer: try: return _DRWDataContainer(fws := (_sin(self.counter) + .5) * self.magnitude + self.offset, rws := self.generate_rear_wheel_speed(fws), diff --git a/leads_raspberry_pi/raspberry_pi_4b.py b/leads_raspberry_pi/raspberry_pi_4b.py index 243e6b12..7088d32e 100644 --- a/leads_raspberry_pi/raspberry_pi_4b.py +++ b/leads_raspberry_pi/raspberry_pi_4b.py @@ -2,5 +2,5 @@ class RaspberryPi4B(_Controller): - def collect_all(self) -> T: + def read(self) -> T: return None