Index: leahi_dialin/td/modules/switches.py =================================================================== diff -u -rdff2704b529bfbb67b2e8c822e69e3df7d955153 -r6caa49d072aceb2655d605de5d2eea52ab1a8911 --- leahi_dialin/td/modules/switches.py (.../switches.py) (revision dff2704b529bfbb67b2e8c822e69e3df7d955153) +++ leahi_dialin/td/modules/switches.py (.../switches.py) (revision 6caa49d072aceb2655d605de5d2eea52ab1a8911) @@ -22,6 +22,7 @@ from leahi_dialin.common.constants import NO_RESET from leahi_dialin.common.generic_defs import DataTypes from leahi_dialin.common.msg_ids import MsgIds +from leahi_dialin.common.msg_ids import MsgIds from leahi_dialin.common.override_templates import cmd_generic_broadcast_interval_override, cmd_generic_override from leahi_dialin.common import td_enum_repository from leahi_dialin.protocols.CAN import CanMessenger, CanChannels @@ -51,11 +52,26 @@ self.td_switches_timestamp = 0.0 #: The timestamp of the latest message - # The Switches data in dictionary format self.td_switches_status = { td_enum_repository.TDSwitchNames.H9_FRONT_DOOR.name: td_enum_repository.TDSwitchStatus.CLOSED.value } self.handler_execution_times = [] + +# ============================================================ Properties ============================================================ + @property + def td_switches_status(self) -> dict: + """ + The Switches data + """ + return self._switches + + @td_switches_status.setter + def td_switches_status(self, value): + self._switches = value + + + +# ============================================================ Handlers ============================================================ @publish(["msg_id_td_switches_data", "td_switches_status", "td_switches_timestamp"]) def _handler_switches_sync(self, message, timestamp=0.0): """ @@ -65,16 +81,16 @@ @return: none """ start = time.perf_counter() - sensor_list =[] - sensor_list.append((td_enum_repository.TDSwitchNames.H9_FRONT_DOOR.name, DataTypes.U32)) + msg_list =[] + msg_list.append((self.td_switches_status, td_enum_repository.TDSwitchNames.H9_FRONT_DOOR.name, DataTypes.U32)) - self.process_into_dict(dict_to_update = self.td_switches_status, - decoder_list = sensor_list, - message = message) + self.process_into_vars(decoder_list = msg_list, message = message) self.td_switches_timestamp = timestamp self.handler_execution_times.append((timestamp, message, time.perf_counter() - start)) + +# ============================================================ Overrides and Requests ============================================================ def cmd_switches_data_broadcast_interval_override(self, ms: int, reset: int = NO_RESET) -> int: """ Constructs and sends the TD switch data publication override command.