Index: dialin/common/msg_ids.py =================================================================== diff -u -ra7512831552e0e4431ceface9d5d08483db10056 -r46ae582aedfc3ba78748f99bbbd6c5659582a758 --- dialin/common/msg_ids.py (.../msg_ids.py) (revision a7512831552e0e4431ceface9d5d08483db10056) +++ dialin/common/msg_ids.py (.../msg_ids.py) (revision 46ae582aedfc3ba78748f99bbbd6c5659582a758) @@ -211,8 +211,8 @@ MSG_ID_PRESSURE_ARTERIAL_OVERRIDE = 0X8017 MSG_ID_PRESSURE_VENOUS_OVERRIDE = 0X8018 MSG_ID_OCCLUSION_BLOOD_PUMP_OVERRIDE = 0X8019 - MSG_ID_OCCLUSION_DIAL_IN_PUMP_OVERRIDE = 0X801A - MSG_ID_OCCLUSION_DIAL_OUT_PUMP_OVERRIDE = 0X801B + MSG_ID_BLOOD_PUMP_ROTOR_COUNT_OVERRIDE = 0X801A + MSG_ID_SET_ARTERIAL_PRESSURE_OFFSET = 0X801B MSG_ID_PRES_OCCL_SEND_INTERVAL_OVERRIDE = 0X801C MSG_ID_SET_RTC_DATE_TIME = 0X801D MSG_ID_DIAL_OUT_FLOW_SEND_INTERVAL_OVERRIDE = 0X801E Index: dialin/hd/blood_flow.py =================================================================== diff -u -r076965b54ec7f9711537ad5553de65b4da11338e -r46ae582aedfc3ba78748f99bbbd6c5659582a758 --- dialin/hd/blood_flow.py (.../blood_flow.py) (revision 076965b54ec7f9711537ad5553de65b4da11338e) +++ dialin/hd/blood_flow.py (.../blood_flow.py) (revision 46ae582aedfc3ba78748f99bbbd6c5659582a758) @@ -51,7 +51,7 @@ self.measured_blood_pump_mc_speed = 0.0 self.measured_blood_pump_mc_current = 0.0 self.pwm_duty_cycle_pct = 0.0 - self.flow_signal_strength = 0.0 + self.rotor_count = 0 def get_target_blood_flow_rate(self): """ @@ -109,13 +109,13 @@ """ return self.pwm_duty_cycle_pct - def get_flow_signal_strength(self): + def get_rotor_count(self): """ - Gets the blood flow signal strength pct + Gets the blood pump rotor count (since cartridge installed) - @return: the blood flow signal strength pct (0..100) + @return: the blood pump rotor count """ - return self.flow_signal_strength + return self.rotor_count @publish(["target_blood_flow_rate", "measured_blood_flow_rate", "measured_blood_pump_rotor_speed", "measured_blood_pump_speed", "measured_blood_pump_mc_speed", "measured_blood_pump_mc_current", @@ -143,7 +143,7 @@ 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])) - sig = struct.unpack('f', bytearray( + rot = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8])) self.target_blood_flow_rate = tgt[0] @@ -153,7 +153,7 @@ self.measured_blood_pump_mc_speed = mcspeed[0] self.measured_blood_pump_mc_current = mccurr[0] self.pwm_duty_cycle_pct = pwm[0] - self.flow_signal_strength = sig[0] + self.rotor_count = rot[0] def cmd_blood_flow_set_point_override(self, flow: int, mode: int = PUMP_CONTROL_MODE_CLOSED_LOOP, reset: int = NO_RESET) -> int: @@ -512,3 +512,44 @@ else: self.logger.debug("Timeout!!!!") return False + + def cmd_blood_pump_rotor_count_override(self, rot_count: int, reset: int = NO_RESET) -> int: + """ + Constructs and sends the blood 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_BLOOD_PUMP_ROTOR_COUNT_OVERRIDE.value, + payload=payload) + + self.logger.debug("override blood 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("Blood 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 + Index: dialin/hd/pressure_occlusion.py =================================================================== diff -u -rebf0a72a1a1a52f3cfe20975de4857201275888c -r46ae582aedfc3ba78748f99bbbd6c5659582a758 --- dialin/hd/pressure_occlusion.py (.../pressure_occlusion.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) +++ dialin/hd/pressure_occlusion.py (.../pressure_occlusion.py) (revision 46ae582aedfc3ba78748f99bbbd6c5659582a758) @@ -356,3 +356,41 @@ else: self.logger.debug("Timeout!!!!") return False + + def cmd_arterial_pressure_offset_override(self, offset: float, reset: int = NO_RESET) -> int: + """ + Constructs and sends the arterial pressure offset override command + Constraints: + Must be logged into HD. + + @param offset: float - offset (in mmHg) for arterial pressure sensor + @param reset: integer - 1 to reset a previous override, 0 to override + @return: 1 if successful, zero otherwise + """ + + rst = integer_to_bytearray(reset) + off = float_to_bytearray(offset) + payload = rst + off + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, + message_id=MsgIds.MSG_ID_SET_ARTERIAL_PRESSURE_OFFSET.value, + payload=payload) + + self.logger.debug("override arterial pressure offset") + + # Send message + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + if reset == RESET: + str_res = "reset back to normal: " + else: + str_res = str(offset) + " mmHg: " + self.logger.debug("Arterial pressure offset 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