- removed name property from Msg container
- added source property to MsgContainer
This commit is contained in:
+8
-5
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user