Index: dialin/common/alarm_defs.py =================================================================== diff -u -rdf58df8b4e8b8d3f0b0764deda9f15050a071d78 -r26de67dd19c2cc0f475d1e77b4a887857841f6c1 --- dialin/common/alarm_defs.py (.../alarm_defs.py) (revision df58df8b4e8b8d3f0b0764deda9f15050a071d78) +++ dialin/common/alarm_defs.py (.../alarm_defs.py) (revision 26de67dd19c2cc0f475d1e77b4a887857841f6c1) @@ -8,9 +8,9 @@ # @file alarm_defs.py # # @author (last) Peter Lucia -# @date (last) 27-Apr-2021 +# @date (last) 11-May-2021 # @author (original) Peter Lucia -# @date (original) 27-Apr-2021 +# @date (original) 11-May-2021 # ############################################################################ from enum import unique @@ -23,7 +23,7 @@ ALARM_ID_NO_ALARM = 0 ALARM_ID_HD_SOFTWARE_FAULT = 1 ALARM_ID_STUCK_BUTTON_TEST_FAILED = 2 - ALARM_ID_FPGA_POST_TEST_FAILED = 3 + ALARM_ID_HD_FPGA_POST_TEST_FAILED = 3 ALARM_ID_WATCHDOG_POST_TEST_FAILED = 4 ALARM_ID_UI_COMM_POST_FAILED = 5 ALARM_ID_BLOOD_PUMP_MC_CURRENT_CHECK = 6 @@ -66,9 +66,10 @@ ALARM_ID_NVDATA_SRVC_RECORD_CRC_ERROR = 43 ALARM_ID_NVDATA_CAL_RECORD_CRC_ERROR = 44 ALARM_ID_NVDATA_HW_USAGE_DATA_CRC_ERROR = 45 - ALARM_ID_RO_PUMP_OUT_PRESSURE_OUT_OF_RANGE = 47 + ALARM_ID_AVAILABLE_1 = 46 + ALARM_ID_AVAILABLE_2 = 47 ALARM_ID_TEMPERATURE_SENSORS_FAULT = 48 - ALARM_ID_FPGA_COMM_TIMEOUT = 49 + ALARM_ID_HD_FPGA_COMM_TIMEOUT = 49 ALARM_ID_HD_COMM_TIMEOUT = 50 ALARM_ID_VALVE_CONTROL_FAILURE = 51 ALARM_ID_BLOOD_PUMP_FLOW_VS_MOTOR_SPEED_CHECK = 52 @@ -129,7 +130,7 @@ ALARM_ID_END_OF_TREATMENT_WARNING = 107 ALARM_ID_END_OF_TREATMENT_ALARM = 108 ALARM_ID_END_OF_TREATMENT_HIGH = 109 - ALARM_ID_DG_HEAT_DISINFECT_CYCLE_FAILED = 110 + ALARM_ID_AVAILABLE_3 = 110 ALARM_ID_RO_PUMP_RAMP_UP_TO_FLOW_TIMEOUT = 111 ALARM_ID_FLOW_RATE_OUT_OF_LOWER_RANGE = 112 ALARM_ID_DRAIN_PUMP_OFF_FAULT = 113 @@ -147,7 +148,7 @@ ALARM_ID_TREATMENT_RINSEBACK_TIMEOUT_ALARM = 125 ALARM_ID_TREATMENT_RECIRC_TIMEOUT_ALARM = 126 ALARM_ID_CARTRIDGE_DOOR_OPENED = 127 - ALARM_ID_PRE_TREATMENT_NO_CART_SELF_TEST_FAILURE = 128 + ALARM_ID_AVAILABLE_4 = 128 ALARM_ID_INSTALL_NEW_CARTRIDGE = 129 ALARM_ID_CARTRIDGE_INSTALLED_IMPROPERLY = 130 ALARM_ID_RINSEBACK_VOLUME_CHECK_FAILURE = 131 @@ -159,7 +160,7 @@ ALARM_ID_PRE_TREATMENT_DRY_SELF_TEST_FAILURE = 137 ALARM_ID_PRE_TREATMENT_WET_SELF_TEST_FAILURE = 138 ALARM_ID_DG_FLOW_METER_CHECK_FAILURE = 139 - ALARM_ID_DG_RO_PUMP_TOO_MANY_RAMP_UP_RETRY = 140 + ALARM_ID_AVAILABLE_5 = 140 ALARM_ID_NVDATAMGMT_GROUP_RECORD_CRC_INVALID = 141 ALARM_ID_NVDATAMGMT_INDIVIDUAL_RECORD_CRC_INVALID = 142 ALARM_ID_NVDATAMGMT_INDIVIDUAL_RECORD_TIME_INVALID = 143 @@ -213,3 +214,30 @@ ALARM_ID_HD_SYRINGE_PUMP_NOT_ENOUGH_HEPARIN_ALARM = 191 ALARM_ID_HD_SYRINGE_PUMP_DAC_WRITE_ERROR = 192 ALARM_ID_HD_SYRINGE_PUMP_RUNNING_WHILE_BP_OFF_ERROR = 193 + ALARM_ID_DG_CHEM_DISINFECT_INLET_PRES_AND_TEMP_SNSRS_OUT = 194 + ALARM_ID_DG_CHEM_DISINFECT_INLET_COND_AND_TEMP_OUT = 195 + ALARM_ID_DG_FPGA_COMM_TIMEOUT = 196 + ALARM_ID_DG_LOAD_CELL_ADC_ERROR = 197 + ALARM_ID_HD_VENOUS_PRESSURE_READ_TIMEOUT_ERROR = 198 + ALARM_ID_HD_VENOUS_PRESSURE_SENSOR_TEMP_OUT_OF_RANGE = 199 + ALARM_ID_HD_BP_OCCLUSION_READ_TIMEOUT_ERROR = 200 + ALARM_ID_HD_DPI_OCCLUSON_READ_TIMEOUT_ERROR = 201 + ALARM_ID_HD_DPO_OCCLUSION_READ_TIMEOUT_ERROR = 202 + ALARM_ID_HD_BP_OCCLUSION_SENSOR_ERROR = 203 + ALARM_ID_HD_DPI_OCCLUSION_SENSOR_ERROR = 204 + ALARM_ID_HD_DPO_OCCLUSION_SENSOR_ERROR = 205 + ALARM_ID_DG_CONCENTRATE_PUMP_FAULT = 206 + ALARM_ID_HD_BP_FLOW_READ_TIMEOUT_ERROR = 207 + ALARM_ID_HD_BP_FLOW_SENSOR_ERROR = 208 + ALARM_ID_HD_DP_FLOW_READ_TIMEOUT_ERROR = 209 + ALARM_ID_HD_DP_FLOW_SENSOR_ERROR = 210 + ALARM_ID_DG_CHEM_DISINFECT_TARGET_TEMP_TIMEOUT = 211 + ALARM_ID_DG_FPGA_POST_TEST_FAILED = 212 + ALARM_ID_HD_ARTERIAL_BUBBLE_SELF_TEST_FAILURE = 213 + ALARM_ID_HD_ARTERIAL_BUBBLE_DETECTOR_FAULT = 214 + ALARM_ID_DG_HEATERS_SELF_TEST_FAILURE = 215 + ALARM_ID_HD_VENOUS_BUBBLE_SELF_TEST_FAILURE = 216 + ALARM_ID_HD_VENOUS_BUBBLE_DETECTOR_TREATMENT_FAULT = 217 + ALARM_ID_HD_VENOUS_BUBBLE_DETECTOR_RINSEBACK_FAULT = 218 + ALARM_ID_HD_ARTERIAL_BUBBLE_DETECTED = 219 + ALARM_ID_HD_VENOUS_BUBBLE_DETECTED = 220 Index: dialin/common/msg_defs.py =================================================================== diff -u -r7d528c2109af39ed65e9dd3d61162de89ad22d96 -r26de67dd19c2cc0f475d1e77b4a887857841f6c1 --- dialin/common/msg_defs.py (.../msg_defs.py) (revision 7d528c2109af39ed65e9dd3d61162de89ad22d96) +++ dialin/common/msg_defs.py (.../msg_defs.py) (revision 26de67dd19c2cc0f475d1e77b4a887857841f6c1) @@ -21,11 +21,12 @@ # Define msg ids that are not yet added to common but are needed in dialin @unique class MsgIdsDialin(DialinEnum): - pass + MSG_DIALIN_ID_HD_SERIAL_NUMBER_RESPONSE = 0X87 + MSG_DIALIN_ID_DG_SERIAL_NUMBER_RESPONSE = 0X88 + MSG_DIALIN_ID_UI_SYSTEM_USAGE_REQUEST = 0x89 + MSG_DIALIN_ID_HD_SYSTEM_USAGE_RESPONSE = 0x8A + MSG_DIALIN_ID_DG_SYSTEM_USAGE_RESPONSE = 0x8C -# extend MsgIds -for each in MsgIdsDialin: - extend_enum(MsgIds, each.name, each.value) ACK_NOT_REQUIRED = [ MsgIds.MSG_ID_ALARM_CONDITION_CLEARED.value @@ -110,6 +111,4 @@ START_POS_FIELD_24 = END_POS_FIELD_23 END_POS_FIELD_24 = START_POS_FIELD_24 + 4 START_POS_FIELD_25 = END_POS_FIELD_24 - END_POS_FIELD_25 = START_POS_FIELD_25 + 4 - - + END_POS_FIELD_25 = START_POS_FIELD_25 + 4 \ No newline at end of file Index: dialin/common/msg_ids.py =================================================================== diff -u -rdf58df8b4e8b8d3f0b0764deda9f15050a071d78 -r26de67dd19c2cc0f475d1e77b4a887857841f6c1 --- dialin/common/msg_ids.py (.../msg_ids.py) (revision df58df8b4e8b8d3f0b0764deda9f15050a071d78) +++ dialin/common/msg_ids.py (.../msg_ids.py) (revision 26de67dd19c2cc0f475d1e77b4a887857841f6c1) @@ -8,9 +8,9 @@ # @file msg_ids.py # # @author (last) Peter Lucia -# @date (last) 27-Apr-2021 +# @date (last) 11-May-2021 # @author (original) Peter Lucia -# @date (original) 27-Apr-2021 +# @date (original) 11-May-2021 # ############################################################################ from enum import unique @@ -132,7 +132,7 @@ MSG_ID_UI_TREATMENT_LOG_DATA_REQUEST = 0X75 MSG_ID_HD_TREATMENT_LOG_DATA_RESPONSE = 0X76 MSG_ID_HD_POST_TREATMENT_STATE = 0X77 - MSG_ID___AVAILABLE_16 = 0X78 + MSG_ID_DG_START_STOP_CHEM_DISINFECT = 0X78 MSG_ID_DG_START_STOP_FLUSH = 0X79 MSG_ID_DG_FLUSH_DATA = 0X7A MSG_ID_HD_VOLTAGES_DATA = 0X7B @@ -225,8 +225,18 @@ MSG_ID_HD_ALARM_AUDIO_CURRENT_HG_OVERRIDE = 0X8054 MSG_ID_HD_ALARM_AUDIO_CURRENT_LG_OVERRIDE = 0X8055 MSG_ID_HD_ALARM_BACKUP_AUDIO_CURRENT_OVERRIDE = 0X8056 + MSG_ID_HD_VALVES_CURRENT_OVERRIDE = 0X8057 + MSG_ID_HD_SYRINGE_PUMP_STATUS_OVERRIDE = 0X8059 + MSG_ID_HD_SYRINGE_PUMP_ENCODER_STATUS_OVERRIDE = 0X805A + MSG_ID_HD_SYRINGE_PUMP_ADC_DAC_STATUS_OVERRIDE = 0X805B + MSG_ID_HD_SYRINGE_PUMP_ADC_READ_COUNTER_OVERRIDE = 0X805C + MSG_ID_HD_BUBBLES_DATA_SEND_INTERVAL_OVERRIDE = 0X805D + MSG_ID_HD_BUBBLES_STATUS_OVERRIDE = 0X805E + MSG_ID_HD_BUBBLES_SELF_TEST_REQUEST = 0X8060 MSG_ID_DG_VOLTAGES_DATA = 0X86 + MSG_ID_DG_CHEM_DISINFECT_DATA = 0X87 MSG_ID_PRESSURE_OCCLUSION_DATA = 0X9 + MSG_ID_HD_BUBBLES_DATA = 0X93 MSG_ID_CAN_ERROR_COUNT = 0X999 MSG_ID_RTC_EPOCH = 0XA MSG_ID_DG_TESTER_LOGIN_REQUEST = 0XA000 @@ -260,7 +270,7 @@ MSG_ID___AVAILABLE_13 = 0XA01E MSG_ID___AVAILABLE_14 = 0XA01F MSG_ID___AVAILABLE_15 = 0XA020 - MSG_ID_HEAT_DISINFECT_PUBLISH_INTERVAL_OVERRIDE = 0XA021 + MSG_ID___AVAILABLE_16 = 0XA021 MSG_ID_DG_SOFTWARE_RESET_REQUEST = 0XA022 MSG_ID_DG_CONCENTRATE_PUMP_MEASURED_SPEED_OVERRIDE = 0XA023 MSG_ID_CONCENTRATE_PUMP_TARGET_SPEED_OVERRIDE = 0XA024 Index: dialin/dg/dialysate_generator.py =================================================================== diff -u -rbe97d97e1ddd765351cdc51cb75aee9e7e63ba58 -r26de67dd19c2cc0f475d1e77b4a887857841f6c1 --- dialin/dg/dialysate_generator.py (.../dialysate_generator.py) (revision be97d97e1ddd765351cdc51cb75aee9e7e63ba58) +++ dialin/dg/dialysate_generator.py (.../dialysate_generator.py) (revision 26de67dd19c2cc0f475d1e77b4a887857841f6c1) @@ -23,7 +23,6 @@ from .fans import Fans from .hd_proxy import DGHDProxy from .heaters import Heaters -from .heat_disinfect import HeatDisinfect from .load_cells import DGLoadCells from .pressures import DGPressures from .reservoirs import DGReservoirs @@ -44,6 +43,7 @@ from ..protocols.CAN import (DenaliCanMessenger, DenaliMessage, DenaliChannels) from ..utils.base import _AbstractSubSystem, _publish, _LogManager from ..common.msg_defs import MsgIds, MsgFieldPositions +from .flush import FlushMode class DG(_AbstractSubSystem): @@ -166,6 +166,7 @@ self.service_record = DGServiceNVRecord(self.can_interface, self.logger) self.scheduled_runs_record = DGScheduledRunsNVRecord(self.can_interface, self.logger) self.valves = DGValves(self.can_interface, self.logger) + self.flush = FlushMode(self.can_interface, self.logger) def get_version(self): """ Index: dialin/hd/hemodialysis_device.py =================================================================== diff -u -rbe97d97e1ddd765351cdc51cb75aee9e7e63ba58 -r26de67dd19c2cc0f475d1e77b4a887857841f6c1 --- dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision be97d97e1ddd765351cdc51cb75aee9e7e63ba58) +++ dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision 26de67dd19c2cc0f475d1e77b4a887857841f6c1) @@ -17,6 +17,7 @@ from .accelerometer import HDAccelerometer from .air_trap import HDAirTrap from .alarms import HDAlarms +from .blood_leak import HDBloodLeak from .buttons import HDButtons from .fluid_leak import HDFluidLeak from .ui_proxy import HDUIProxy @@ -93,6 +94,7 @@ self.air_trap = HDAirTrap(self.can_interface, self.logger) self.alarms = HDAlarms(self.can_interface, self.logger) self.buttons = HDButtons(self.can_interface, self.logger) + self.blood_leak = HDBloodLeak(self.can_interface, self.logger) self.fluid_leak = HDFluidLeak(self.can_interface, self.logger) self.ui = HDUIProxy(self.can_interface, self.logger) self.rtc = HDRTC(self.can_interface, self.logger) Index: dialin/hd/ui_proxy.py =================================================================== diff -u -r64a8b369db68485a9d1d461e1aa53ee7ddbc0c30 -r26de67dd19c2cc0f475d1e77b4a887857841f6c1 --- dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision 64a8b369db68485a9d1d461e1aa53ee7ddbc0c30) +++ dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision 26de67dd19c2cc0f475d1e77b4a887857841f6c1) @@ -1001,7 +1001,7 @@ "treatment_end_cmd_succeeded", "treatment_end_cmd_reject_reason", ]) - def _handler_treatment_end_cmd_response(self, message): + def _handler_treatment_end_cmd_response(self, message: dict) -> None: """ Handler for response from HD regarding treatment end user command. @@ -1068,7 +1068,7 @@ self.logger.debug("Sending ui request to set alarm audio volume to level " + str(volume) + " to HD") self.can_interface.send(message, 0) - def cmd_ui_uf_volume_set(self, uf_volume): + def cmd_ui_uf_volume_set(self, uf_volume: float): """ Constructs and sends the ui set ultrafiltration volume parameter message @@ -1152,13 +1152,12 @@ self.can_interface.send(message, 0) - def cmd_ui_treatment_duration_setting_change_request(self, time_min=0): + def cmd_ui_treatment_duration_setting_change_request(self, time_min: int = 0): """ - Constructs and sends a ui UF change settings confirmed by user message + Constructs and sends a ui UF change settings confirmed by user message - @param time_min: (int) treatment time (in min). - - @return: None + @param time_min: (int) treatment time (in min). + @return: None """ payload = integer_to_bytearray(time_min) Index: dialin/ui/dg_simulator.py =================================================================== diff -u -rf053467ac7cfb9fe349e394342d3a9253a377403 -r26de67dd19c2cc0f475d1e77b4a887857841f6c1 --- dialin/ui/dg_simulator.py (.../dg_simulator.py) (revision f053467ac7cfb9fe349e394342d3a9253a377403) +++ dialin/ui/dg_simulator.py (.../dg_simulator.py) (revision 26de67dd19c2cc0f475d1e77b4a887857841f6c1) @@ -16,19 +16,22 @@ import struct from ..utils import YES -from ..common.msg_defs import MsgIds +from ..common import * from ..protocols.CAN import (DenaliMessage, DenaliCanMessenger, DenaliChannels) from ..utils.base import _AbstractSubSystem, _LogManager from ..utils.conversions import integer_to_bytearray, float_to_bytearray, byte_to_bytearray, short_to_bytearray from . import messageBuilder -from ..common import GuiActionType + class DGSimulator(_AbstractSubSystem): instance_count = 0 - def __init__(self, can_interface="can0", log_level=None, console_out=False): + def __init__(self, can_interface:str="can0", + log_level:str=None, + console_out:bool=False, + passive_mode:bool=False): super().__init__() self._log_manager = _LogManager(log_level=log_level, log_filepath=self.__class__.__name__ + ".log") @@ -37,15 +40,40 @@ self.can_interface = DenaliCanMessenger(can_interface=can_interface, logger=self.logger, log_can=self._log_manager.log_level == "CAN_ONLY", - console_out=console_out) + console_out=console_out, + passive_mode=passive_mode) self.can_interface.start() if self.can_interface is not None: channel_id = DenaliChannels.ui_to_hd_ch_id self.can_interface.register_receiving_publication_function(channel_id, MsgIds.MSG_ID_UI_DG_SET_RTC_REQUEST.value, self._handler_set_rtc_request) + self.can_interface.register_receiving_publication_function(DenaliChannels.ui_sync_broadcast_ch_id, + MsgIds.MSG_ID_REQUEST_FW_VERSIONS.value, + self._handler_request_dg_version) + self.can_interface.register_receiving_publication_function(DenaliChannels.ui_sync_broadcast_ch_id, + MsgIdsDialin.MSG_DIALIN_ID_UI_SYSTEM_USAGE_REQUEST.value, + self._handler_system_usage_response) + def _handler_system_usage_response(self, message: dict) -> None: + """ + Handles a request for system usage + + @param message: (dict) the message + @return: None + """ + self.logger.debug("Handling request for system usage.") + + payload = integer_to_bytearray(1619628663) + payload += integer_to_bytearray(1619887863) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_to_ui_ch_id, + message_id=MsgIdsDialin.MSG_DIALIN_ID_DG_SYSTEM_USAGE_RESPONSE.value, + payload=payload) + + self.can_interface.send(message, 0) + def _handler_set_rtc_request(self, message: dict) -> None: """ Handles a request to set the DG RTC @@ -94,7 +122,6 @@ self.can_interface.send(message, 0) - def cmd_set_dg_ro_pump_data(self, vSetPtPressure, vFlowRate, vPWM): """ the DG RO Pump Data message setter/sender method @@ -390,6 +417,31 @@ self.can_interface.send(message, 0) + def _handler_request_dg_version(self, message: dict) -> None: + """ + Handles a request for the HD version + + @param message: (dict) the received message + @return: None + """ + self.logger.debug("Handling request for dg version.") + + self.cmd_send_version_dg_data(9, 9, 9, 9, 9, 9, 9, 9) + self.cmd_send_dg_serial_number() + + def cmd_send_dg_serial_number(self) -> None: + """ + Sends the dg serial number + @return: None + """ + payload = b'0123456789\0' + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_to_ui_ch_id, + message_id=MsgIdsDialin.MSG_DIALIN_ID_DG_SERIAL_NUMBER_RESPONSE.value, + payload=payload) + + self.can_interface.send(message, 0) + def cmd_send_version_dg_data(self, vMajor, vMinor, vMicro, vBuild, vFPGA_id, vFPGA_Major, vFPGA_Minor, vFPGA_Lab ): """ the hd version response message method @@ -430,3 +482,4 @@ txt = messageBuilder.textToByte(vText, message_length) # + 1 null term msg = messageBuilder.buildMessage(GuiActionType.DGDebugText, 1 * (message_length + 1), False, txt) return messageBuilder.toFrames(msg) + Index: dialin/ui/hd_simulator.py =================================================================== diff -u -raf21ad6b590a05515b33e573d1c9236f21cafa3e -r26de67dd19c2cc0f475d1e77b4a887857841f6c1 --- dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision af21ad6b590a05515b33e573d1c9236f21cafa3e) +++ dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision 26de67dd19c2cc0f475d1e77b4a887857841f6c1) @@ -21,10 +21,8 @@ import subprocess from . import messageBuilder -from ..common import TreatmentParameterRejections, GuiActionType, EResponse, TXStates from .hd_simulator_alarms import HDAlarmsSimulator -from ..common.msg_defs import RequestRejectReasons, MsgIds, MsgFieldPositions -from ..common.hd_defs import HDOpModes +from ..common import * from ..protocols.CAN import (DenaliMessage, DenaliCanMessenger, DenaliChannels) @@ -37,7 +35,10 @@ NUM_TREATMENT_PARAMETERS = 18 instanceCount = 0 - def __init__(self, can_interface="can0", log_level=None, console_out=False): + def __init__(self, can_interface:str="can0", + log_level:bool= None, + console_out:bool= False, + passive_mode:bool=False): """ The HDSimulator constructor @@ -54,14 +55,15 @@ self.can_interface = DenaliCanMessenger(can_interface=can_interface, logger=self.logger, log_can=self._log_manager.log_level == "CAN_ONLY", - console_out=console_out) + console_out=console_out, + passive_mode=passive_mode) self.can_interface.start() if self.can_interface is not None: channel_id = DenaliChannels.ui_to_hd_ch_id self.can_interface.register_receiving_publication_function(channel_id, MsgIds.MSG_ID_UI_INITIATE_TREATMENT_REQUEST.value, - self._handler_ui_start_treatment) + self._handler_ui_initiate_treatment) self.can_interface.register_receiving_publication_function(channel_id, MsgIds.MSG_ID_UI_SET_UF_VOLUME_PARAMETER.value, self._handler_ui_pre_treatment_uf_request) @@ -77,17 +79,33 @@ self.can_interface.register_receiving_publication_function(channel_id, MsgIds.MSG_ID_UI_HD_SET_RTC_REQUEST.value, self._handler_set_rtc_request) + self.can_interface.register_receiving_publication_function(DenaliChannels.ui_sync_broadcast_ch_id, + MsgIds.MSG_ID_REQUEST_FW_VERSIONS.value, + self._handler_request_hd_version) + self.can_interface.register_receiving_publication_function(DenaliChannels.ui_sync_broadcast_ch_id, + MsgIdsDialin.MSG_DIALIN_ID_UI_SYSTEM_USAGE_REQUEST.value, + self._handler_system_usage_response) self.alarms_simulator = HDAlarmsSimulator(self.can_interface, self.logger) self.treatment_parameter_rejections = TreatmentParameterRejections() - def alarm(self) -> HDAlarmsSimulator: + def _handler_system_usage_response(self, message: dict) -> None: """ - Gets the alarm simulator object - @return: (HDAlarmsSimulator) the alarms simulator + Handles a request for system usage + + @param message: (dict) the message + @return: None """ - return self.alarms_simulator + + payload = integer_to_bytearray(1619628663) + payload += integer_to_bytearray(1619887863) + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIdsDialin.MSG_DIALIN_ID_HD_SYSTEM_USAGE_RESPONSE.value, + payload=payload) + + self.can_interface.send(message, 0) + def _handler_set_rtc_request(self, message: dict) -> None: """ Handles a UI request to set the HD RTC @@ -123,7 +141,6 @@ self.can_interface.send(message, 0) - def cmd_send_treatment_parameter_validation_response(self, rejections: List[RequestRejectReasons]): """ Sends a treatment parameter validation response @@ -273,7 +290,7 @@ self.cmd_send_uf_treatment_response(1, 0, uf_volume) - def _handler_ui_start_treatment(self, message): + def _handler_ui_initiate_treatment(self, message): """ Handler function to start a treatment @@ -296,9 +313,9 @@ self.logger.debug("Starting treatment") self.cmd_send_hd_operation_mode(HDOpModes.MODE_TREA.value) - self.cmd_send_start_treatment_response(YES, 0) + self.cmd_initiate_treatment_response(YES, 0) - def cmd_send_start_treatment_response(self, response, reason): + def cmd_initiate_treatment_response(self, response, reason): """ Sends a start treatment response message @@ -1354,6 +1371,34 @@ self.can_interface.send(message, 0) + def _handler_request_hd_version(self, message: dict): + """ + Handles a request for the HD version + + @param message: (dict) the received message + @return: None + """ + + self.logger.debug("Handling request for hd version.") + self.cmd_send_version_hd_data(9, 9, 9, 9, 9, 9, 9, 9) + self.cmd_send_hd_serial_number() + + def cmd_send_hd_serial_number(self): + """ + Sends the hd serial number response + + @return: None + """ + self.logger.debug("Sending hd serial number...") + + payload = bytearray('0123456789\0', encoding="utf-8") + + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIdsDialin.MSG_DIALIN_ID_HD_SERIAL_NUMBER_RESPONSE.value, + payload=payload) + + self.can_interface.send(message, 0) + def cmd_send_version_hd_data(self, vMajor, vMinor, vMicro, vBuild, vFPGA_id, vFPGA_Major, vFPGA_Minor, vFPGA_Lab ): """ the hd version response message method @@ -1382,3 +1427,10 @@ payload=payload) self.can_interface.send(message, 0) + + def alarm(self) -> HDAlarmsSimulator: + """ + Gets the alarm simulator object + @return: (HDAlarmsSimulator) the alarms simulator + """ + return self.alarms_simulator