Index: leahi_dialin/dd/modules/constants.py =================================================================== diff -u -rfd7a25d8f068bcba594c01410a02a03f6afbcd59 -r028086f4e594e25b8e693242fdce1cc41c8b0312 --- leahi_dialin/dd/modules/constants.py (.../constants.py) (revision fd7a25d8f068bcba594c01410a02a03f6afbcd59) +++ leahi_dialin/dd/modules/constants.py (.../constants.py) (revision 028086f4e594e25b8e693242fdce1cc41c8b0312) @@ -16,3 +16,6 @@ RESET = 1 NO_RESET = 0 + +ACCEPTED = 1 +REJECTED = 0 Index: leahi_dialin/fp/filtration_purification.py =================================================================== diff -u -rc587268b85d4b16b4102869d2841be84f3a2a23f -r028086f4e594e25b8e693242fdce1cc41c8b0312 --- leahi_dialin/fp/filtration_purification.py (.../filtration_purification.py) (revision c587268b85d4b16b4102869d2841be84f3a2a23f) +++ leahi_dialin/fp/filtration_purification.py (.../filtration_purification.py) (revision 028086f4e594e25b8e693242fdce1cc41c8b0312) @@ -107,7 +107,7 @@ self.boost_pump = FPBoostPump(self.can_interface, self.logger) self.conductivity = FPConductivitySensors(self.can_interface, self.logger) self.flows = FPFlowSensors(self.can_interface, self.logger) - self.pumps = FPPumps(self.can_interface, self.logger) + self.fluid_pumps = FPPumps(self.can_interface, self.logger) self.levels = FPLevels(self.can_interface, self.logger) self.pressures = FPPressureSensors(self.can_interface, self.logger) self.ro_pump = FPROPump(self.can_interface, self.logger) Index: leahi_dialin/td/modules/constants.py =================================================================== diff -u -rafe332fec54d9d0432dfc0d54aef1debaa92b066 -r028086f4e594e25b8e693242fdce1cc41c8b0312 --- leahi_dialin/td/modules/constants.py (.../constants.py) (revision afe332fec54d9d0432dfc0d54aef1debaa92b066) +++ leahi_dialin/td/modules/constants.py (.../constants.py) (revision 028086f4e594e25b8e693242fdce1cc41c8b0312) @@ -22,3 +22,6 @@ PUMP_CONTROL_MODE_CLOSED_LOOP = 0 PUMP_CONTROL_MODE_OPEN_LOOP = 1 + +ACCEPTED = 1 +REJECTED = 0 \ No newline at end of file Index: leahi_dialin/td/proxies/ui_proxy.py =================================================================== diff -u -rf67b42d75954b722ae56eb8abc5facdbee636477 -r028086f4e594e25b8e693242fdce1cc41c8b0312 --- leahi_dialin/td/proxies/ui_proxy.py (.../ui_proxy.py) (revision f67b42d75954b722ae56eb8abc5facdbee636477) +++ leahi_dialin/td/proxies/ui_proxy.py (.../ui_proxy.py) (revision 028086f4e594e25b8e693242fdce1cc41c8b0312) @@ -16,7 +16,8 @@ import struct from logging import Logger -from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions +from leahi_dialin.td.modules.constants import ACCEPTED, REJECTED +from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions, RequestRejectReasons from leahi_dialin.protocols.CAN import DenaliMessage, DenaliCanMessenger, DenaliChannels from leahi_dialin.utils.base import AbstractSubSystem, publish from leahi_dialin.utils.conversions import integer_to_bytearray, unsigned_byte_to_bytearray, float_to_bytearray, \ @@ -191,34 +192,42 @@ dialyate_flow_rate: int, treatment_duration: int, saline_bolus_volume: int, + heparin_stop_time: int, + heparin_type: int, acid_concentrate: int, bicarb_concentrate: int, dialyzer_type: int, bp_interval: int, rinseback_flow_rate: int, - arterial_pressure_limt: int, + arterial_pressure_limit: int, venous_pressure_limit: int, venous_pressure_asymmetric: int, tmp_pressure_limit: int, - dialysate_temp: int) -> None: + dialysate_temp: float, + heparin_dispense_rate: float, + heparin_bolus_volume: float ) -> None: """ Constructs and sends a UI set treatment parameters message. :param blood_flow_rate: (int) blood flow rate (in mL/min) :param dialyate_flow_rate: (int) dialysate flow rate (in mL/min) :param treatment_duration: (int) treatment duration (in min) - :param saline_bolus_volume: (int) Saline bolus volume (in mL) + :param saline_bolus_volume: (int) saline bolus volume (in mL) + :param heparin_stop_time: (int) heparin stop time (in minutes) + :param heparin_type: (int) heparin Type :param acid_concentrate: (int) acid concentrate type :param bicarb_concentrate: (int) bicarbonate concentrate type :param dialyzer_type: (int) dialyzer type :param bp_interval: (int) blood pressure measurement interval (in min) - :param rinseback_flow_rate: (int) rinseback flow rate (in mL/min) - :param arterial_pressure_limt: (int) arterial pressure alarm limit window (in mmHg) + :param rinseback_flow_rate: (int) rinse back flow rate (in mL/min) + :param arterial_pressure_limit: (int) arterial pressure alarm limit window (in mmHg) :param venous_pressure_limit: (int) venous pressure alarm limit window (in mmHg) :param venous_pressure_asymmetric: (int) venous pressure alarm limit asymmetric (in mmHg) - :param tmp_pressure_limit: (int) transmembrane pressure alarm limit window - :param dialysate_temp: (int) dialysate temperature (in deg C) + :param tmp_pressure_limit: (int) transmembrane pressure alarm limit window (in mmHg) + :param dialysate_temp: (float) dialysate temperature (in deg C) + :param heparin_dispense_rate: (float) heparin dispense rate (in mL/hr) + :param heparin_bolus_volume: (float) heparin bolus volume (in mL) :return: None """ @@ -227,28 +236,31 @@ dia = integer_to_bytearray(dialyate_flow_rate) dur = integer_to_bytearray(treatment_duration) sal = integer_to_bytearray(saline_bolus_volume) + hst = integer_to_bytearray(heparin_stop_time) + het = integer_to_bytearray(heparin_type) acc = integer_to_bytearray(acid_concentrate) bic = integer_to_bytearray(bicarb_concentrate) dzr = integer_to_bytearray(dialyzer_type) bpi = integer_to_bytearray(bp_interval) rbf = integer_to_bytearray(rinseback_flow_rate) - apw = integer_to_bytearray(arterial_pressure_limt) + apw = integer_to_bytearray(arterial_pressure_limit) vpw = integer_to_bytearray(venous_pressure_limit) vpa = integer_to_bytearray(venous_pressure_asymmetric) - tmp = float_to_bytearray(tmp_pressure_limit) + tmp = integer_to_bytearray(tmp_pressure_limit) dtp = float_to_bytearray(dialysate_temp) + hdr = float_to_bytearray(heparin_dispense_rate) + hbv = float_to_bytearray(heparin_bolus_volume) - payload = bld + dia + dur + sal + acc + bic + dzr + bpi + rbf + apw + vpw + vpa + tmp + dtp + payload = bld + dia + dur + sal + hst + het + acc + bic + dzr + bpi + rbf + apw + vpw + vpa + tmp + dtp + hdr + hbv message = DenaliMessage.build_message(channel_id=DenaliChannels.ui_to_td_ch_id, message_id=MsgIds.MSG_ID_UI_TREATMENT_PARAMS_TO_VALIDATE.value, payload=payload) self.logger.debug("Sending treatment parameters to TD.") - self.can_interface.send(message, 0) - def cmd_send_ui_version_request(self): + def cmd_send_ui_version_request(self) -> None: """ Constructs and sends a UI version request broadcast. Can be used to retrieve all sub system version responses. @@ -269,3 +281,80 @@ self.logger.debug("Sending UI Version Request.") self.can_interface.send(message, 0) + + + def cmd_send_ui_initiate_treatment(self, accepted:int = ACCEPTED, rejection_reason:int = RequestRejectReasons.REQUEST_REJECT_REASON_NONE ) -> None: + """ + Constructs and sends a UI initiate treatment message. + + :param accepted: (int) the acceptance value + :param rejection_reason: (int) the rejection reason value + :return: none + """ + acc = unsigned_byte_to_bytearray(accepted) + rjr = unsigned_byte_to_bytearray(rejection_reason) + + payload = acc + rjr + + message = DenaliMessage.build_message(channel_id=DenaliChannels.ui_to_td_ch_id, + message_id=MsgIds.MSG_ID_UI_INITIATE_TREATMENT_WORKFLOW.value, + payload=payload) + + self.logger.debug("Sending UI Initiate Treatment Workflow.") + self.can_interface.send(message, 0) + + def cmd_send_ui_confirmed_treatment_parameters (self, accepted: int = ACCEPTED ) -> None: + """ + Constructs and sends a UI confirmation of treatment parameters message. + + :param accepted: (int) the acceptance value + :return: none + """ + acc = unsigned_byte_to_bytearray(accepted) + + payload = acc + + message = DenaliMessage.build_message(channel_id=DenaliChannels.ui_to_td_ch_id, + message_id=MsgIds.MSG_ID_UI_TREATMENT_PARAMS_CONFIRMED.value, + payload=payload) + + self.logger.debug("Sending UI Confirm Treatment Parameters.") + self.can_interface.send(message, 0) + + def cmd_send_ui_pause_resume_uf(self, accepted:int = ACCEPTED, rejection_reason:int = RequestRejectReasons.REQUEST_REJECT_REASON_NONE ) -> None: + """ + Constructs and sends a UI pause/resume ultrafiltration message. + + :param accepted: (int) the acceptance value + :param rejection_reason: (int) the rejection reason value + :return: none + """ + acc = unsigned_byte_to_bytearray(accepted) + rjr = unsigned_byte_to_bytearray(rejection_reason) + + payload = acc + rjr + + message = DenaliMessage.build_message(channel_id=DenaliChannels.ui_to_td_ch_id, + message_id=MsgIds.MSG_ID_UI_UF_PAUSE_RESUME_REQUEST.value, + payload=payload) + + self.logger.debug("Sending UI Pause Resume UF request.") + self.can_interface.send(message, 0) + + def cmd_send_ui_validate_uf_volume (self, uf_volume: float = 0.0 ) -> None: + """ + Constructs and sends a UI validate ultrafiltration message. + + :param uf_volume: (float) the uf volume between 0.0 - 8.0 + :return: none + """ + ufv = float_to_bytearray(uf_volume) + + payload = ufv + + message = DenaliMessage.build_message(channel_id=DenaliChannels.ui_to_td_ch_id, + message_id=MsgIds.MSG_ID_UI_ULTRAFILTRATION_VOLUME_TO_VALIDATE.value, + payload=payload) + + self.logger.debug("Sending UI Ultrafiltration volume to validate.") + self.can_interface.send(message, 0) \ No newline at end of file Index: leahi_dialin/td/treatment_delivery.py =================================================================== diff -u -r51b54b55fd498d481061cb3e02e312354e970242 -r028086f4e594e25b8e693242fdce1cc41c8b0312 --- leahi_dialin/td/treatment_delivery.py (.../treatment_delivery.py) (revision 51b54b55fd498d481061cb3e02e312354e970242) +++ leahi_dialin/td/treatment_delivery.py (.../treatment_delivery.py) (revision 028086f4e594e25b8e693242fdce1cc41c8b0312) @@ -30,6 +30,7 @@ from .modules.voltages import TDVoltages from .proxies.dd_proxy import DDProxy +from .proxies.ui_proxy import UIProxy from ..common.msg_defs import MsgIds, MsgFieldPositions, MsgFieldPositionsFWVersions from ..common.td_defs import TDOpModes @@ -126,6 +127,7 @@ self.voltages = TDVoltages(self.can_interface, self.logger) self.dd_proxy = DDProxy(self.can_interface, self.logger) + self.ui_proxy = UIProxy(self.can_interface, self.logger) @publish(["td_debug_events_timestamp","td_debug_events"]) def _handler_td_debug_event_sync(self, message, timestamp = 0.0):