Index: leahi_dialin/common/dd_defs.py =================================================================== diff -u -rbebba1d868f26b10c5cc045fbcb7ca2b067267a6 -r36b34b8458cfce3518ba08d73f2747b8011c462d --- leahi_dialin/common/dd_defs.py (.../dd_defs.py) (revision bebba1d868f26b10c5cc045fbcb7ca2b067267a6) +++ leahi_dialin/common/dd_defs.py (.../dd_defs.py) (revision 36b34b8458cfce3518ba08d73f2747b8011c462d) @@ -330,3 +330,10 @@ D70_VALV = 26 # Ultrafiltration Valve 1 Outlet (D70) D72_VALV = 27 # Ultrafiltration Valve 2 Outlet (D72) NUM_OF_DD_VALVES = 28 # Number of Valves for the DD + +@unique +class DDAcidCompositionNames(DialinEnum): + ACID_08_1251_1 = 0 # Acid type 08-1251-1 + ACID_08_2251_0 = 1 # Acid type 08-2251-0 + ACID_08_3251_9 = 2 # Acid type 08-3251-9 + NUM_OF_ACID_TYPE = 3 # Number of Acid Types \ No newline at end of file Index: leahi_dialin/common/msg_ids.py =================================================================== diff -u -rba2793fd2b970fc89af085f1dfe4e8b6fe408353 -r36b34b8458cfce3518ba08d73f2747b8011c462d --- leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision ba2793fd2b970fc89af085f1dfe4e8b6fe408353) +++ leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision 36b34b8458cfce3518ba08d73f2747b8011c462d) @@ -261,6 +261,14 @@ MSG_ID_DD_BLOOD_LEAK_INTENSITY_MOVING_AVERAGE_OVERRIDE_REQUEST = 0xA04C MSG_ID_DD_BLOOD_LEAK_ZEROING_INTERVAL_IN_MS_OVERRIDE_REQUEST = 0xA04D MSG_ID_DD_BLOOD_LEAK_ZERO_REQUEST = 0xA04E + MSG_ID_DD_FILTERED_COND_SENSOR_READINGS_OVERRIDE_REQUEST = 0xA04F + MSG_ID_DD_FILTERED_COND_SENSOR_TEMPERATURE_OVERRIDE_REQUEST = 0xA050 + MSG_ID_DD_VOLTAGE_DATA_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0xA051 + MSG_ID_DD_MONITORED_VOLTAGE_OVERRIDE_REQUEST = 0xA052 + MSG_ID_DD_DIALYSATE_FLOW_RATE_OVERRIDE_REQUEST = 0xA053 + MSG_ID_DD_TARGET_DIALYSATE_TEMPERATURE_OVERRIDE_REQUEST = 0xA054 + MSG_ID_DD_ULTRAFILTRATION_RATE_OVERRIDE_REQUEST = 0xA055 + MSG_ID_DD_ACID_COMPOSITION_OVERRIDE_REQUEST = 0xA056 MSG_ID_DD_PISTON_PUMP_DATA_PUBLISH_OVERRIDE_REQUEST = 0xAF00 MSG_ID_DD_PISTON_PUMP_START_STOP_OVERRIDE_REQUEST = 0xAF01 Index: leahi_dialin/dd/proxies/td_proxy.py =================================================================== diff -u -r2dab2b0329a56006e07cd36a3883ed099d7a367a -r36b34b8458cfce3518ba08d73f2747b8011c462d --- leahi_dialin/dd/proxies/td_proxy.py (.../td_proxy.py) (revision 2dab2b0329a56006e07cd36a3883ed099d7a367a) +++ leahi_dialin/dd/proxies/td_proxy.py (.../td_proxy.py) (revision 36b34b8458cfce3518ba08d73f2747b8011c462d) @@ -16,7 +16,9 @@ import struct from logging import Logger +from .constants import RESET, NO_RESET from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions +from leahi_dialin.common.dd_defs import DDAcidCompositionNames 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, byte_to_bytearray, float_to_bytearray @@ -129,4 +131,152 @@ payload=payload) self.logger.debug("Sending TD start pre gen request to DD.") - self.can_interface.send(message, 0) \ No newline at end of file + self.can_interface.send(message, 0) + + def cmd_dialysate_flow_rate_override(self, dialysate_rate: float, reset: int = NO_RESET) -> int: + """ + Constructs and sends the dialysate flow rate override command + Constraints: + Must be logged into DD. + + @param dialysate_rate: float - flow rate value to override dialysate flow rate with + @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) + flow_rate = float_to_bytearray(dialysate_rate) + payload = reset_byte_array + flow_rate + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, + message_id=MsgIds.MSG_ID_DD_DIALYSATE_FLOW_RATE_OVERRIDE_REQUEST.value, + payload=payload) + + if reset == RESET: + str_res = "reset back to normal" + else: + str_res = str(dialysate_rate) + self.logger.debug("override switch frequency " + ": " + str_res) + + # 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 + + def cmd_target_dialysate_temperature_override(self, dialysate_temp: float, reset: int = NO_RESET) -> int: + """ + Constructs and sends the target dialysate temperature override command + Constraints: + Must be logged into DD. + + @param dialysate_temp: float - temperature value to override target dialysate temperature with + @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) + target_temp = float_to_bytearray(dialysate_temp) + payload = reset_byte_array + target_temp + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, + message_id=MsgIds.MSG_ID_DD_TARGET_DIALYSATE_TEMPERATURE_OVERRIDE_REQUEST.value, + payload=payload) + + if reset == RESET: + str_res = "reset back to normal" + else: + str_res = str(dialysate_temp) + self.logger.debug("override switch frequency " + ": " + str_res) + + # 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 + + def cmd_ultrafiltration_rate_override(self, uf_rate: float, reset: int = NO_RESET) -> int: + """ + Constructs and sends the ultrafiltration rate override command + Constraints: + Must be logged into DD. + + @param uf_rate: float - ultrafiltration rate value to override ultrafiltration rate with + @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) + rate = float_to_bytearray(uf_rate) + payload = reset_byte_array + rate + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, + message_id=MsgIds.MSG_ID_DD_ULTRAFILTRATION_RATE_OVERRIDE_REQUEST.value, + payload=payload) + + if reset == RESET: + str_res = "reset back to normal" + else: + str_res = str(uf_rate) + self.logger.debug("override switch frequency " + ": " + str_res) + + # 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 + + def cmd_acid_composition_override(self, acid_comp: int = DDAcidCompositionNames.ACID_08_1251_1.value, reset: int = NO_RESET) -> int: + """ + Constructs and sends the acid composition override command + Constraints: + Must be logged into DD. + + @param acid_comp: float - enumerated value to override the acid composition with + @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) + acid = float_to_bytearray(acid_comp) + payload = reset_byte_array + acid + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, + message_id=MsgIds.MSG_ID_DD_ACID_COMPOSITION_OVERRIDE_REQUEST.value, + payload=payload) + + if reset == RESET: + str_res = "reset back to normal" + else: + str_res = str(acid_comp) + self.logger.debug("override switch frequency " + ": " + str_res) + + # 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