From 93e82a22842a16ebc43fb1844aa8e09b513dac3f Mon Sep 17 00:00:00 2001 From: Stefan Allius Date: Thu, 9 May 2024 18:22:08 +0200 Subject: [PATCH] move state variable to the parent class --- app/src/gen3/talent.py | 5 ----- app/src/messages.py | 4 ++++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/gen3/talent.py b/app/src/gen3/talent.py index daf700f..44c7d0f 100644 --- a/app/src/gen3/talent.py +++ b/app/src/gen3/talent.py @@ -35,10 +35,6 @@ class Control: class Talent(Message): - STATE_INIT = 0 - STATE_UP = 2 - STATE_CLOSED = 3 - def __init__(self, server_side: bool, id_str=b''): super().__init__(server_side) self.await_conn_resp_cnt = 0 @@ -48,7 +44,6 @@ class Talent(Message): self.db = InfosG3() self.mb = Modbus() self.forward_modbus_resp = False - self.state = self.STATE_INIT self.switch = { 0x00: self.msg_contact_info, 0x13: self.msg_ota_update, diff --git a/app/src/messages.py b/app/src/messages.py index 5bcf711..615c054 100644 --- a/app/src/messages.py +++ b/app/src/messages.py @@ -50,6 +50,9 @@ class IterRegistry(type): class Message(metaclass=IterRegistry): _registry = [] + STATE_INIT = 0 + STATE_UP = 2 + STATE_CLOSED = 3 def __init__(self, server_side: bool): self._registry.append(weakref.ref(self)) @@ -65,6 +68,7 @@ class Message(metaclass=IterRegistry): self._send_buffer = bytearray(0) self._forward_buffer = bytearray(0) self.new_data = {} + self.state = self.STATE_INIT ''' Empty methods, that have to be implemented in any child class which