Index: leahi_dialin/dd/modules/piston_pump.py =================================================================== diff -u -rf9dd375900151a5daafe3b687187187645d5f1ab -ra313166ac02fdc81a9d2b24eca45cded18fd468e --- leahi_dialin/dd/modules/piston_pump.py (.../piston_pump.py) (revision f9dd375900151a5daafe3b687187187645d5f1ab) +++ leahi_dialin/dd/modules/piston_pump.py (.../piston_pump.py) (revision a313166ac02fdc81a9d2b24eca45cded18fd468e) @@ -5,7 +5,7 @@ # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # -# @file piston_pumps.py +# @file piston_pump.py # # @author (last) Micahel Garthwaite # @date (last) 07-Mar-2023 @@ -20,13 +20,20 @@ from .constants import RESET, NO_RESET from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions from leahi_dialin.protocols.CAN import DenaliMessage, DenaliChannels -from leahi_dialin.utils.base import AbstractSubSystem, publish +from leahi_dialin.utils.base import AbstractSubSystem, publish, DialinEnum from leahi_dialin.utils.checks import check_broadcast_interval_override_ms from leahi_dialin.utils.conversions import integer_to_bytearray, float_to_bytearray +@unique +class DDPistonPumpsEnum(DialinEnum): + ACID = 0 # Acid piston pump + BICARB = 1 # Bicarbonate piston pump + UF = 2 # Ultrafilteration piston pump + NUM_OF_PISTON_PUMPS = 3 # Number of piston pumps + class DDPistonPumps(AbstractSubSystem): """ - PistonPumps + DDPistonPumps Dialysate Delivery (DD) Dialin API sub-class for piston pumps related commands. """ @@ -126,14 +133,14 @@ self.logger.error("Timeout!!!!") return False - def cmd_piston_set_start_stop(self, pump_id: int, command: int, count: int, speed: float, volume: float ) -> int: + def cmd_piston_set_start_stop_override(self, pump_id: int, command: int, count: int, flow_rate: float, volume: float ) -> int: """ Constructs and sends the piston pump start stop command @param pump_id: unsigned int - concentrate pump ID @param command: int - value to command the concentrate pump @param count: int - vale to set the cycle count to - @param speed: float - ml/min to set the speed to + @param flow_rate: float - ml/min to set the speed to @param volume: float - the volume to set to @return: 1 if successful, zero otherwise @@ -142,7 +149,7 @@ pmp = integer_to_bytearray(pump_id) cmd = integer_to_bytearray(command) cyc = integer_to_bytearray(count) - spd = float_to_bytearray(speed) + spd = float_to_bytearray(flow_rate) vlm = float_to_bytearray(volume) payload = pmp + cmd + cyc + spd + vlm @@ -161,4 +168,36 @@ return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: self.logger.error("Timeout!!!!") + return False + + def cmd_piston_pump_fill_after_dispense_override(self, fill: bool, reset: int = NO_RESET) -> int: + """ + Constructs and sends the piston pump fill after dispense override command + Constraints: + Must be logged into DD. + + @param fill: integer - 0 = false, 1 = true to override piston pump fill + @param reset: integer - 1 to reset a previous override, 0 to override + @return: 1 if successful, zero otherwise + """ + + reset_byte_array = integer_to_bytearray(reset) + fl = integer_to_bytearray(fill) + payload = reset_byte_array + fl + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, + message_id=MsgIds.MSG_ID_DD_PISTON_PUMP_FILL_AFTER_DISPENSE_OVERRIDE_REQUEST.value, + payload=payload) + + self.logger.debug("override DD piston pump fill after dispense.") + + # Send message + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.error("Timeout!!!!") return False \ No newline at end of file