########################################################################### # # 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_requests.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.msg_ids import MsgIds from leahi_dialin.common.override_templates import cmd_generic_override from leahi_dialin.protocols.CAN import CanChannels from leahi_dialin.utils.abstract_classes import AbstractSubSystem from leahi_dialin.utils.conversions import integer_to_bytearray class FPRecordsSetRequests(AbstractSubSystem): """ Part of the FP Records """ def __init__(self, *args, **kwargs): """ The sub record class to handle all the set requests. """ # Passing the arguments over to the next class too super().__init__(*args, **kwargs) # ================================================= Set Records Main Methods ================================================= def cmd_set_service_records(self, water_recovery: int=0, primary_filter_replacement_date: int=0, secondary_filter_replacement_date: int=0, ro_membrane_replacement_date: int=0, service_loc: int=0, last_service_date: int=0, service_interval_sec: int=0, last_reset_time: int=0) -> int: """ Constructs and sends a command for setting the Service Records. Constraints: Must be logged into FP. Must be in Service mode. @return: 1 if successful, zero otherwise """ payload = integer_to_bytearray(water_recovery) payload += integer_to_bytearray(primary_filter_replacement_date) payload += integer_to_bytearray(secondary_filter_replacement_date) payload += integer_to_bytearray(ro_membrane_replacement_date) payload += integer_to_bytearray(service_loc) payload += integer_to_bytearray(last_service_date) payload += integer_to_bytearray(service_interval_sec) payload += integer_to_bytearray(last_reset_time) return cmd_generic_override( payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, msg_id = MsgIds.MSG_ID_UI_FP_NVM_SET_SERVICE_RECORD_REQUEST, entity_name = f'New FP Service Record', override_text = 'being set', logger = self.logger, can_interface = self.can_interface) def cmd_set_usage_info_records(self, primary_filter_treatment_count: int=0, primary_filter_disinfection_count: int=0, secondary_filter_treatment_count: int=0, secondary_filter_disinfection_count: int=0, ro_membrane_treatment_count: int=0, ro_membrane_disinfection_count: int=0, last_reset_time: int=0) -> int: """ Constructs and sends a command for setting the Usage Information Records. Constraints: Must be logged into FP. Must be in Service mode. @return: 1 if successful, zero otherwise """ payload = integer_to_bytearray(primary_filter_treatment_count) payload += integer_to_bytearray(primary_filter_disinfection_count) payload += integer_to_bytearray(secondary_filter_treatment_count) payload += integer_to_bytearray(secondary_filter_disinfection_count) payload += integer_to_bytearray(ro_membrane_treatment_count) payload += integer_to_bytearray(ro_membrane_disinfection_count) payload += integer_to_bytearray(last_reset_time) return cmd_generic_override( payload = payload, reset = None, channel_id = CanChannels.dialin_to_dd_ch_id, msg_id = MsgIds.MSG_ID_UI_FP_NVM_SET_USAGE_INFO_RECORD_REQUEST, entity_name = f'New FP Usage Information Record', override_text = 'being set', logger = self.logger, can_interface = self.can_interface)