Index: leahi_dialin/dd/proxies/td_proxy.py =================================================================== diff -u -r38e8dd31728056dbb7f9304c98ab16d7147b75a2 -r941ca56f3f41c92c4b025a0713ee1d99c792aab8 --- leahi_dialin/dd/proxies/td_proxy.py (.../td_proxy.py) (revision 38e8dd31728056dbb7f9304c98ab16d7147b75a2) +++ leahi_dialin/dd/proxies/td_proxy.py (.../td_proxy.py) (revision 941ca56f3f41c92c4b025a0713ee1d99c792aab8) @@ -18,6 +18,7 @@ from logging import Logger from leahi_dialin.common.msg_defs import MsgIds, MsgFieldPositions +from leahi_dialin.common.override_templates import cmd_generic_override 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, float_to_bytearray @@ -86,7 +87,7 @@ def cmd_td_send_dd_gen_dialysate_request(self, start: bool = 0, dial_rate: float = 0, uf_rate: float = 0, - dial_temp: float = 0, bypass: int = 0, acid: int = 0, bicarb: int = 0): + dial_temp: float = 0, bypass: int = 0, acid_conv_factor: float = 0.0, bicarb_conv_factor: float = 0.0, sodium: int = 0, bicarb_volume: int = 0): """ Constructs and sends a TD gen dialysate request to the DD. @@ -97,19 +98,24 @@ uf = float_to_bytearray(uf_rate) temp = float_to_bytearray(dial_temp) byp = integer_to_bytearray(bypass) - acd = integer_to_bytearray(acid) - bic = integer_to_bytearray(bicarb) - payload = stt + dial + uf + temp + byp + acd + bic - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, - message_id=MsgIds.MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA.value, - payload=payload) + acd = float_to_bytearray(acid_conv_factor) + bic = float_to_bytearray(bicarb_conv_factor) + sod = integer_to_bytearray(sodium) + bvl = integer_to_bytearray(bicarb_volume) + payload = stt + dial + uf + temp + byp + acd + bic + sod + bvl - self.logger.debug("Sending TD gen dialysate data request to DD.") - self.can_interface.send(message, 0) + cmd_generic_override(payload = payload, + reset = None, + channel_id = DenaliChannels.dialin_to_dd_ch_id, + msg_id = MsgIds.MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA, + entity_name = 'TD Gen Dialysate Request', + override_text = 'N/A', + logger = self.logger, + can_interface = self.can_interface) def cmd_td_send_dd_start_pre_gen_request(self, start: bool = 0, dialysate_rate: float = 0.0, dialysate_temp: float = 0.0, - acid_type: int = 0, bicarb_type: int = 0 ): + acid_conv_factor: float = 0.0, bicarb_conv_factor: float = 0.0, sodium: int = 0, bicarb_volume: int = 0): """ Constructs and sends a TD start pre gen dialysate request to the DD. :param start: start and stop boolean @@ -122,16 +128,21 @@ stt = integer_to_bytearray(start) dial = float_to_bytearray(dialysate_rate) temp = float_to_bytearray(dialysate_temp) - acd = integer_to_bytearray(acid_type) - bic = integer_to_bytearray(bicarb_type) - payload = stt + dial + temp + acd + bic + acd = float_to_bytearray(acid_conv_factor) + bic = float_to_bytearray(bicarb_conv_factor) + sod = integer_to_bytearray(sodium) + bvl = integer_to_bytearray(bicarb_volume) + payload = stt + dial + temp + acd + bic + sod + bvl - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, - message_id=MsgIds.MSG_ID_DD_PRE_GEN_DIALYSATE_REQUEST_DATA.value, - payload=payload) + cmd_generic_override(payload = payload, + reset = None, + channel_id = DenaliChannels.dialin_to_dd_ch_id, + msg_id = MsgIds.MSG_ID_DD_PRE_GEN_DIALYSATE_REQUEST_DATA, + entity_name = 'TD Pre-Gen Dialysate Request', + override_text = 'N/A', + logger = self.logger, + can_interface = self.can_interface) - self.logger.debug("Sending TD start pre gen request to DD.") - self.can_interface.send(message, 0) def cmd_td_override_treatment_parameter(self, paramID: int, value, reset: int = 0): """ @@ -156,9 +167,11 @@ val = integer_to_bytearray(int(value)) payload = rst + val + pid - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, - message_id=MsgIds.MSG_ID_DD_TREATMENT_PARAMS_OVERRIDE_REQUEST.value, - payload=payload) - - self.logger.debug("Sending DD treatment parameter override: id={}, value={}, reset={}".format( paramID, value, reset)) - self.can_interface.send(message, 0) + cmd_generic_override(payload = payload, + reset = None, + channel_id = DenaliChannels.dialin_to_dd_ch_id, + msg_id = MsgIds.MSG_ID_DD_TREATMENT_PARAMS_OVERRIDE_REQUEST, + entity_name = f'DD treatment parameter override: id={paramID}, value={value}, reset={reset}', + override_text = 'N/A', + logger = self.logger, + can_interface = self.can_interface)