Index: dialin/common/msg_ids.py =================================================================== diff -u -r9bc00e997e91dab8b404aa877b02ae3d4100d417 -re96f7b36e76ffad8f72e2c53d8c5a62e5abd10a2 --- dialin/common/msg_ids.py (.../msg_ids.py) (revision 9bc00e997e91dab8b404aa877b02ae3d4100d417) +++ dialin/common/msg_ids.py (.../msg_ids.py) (revision e96f7b36e76ffad8f72e2c53d8c5a62e5abd10a2) @@ -220,6 +220,7 @@ MSG_ID_DG_HEAT_DISINFECT_ACTIVE_COOL_DATA = 0xC5 MSG_ID_DG_START_STOP_HEAT_DISINFECT_ACTIVE_COOL = 0xC6 MSG_ID_HD_AIR_PUMP_DATA = 0xC7 + MSG_ID_HD_SEND_CHEM_FLUSH_SAMPLE_PASS_FAIL_TO_DG = 0xC8 MSG_ID_CAN_ERROR_COUNT = 0x999 @@ -365,6 +366,9 @@ MSG_ID_HD_BATTERY_STATUS_OVERRIDE = 0x808C MSG_ID_HD_BATTERY_CHARGER_STATUS_OVERRIDE = 0x808D MSG_ID_HD_BATTERY_COMM_STATUS_OVERRIDE = 0x808E + MSG_ID_HD_DIAL_IN_PUMP_HARD_STOP = 0x808F + MSG_ID_HD_DIAL_OUT_PUMP_HARD_STOP = 0x8090 + MSG_ID_HD_BLOOD_PUMP_HARD_STOP = 0x8091 MSG_ID_DG_TESTER_LOGIN_REQUEST = 0xA000 MSG_ID_DG_ALARM_STATE_OVERRIDE = 0xA001 Index: dialin/dg/reservoirs.py =================================================================== diff -u -rdc07ecb63eed240b6d3b47dd96743f93014c564c -re96f7b36e76ffad8f72e2c53d8c5a62e5abd10a2 --- dialin/dg/reservoirs.py (.../reservoirs.py) (revision dc07ecb63eed240b6d3b47dd96743f93014c564c) +++ dialin/dg/reservoirs.py (.../reservoirs.py) (revision e96f7b36e76ffad8f72e2c53d8c5a62e5abd10a2) @@ -7,8 +7,8 @@ # # @file reservoirs.py # -# @author (last) Dara Navaei -# @date (last) 03-Nov-2022 +# @author (last) Micahel Garthwaite +# @date (last) 07-Mar-2023 # @author (original) Sean # @date (original) 14-Apr-2020 # @@ -64,6 +64,7 @@ self.temp_avg_fill = 0.0 self.temp_last_fill = 0.0 self.time_rsrvr_fill = 0.0 + self.dg_reservoirs_timestamp = 0.0 def get_active_reservoir(self): """ @@ -165,10 +166,10 @@ self.logger.debug("Timeout!!!!") return False - @publish(["active_reservoir", "fill_to_vol_ml", "drain_to_vol_ml", "time_reservoir_cycle", + @publish(["dg_reservoirs_timestamp","active_reservoir", "fill_to_vol_ml", "drain_to_vol_ml", "time_reservoir_cycle", "time_reservoir_fill_2_switch", "time_uf_decay", "temp_uf_fill", "temp_reservoir_use_actual", "temp_reservoir_end_fill", "temp_avg_fill", "temp_last_fill", "time_rsrvr_fill"]) - def _handler_reservoirs_sync(self, message): + def _handler_reservoirs_sync(self, message, timestamp=0.0): """ Handles published reservoir data messages. Reservoir data are captured for reference. @@ -201,3 +202,4 @@ message['message'][MsgFieldPositions.START_POS_FIELD_11:MsgFieldPositions.END_POS_FIELD_11]))[0] self.time_rsrvr_fill = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_12:MsgFieldPositions.END_POS_FIELD_12]))[0] + self.dg_reservoirs_timestamp = timestamp Index: dialin/dg/usage_info_record.py =================================================================== diff -u -r9bc00e997e91dab8b404aa877b02ae3d4100d417 -re96f7b36e76ffad8f72e2c53d8c5a62e5abd10a2 --- dialin/dg/usage_info_record.py (.../usage_info_record.py) (revision 9bc00e997e91dab8b404aa877b02ae3d4100d417) +++ dialin/dg/usage_info_record.py (.../usage_info_record.py) (revision e96f7b36e76ffad8f72e2c53d8c5a62e5abd10a2) @@ -273,6 +273,7 @@ 'last_chem_dis_complete_date_epoch': [' int: + """ + Constructs and sends a blood pump stop request message to the HD. + Constraints: + Must be logged into HD. + + @return: 1 if successful, zero otherwise + """ + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, + message_id=MsgIds.MSG_ID_HD_BLOOD_PUMP_HARD_STOP.value) + + self.logger.debug("Stopping blood pump") + + # Send message + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + self.logger.debug("Stopped blood pump") + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("Timeout!!!!") + return False + def cmd_home_blood_pump(self) -> int: """ Constructs and sends a blood pump home request message to the HD. Index: dialin/hd/dialysate_inlet_flow.py =================================================================== diff -u -r9bc00e997e91dab8b404aa877b02ae3d4100d417 -re96f7b36e76ffad8f72e2c53d8c5a62e5abd10a2 --- dialin/hd/dialysate_inlet_flow.py (.../dialysate_inlet_flow.py) (revision 9bc00e997e91dab8b404aa877b02ae3d4100d417) +++ dialin/hd/dialysate_inlet_flow.py (.../dialysate_inlet_flow.py) (revision e96f7b36e76ffad8f72e2c53d8c5a62e5abd10a2) @@ -472,6 +472,31 @@ self.logger.debug("Timeout!!!!") return False + def cmd_stop_dialysate_inlet_pump(self) -> int: + """ + Constructs and sends a dialysate inlet pump stop request message to the HD. + Constraints: + Must be logged into HD. + + @return: 1 if successful, zero otherwise + """ + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, + message_id=MsgIds.MSG_ID_HD_DIAL_IN_PUMP_HARD_STOP.value) + + self.logger.debug("Stopping dialysate inlet pump") + + # Send message + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + self.logger.debug("Stopped dialysate inlet pump") + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("Timeout!!!!") + return False + def cmd_home_dialysate_inlet_pump(self) -> int: """ Constructs and sends a dialysate inlet pump home request message to the HD. Index: dialin/hd/dialysate_outlet_flow.py =================================================================== diff -u -r9bc00e997e91dab8b404aa877b02ae3d4100d417 -re96f7b36e76ffad8f72e2c53d8c5a62e5abd10a2 --- dialin/hd/dialysate_outlet_flow.py (.../dialysate_outlet_flow.py) (revision 9bc00e997e91dab8b404aa877b02ae3d4100d417) +++ dialin/hd/dialysate_outlet_flow.py (.../dialysate_outlet_flow.py) (revision e96f7b36e76ffad8f72e2c53d8c5a62e5abd10a2) @@ -563,6 +563,31 @@ return 0 + def cmd_stop_dialysate_outlet_pump(self) -> int: + """ + Constructs and sends a dialysate outlet pump stop request message to the HD. + Constraints: + Must be logged into HD. + + @return: 1 if successful, zero otherwise + """ + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, + message_id=MsgIds.MSG_ID_HD_DIAL_OUT_PUMP_HARD_STOP.value) + + self.logger.debug("Stopping dialysate outlet pump") + + # Send message + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + self.logger.debug("Stopped dialysate outlet pump") + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("Timeout!!!!") + return False + def cmd_home_dialysate_outlet_pump(self) -> int: """ Constructs and sends a dialysate outlet pump home request message to the HD. Index: dialin/ui/dg_simulator.py =================================================================== diff -u -r0448a5c20523f3bd085494b5f797c833a3a0e46d -re96f7b36e76ffad8f72e2c53d8c5a62e5abd10a2 --- dialin/ui/dg_simulator.py (.../dg_simulator.py) (revision 0448a5c20523f3bd085494b5f797c833a3a0e46d) +++ dialin/ui/dg_simulator.py (.../dg_simulator.py) (revision e96f7b36e76ffad8f72e2c53d8c5a62e5abd10a2) @@ -7,8 +7,8 @@ # # @file dg_simulator.py # -# @author (last) Behrouz NematiPour -# @date (last) 29-Jun-2022 +# @author (last) Micahel Garthwaite +# @date (last) 08-Mar-2023 # @author (original) Peter Lucia # @date (original) 16-Mar-2021 # @@ -37,11 +37,14 @@ self.console_out = console_out self.can_interface = DenaliCanMessenger(can_interface=can_interface, logger=self.logger, - log_can=self._log_manager.log_level == "CAN_ONLY", console_out=console_out, passive_mode=passive_mode) self.can_interface.start() + self.ui_dg_set_rtc_req_timestamp = 0.0 + self.ui_dg_fw_version_req_timestamp = 0.0 + self.ui_service_info_req_timestamp = 0.0 + if self.can_interface is not None: channel_id = DenaliChannels.ui_to_dg_ch_id if auto_response: @@ -55,13 +58,14 @@ MsgIds.MSG_ID_UI_REQUEST_SERVICE_INFO.value, self._handler_system_usage_response) - def _handler_system_usage_response(self) -> None: + def _handler_system_usage_response(self,message,timestamp=0.0) -> None: """ Handles a request for system usage @return: None """ self.logger.debug("Handling request for system usage.") + self.ui_service_info_req_timestamp = timestamp payload = integer_to_bytearray(1619628663) payload += integer_to_bytearray(1619887863) @@ -72,7 +76,7 @@ self.can_interface.send(message, 0) - def _handler_set_rtc_request(self, message: dict) -> None: + def _handler_set_rtc_request(self, message: dict,timestamp=0.0) -> None: """ Handles a request to set the DG RTC @param message: (dict) the message content @@ -81,7 +85,7 @@ epoch = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] - + self.ui_dg_set_rtc_req_timestamp = timestamp self.logger.debug("DG: Request to set the DG epoch to {0}".format(epoch)) self.cmd_send_set_rtc_response(YES, 0) @@ -420,14 +424,14 @@ self.can_interface.send(message, 0) - def _handler_request_dg_version(self) -> None: + def _handler_request_dg_version(self, message,timestamp=0.0) -> None: """ Handles a request for the HD version @return: None """ self.logger.debug("Handling request for dg version.") - + self.ui_dg_fw_version_req_timestamp = timestamp self.cmd_send_version_dg_data(9, 9, 9, 9, 9, 9, 9, 9) self.cmd_send_dg_serial_number()