- removed name property from Msg container

- added source property to MsgContainer
This commit is contained in:
2026-03-29 11:01:41 +02:00
parent af94c39b3e
commit f7b1b18b2f
8 changed files with 25 additions and 48 deletions
+8 -5
View File
@@ -1,13 +1,16 @@
import time
from a_transceiver import ATransceiver
class MsgContainer:
def __init__(self, data: bytes, name: str = "default", timestamp=time.time()):
self.timestamp : float = timestamp
def __init__(self, data: bytes, source: ATransceiver|None, timestamp=time.time()):
self.data: bytes = data
self.name : str = name
self.source = source
self.timestamp : float = timestamp
def __str__(self):
return f"{self.timestamp}:{self.name}:{self.data}"
return f"{self.timestamp}:{self.source.name}:{self.data}"
def __repr__(self):
return f"{self.timestamp}:{self.name}:{self.data}"
return f"{self.timestamp}:{self.source.name}:{self.data}"
+2 -3
View File
@@ -1,13 +1,12 @@
from abc import ABC, abstractmethod
from msg.container import MsgContainer
class MsgListener(ABC):
def __init__(self):
pass
@abstractmethod
def on_recv(self, msg: MsgContainer):
def on_recv(self, msg):
pass
def is_msg(self, msg: MsgContainer):
def is_msg(self, msg):
return False