Index: dialin/common/dg_defs.py =================================================================== diff -u -rc1ec3baacb779f5176e3a7a619fe49f2dc4c19cd -rdc07ecb63eed240b6d3b47dd96743f93014c564c --- dialin/common/dg_defs.py (.../dg_defs.py) (revision c1ec3baacb779f5176e3a7a619fe49f2dc4c19cd) +++ dialin/common/dg_defs.py (.../dg_defs.py) (revision dc07ecb63eed240b6d3b47dd96743f93014c564c) @@ -281,7 +281,8 @@ DG_EVENT_SW_CONFIG_UPDATE = 10 # DG new software configuration has been updated DG_EVENT_SCHEDULED_RUNS_UPDATE = 11 # DG new scheduled runs information has been updated DG_EVENT_HEATERS_INFO_UPDATE = 12 # DG new heaters information has been updated - NUM_OF_DG_EVENT_IDS = 13 # Total number of DG events + DG_EVENT_AVG_DIALYSATE_FILL_COND_VALUES = 13 # DG average dialysate fill conductivity values + NUM_OF_DG_EVENT_IDS = 14 # Total number of DG events @unique Index: dialin/common/msg_ids.py =================================================================== diff -u -re41a1079f508d5c92e0d83ab6244b5ef79919083 -rdc07ecb63eed240b6d3b47dd96743f93014c564c --- dialin/common/msg_ids.py (.../msg_ids.py) (revision e41a1079f508d5c92e0d83ab6244b5ef79919083) +++ dialin/common/msg_ids.py (.../msg_ids.py) (revision dc07ecb63eed240b6d3b47dd96743f93014c564c) @@ -466,6 +466,7 @@ MSD_ID_DG_RTC_CTL_REG1_STATUS_OVERRIDE = 0xA062 MSD_ID_DG_RTC_CTL_REG3_STATUS_OVERRIDE = 0xA063 MSG_ID_DG_NELSON_DISINFECT_SUPPORT = 0xA064 + MSG_ID_DG_SET_DIALYSATE_MIXING_RATIOS = 0xA065 MSG_ID_HD_DEBUG_EVENT = 0xFFF1 MSG_ID_DG_DEBUG_EVENT = 0xFFF2 Index: dialin/dg/reservoirs.py =================================================================== diff -u -racd09d02879e8add4cf7f694f5db8e423a76c341 -rdc07ecb63eed240b6d3b47dd96743f93014c564c --- dialin/dg/reservoirs.py (.../reservoirs.py) (revision acd09d02879e8add4cf7f694f5db8e423a76c341) +++ dialin/dg/reservoirs.py (.../reservoirs.py) (revision dc07ecb63eed240b6d3b47dd96743f93014c564c) @@ -20,7 +20,7 @@ from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import DenaliMessage, DenaliChannels from ..utils.base import AbstractSubSystem, publish, DialinEnum -from ..utils.conversions import integer_to_bytearray +from ..utils.conversions import integer_to_bytearray, float_to_bytearray @unique @@ -136,6 +136,35 @@ return True + def cmd_set_dialysate_mixing_ratios(self, acid: float, bicarb: float) -> bool: + """ + Sends a command to the DG to set the acid and bicarb mixing ratios + @param acid (float) acid's dialysate mixing ratio + @param bicarb (float) bicarb's dialysate mixing ratio + @return: True if command sent, False if timed out + """ + + ac = float_to_bytearray(acid) + bc = float_to_bytearray(bicarb) + payload = ac + bc + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dg_ch_id, + message_id=MsgIds.MSG_ID_DG_SET_DIALYSATE_MIXING_RATIOS.value, + payload=payload) + + self.logger.debug("Setting acid mixing ratio to {:5.3f} and bicarb mixing ration to {:5.3f}".format(acid, bicarb)) + + # 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.debug("Timeout!!!!") + return False + @publish(["active_reservoir", "fill_to_vol_ml", "drain_to_vol_ml", "time_reservoir_cycle", "time_reservoir_fill_2_switch", "time_uf_decay", "temp_uf_fill", "temp_reservoir_use_actual", "temp_reservoir_end_fill", "temp_avg_fill", "temp_last_fill", "time_rsrvr_fill"])