Index: dialin/common/msg_ids.py =================================================================== diff -u -r19d246d9c099e1a15570767f82ca79502aff2776 -refb6f15147a69ecfd0fb086ff33f906b7ce45869 --- dialin/common/msg_ids.py (.../msg_ids.py) (revision 19d246d9c099e1a15570767f82ca79502aff2776) +++ dialin/common/msg_ids.py (.../msg_ids.py) (revision efb6f15147a69ecfd0fb086ff33f906b7ce45869) @@ -342,6 +342,7 @@ MSG_ID_HD_BLOOD_PUMP_SET_PWM = 0x8085 MSG_ID_HD_DIAL_IN_SET_PWM = 0x8086 MSG_ID_HD_DIAL_OUT_SET_PWM = 0x8087 + MSG_ID_DIALYSATE_INLET_PUMP_ROTOR_COUNT_OVERRIDE = 0x8088 MSG_ID_DG_TESTER_LOGIN_REQUEST = 0xA000 MSG_ID_DG_ALARM_STATE_OVERRIDE = 0xA001 Index: dialin/hd/dialysate_inlet_flow.py =================================================================== diff -u -rcd913c56192aee8e251d0486d044442411902def -refb6f15147a69ecfd0fb086ff33f906b7ce45869 --- dialin/hd/dialysate_inlet_flow.py (.../dialysate_inlet_flow.py) (revision cd913c56192aee8e251d0486d044442411902def) +++ dialin/hd/dialysate_inlet_flow.py (.../dialysate_inlet_flow.py) (revision efb6f15147a69ecfd0fb086ff33f906b7ce45869) @@ -53,6 +53,7 @@ self.measured_dialysate_inlet_pump_mc_speed = 0.0 self.measured_dialysate_inlet_pump_mc_current = 0.0 self.pwm_duty_cycle_pct = 0.0 + self.rotor_count = 0 def get_target_dialysate_inlet_flow_rate(self): """ @@ -110,14 +111,22 @@ """ return self.pwm_duty_cycle_pct + def get_rotor_count(self): + """ + Gets the dialysate inlet pump rotor count (since cartridge installed) + + @return: the dialysate inlet pump rotor count + """ + return self.rotor_count + @publish([ "target_dialysate_inlet_flow_rate", "measured_dialysate_inlet_flow_rate", "measured_dialysate_inlet_pump_rotor_speed", "measured_dialysate_inlet_pump_speed", "measured_dialysate_inlet_pump_mc_speed", "measured_dialysate_inlet_pump_mc_current", - "pwm_duty_cycle_pct" + "pwm_duty_cycle_pct", "rotor_count" ]) def _handler_dialysate_inlet_flow_sync(self, message): """ @@ -142,6 +151,8 @@ message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6])) pwm = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7])) + rot = struct.unpack('I', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8])) self.target_dialysate_inlet_flow_rate = tgt[0] self.measured_dialysate_inlet_flow_rate = flow[0] @@ -150,6 +161,7 @@ self.measured_dialysate_inlet_pump_mc_speed = mcspeed[0] self.measured_dialysate_inlet_pump_mc_current = mccurr[0] self.pwm_duty_cycle_pct = pwm[0] + self.rotor_count = rot[0] def cmd_dialysate_inlet_flow_set_point_override(self, flow: int, @@ -472,6 +484,46 @@ self.logger.debug("Timeout!!!!") return False + def cmd_dialysate_inlet_pump_rotor_count_override(self, rot_count: int, reset: int = NO_RESET) -> int: + """ + Constructs and sends the dialysate inlet pump rotor count override command + Constraints: + Must be logged into HD. + Given count must be zero or positive integer. + + @param rot_count: integer - rotor count to override with + @param reset: integer - 1 to reset a previous override, 0 to override + @return: 1 if successful, zero otherwise + """ + + rst = integer_to_bytearray(reset) + cnt = integer_to_bytearray(rot_count) + payload = rst + cnt + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, + message_id=MsgIds.MSG_ID_DIALYSATE_INLET_PUMP_ROTOR_COUNT_OVERRIDE.value, + payload=payload) + + self.logger.debug("override dialysate inlet pump rotor count") + + # Send message + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + # self.logger.debug(received_message) + if reset == RESET: + str_res = "reset back to normal: " + else: + str_res = str(rot_count) + ": " + self.logger.debug("Dialysate inlet pump rotor count overridden to " + str_res + + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("Timeout!!!!") + return False + def cmd_dialysate_inlet_pump_set_pwm(self, pwm_pct: float) -> int: """ Constructs and sends a dialysate inlet pump set pwm message to the HD.