Index: leahi_dialin/td/modules/buttons.py =================================================================== diff -u -r20c821bd230fc7689a0275a2918981669ff5cc19 -re45b20cdc5d4c5dcff8cef530b173ca94cb2e422 --- leahi_dialin/td/modules/buttons.py (.../buttons.py) (revision 20c821bd230fc7689a0275a2918981669ff5cc19) +++ leahi_dialin/td/modules/buttons.py (.../buttons.py) (revision e45b20cdc5d4c5dcff8cef530b173ca94cb2e422) @@ -8,20 +8,25 @@ # @file buttons.py # # @author (last) Zoltan Miskolci -# @date (last) 08-Jan-2026 +# @date (last) 05-May-2026 # @author (original) Peter Lucia # @date (original) 14-Oct-2024 # ############################################################################ -import struct +# Module imports from logging import Logger +import struct +# Project imports from leahi_dialin.common.constants import NO_RESET -from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions +from leahi_dialin.common.generic_defs import DataTypes +from leahi_dialin.common.msg_defs import MsgFieldPositions +from leahi_dialin.common.msg_ids import MsgIds from leahi_dialin.common.override_templates import cmd_generic_override -from leahi_dialin.protocols.CAN import DenaliCanMessenger, DenaliChannels -from leahi_dialin.utils.base import AbstractSubSystem, publish +from leahi_dialin.protocols.CAN import CanMessenger, CanChannels +from leahi_dialin.utils.abstract_classes import AbstractSubSystem +from leahi_dialin.utils.base import publish from leahi_dialin.utils.conversions import integer_to_bytearray @@ -30,21 +35,20 @@ Treatment Delivery (TD) Dialin API sub-class for button related commands. """ - def __init__(self, can_interface: DenaliCanMessenger, logger: Logger): + def __init__(self, can_interface: CanMessenger, logger: Logger): """ TD_Buttons constructor - @param can_interface: the Denali CAN interface object + @param can_interface: the CAN interface object """ super().__init__() self.can_interface = can_interface self.logger = logger if self.can_interface is not None: - self.msg_id_off_button_press_request = MsgIds.MSG_ID_OFF_BUTTON_PRESS_REQUEST.value - self.can_interface.register_receiving_publication_function(DenaliChannels.td_to_ui_ch_id, - self.msg_id_off_button_press_request, - self._handler_poweroff_timeout_occurred) + self.can_interface.register_receiving_publication_function(channel_id = CanChannels.td_to_ui_ch_id, + message_id = MsgIds.MSG_ID_OFF_BUTTON_PRESS_REQUEST.value, + function = self._handler_poweroff_timeout_occurred) self.td_power_off_timestamp = 0.0 #: The timestamp of the last message self.poweroff_timeout_expired = False #: The Power Off timeout value @@ -71,7 +75,7 @@ self.logger.debug("Poweroff message id detected, but was the wrong length.") return - mode = struct.unpack('h', bytearray( + mode = struct.unpack(DataTypes.U16.unpack_attrib(), bytearray( message["message"][MsgFieldPositions.START_POS_FIELD_1: MsgFieldPositions.START_POS_FIELD_1 + 2])) if len(mode) > 0: @@ -99,7 +103,7 @@ return cmd_generic_override( payload = payload, reset = NO_RESET, - channel_id = DenaliChannels.dialin_to_td_ch_id, + channel_id = CanChannels.dialin_to_td_ch_id, msg_id = MsgIds.MSG_ID_TD_OFF_BUTTON_OVERRIDE_REQUEST, entity_name = f'TD Off Button', override_text = f'{state_name}', @@ -127,7 +131,7 @@ return cmd_generic_override( payload = payload, reset = NO_RESET, - channel_id = DenaliChannels.dialin_to_td_ch_id, + channel_id = CanChannels.dialin_to_td_ch_id, msg_id = MsgIds.MSG_ID_TD_STOP_BUTTON_OVERRIDE_REQUEST, entity_name = f'TD Stop Button', override_text = f'{state_name}',