########################################################################### # # Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. # # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # @file records_set_responses.py # # @author (last) Zoltan Miskolci # @date (last) 11-Aug-2026 # @author (original) Zoltan Miskolci # @date (original) 11-Aug-2026 # ############################################################################ # Project imports from leahi_dialin.common import td_enum_repository from leahi_dialin.common.generic_defs import DataTypes from leahi_dialin.common.msg_defs import RequestRejectReasons from leahi_dialin.common.msg_ids import MsgIds from leahi_dialin.protocols.CAN import CanChannels from leahi_dialin.utils.abstract_classes import AbstractSubSystem from leahi_dialin.utils.base import publish class TDRecordsSetHandlers(AbstractSubSystem): """ Part of the TD Records """ def __init__(self, *args, **kwargs): """ The sub record class to handle all the set handlers. """ if self.can_interface is not None: self.can_interface.register_receiving_publication_function(channel_id = CanChannels.td_sync_broadcast_ch_id, message_id = MsgIds.MSG_ID_UNUSED.value, # message_id = MsgIds.MSG_ID_TD_UI_NVM_SET_SERVICE_RECORD_RESPONSE.value, function = self._handler_set_service_rec_rr_sync) self.can_interface.register_receiving_publication_function(channel_id = CanChannels.td_sync_broadcast_ch_id, message_id = MsgIds.MSG_ID_UNUSED.value, # message_id = MsgIds.MSG_ID_TD_UI_NVM_SET_USAGE_INFO_RECORD_RESPONSE.value, function = self._handler_set_usage_info_rec_rr_sync) # Passing the arguments over to the next class too super().__init__(*args, **kwargs) # ================================================= Reject Reason Message Handler Methods ================================================= # @publish([MsgIds.MSG_ID_TD_UI_NVM_SET_SERVICE_RECORD_RESPONSE.name.lower(), "set_service_rec_ack", "set_service_rec_rr", "set_service_rec_rr_timestamp"]) @publish([MsgIds.MSG_ID_UNUSED.name.lower(), "set_service_rec_ack", "set_service_rec_rr", "set_service_rec_rr_timestamp"]) def _handler_set_service_rec_rr_sync(self, message, timestamp = 0.0): """ Handles published TD Set TD Service Records Reject Reason data messages. TD Set TD Service Records Reject Reason are captured for reference. @param message: published data message @return: none """ msg_list = [] msg_list.append((type(self).set_service_rec_ack, DataTypes.BOOL)) for ser_rec in td_enum_repository.TDServiceRecordFields: msg_list.append((self.set_service_rec_rr, ser_rec, DataTypes.U32)) self.process_into_vars(decoder_list = msg_list, message = message) # Convert to enum for ser_rec in self.set_service_rec_rr: if isinstance(self.set_service_rec_rr[ser_rec], int): self.set_service_rec_rr[ser_rec] = RequestRejectReasons(self.set_service_rec_rr[ser_rec]) self.set_service_rec_rr_timestamp = timestamp # @publish([MsgIds.MSG_ID_TD_UI_NVM_SET_USAGE_INFO_RECORD_RESPONSE.name.lower(), "set_usage_info_rec_ack", "set_usage_info_rec_rr", "set_usage_info_rec_rr_timestamp"]) @publish([MsgIds.MSG_ID_UNUSED.name.lower(), "set_usage_info_rec_ack", "set_usage_info_rec_rr", "set_usage_info_rec_rr_timestamp"]) def _handler_set_usage_info_rec_rr_sync(self, message, timestamp = 0.0): """ Handles published TD Set TD Usage Information Records Reject Reason data messages. TD Set TD Usage Information Records Reject Reason are captured for reference. @param message: published data message @return: none """ msg_list = [] msg_list.append((type(self).set_usage_info_rec_ack, DataTypes.BOOL)) for info_rec in td_enum_repository.TDUsageInformationRecordFields: msg_list.append((self.set_usage_info_rec_rr, info_rec, DataTypes.U32)) self.process_into_vars(decoder_list = msg_list, message = message) # Convert to enum for info_rec in self.set_usage_info_rec_rr: if isinstance(self.set_usage_info_rec_rr[info_rec], int): self.set_usage_info_rec_rr[info_rec] = RequestRejectReasons(self.set_usage_info_rec_rr[info_rec]) self.set_usage_info_rec_rr_timestamp = timestamp