Index: dialin/hd/air_bubbles.py =================================================================== diff -u -r8474f8e345f165187d4dde17840575ee4e98a9b4 -r4b8fb150f3de89c148809f7fa294ea76c28dceb3 --- dialin/hd/air_bubbles.py (.../air_bubbles.py) (revision 8474f8e345f165187d4dde17840575ee4e98a9b4) +++ dialin/hd/air_bubbles.py (.../air_bubbles.py) (revision 4b8fb150f3de89c148809f7fa294ea76c28dceb3) @@ -33,8 +33,7 @@ """ # Air bubble detectors - ADA = 0 # Air bubble Detector Arterial - ADV = 1 # Air bubble Detector Venous + ADV = 0 # Air bubble Detector Venous # Air bubble detectors status BUBBLE_DETECTED_STATUS = 0 # Air bubble detected @@ -59,27 +58,27 @@ self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_air_bubbles_data_sync) - # Initialize status of ADA and ADV air bubble detectors to fluid (no air bubble) detected - self.air_bubbles_status = [self.FLUID_DETECTED_STATUS, self.FLUID_DETECTED_STATUS] + # Initialize status of ADV air bubble detectors to fluid (no air bubble) detected + self.air_bubbles_status = [self.FLUID_DETECTED_STATUS] - # Initialize state of ADA and ADV air bubble detectors state machine to normal - self.air_bubbles_state = [self.AIR_BUBBLE_NORMAL_STATE, self.AIR_BUBBLE_NORMAL_STATE] + # Initialize state of ADV air bubble detectors state machine to normal + self.air_bubbles_state = [self.AIR_BUBBLE_NORMAL_STATE] def get_air_bubble_status(self, index: int) -> int: """ - Gets the given air bubble status using index 0 for ADA and index 1 for ADV. + Gets the given air bubble status using index 0 for ADV. - @param index: integer - 0 for getting ADA detector status, 1 for getting ADV detector status + @param index: integer - 0 for getting ADV detector status @return: Air bubble status (air bubble or fluid) for given detector """ return self.air_bubbles_status[index] def get_air_bubble_state(self, index: int) -> int: """ - Gets the given air bubble state using index 0 for ADA and index 1 for ADV. + Gets the given air bubble state using index 0 for ADV. - @param index: integer - 0 for getting ADA detector state, 1 for getting ADV detector state + @param index: integer - 0 for getting ADV detector state @return: integer - air bubble state (0: init, 1: self-test, 2: normal) for given detector """ @@ -89,23 +88,19 @@ def _handler_air_bubbles_data_sync(self, message): """ Handles published air bubbles data messages. Air bubble status and state are captured - for ADA and ADV detectors. + for ADV detector. - @param message: published air bubbles data message as: ADA status, ADA state, ADV status, ADV state + @param message: published air bubbles data message as: ADV status, ADV state @return: None """ - ada_status = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1])) - ada_state = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2])) adv_status = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3])) + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1])) adv_state = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4])) + message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2])) - self.air_bubbles_status = [ada_status[0], adv_status[0]] - self.air_bubbles_state = [ada_state[0], adv_state[0]] + self.air_bubbles_status = [adv_status[0]] + self.air_bubbles_state = [adv_state[0]] def cmd_air_bubble_status_override(self, status: int, index: int, reset: int = NO_RESET) -> int: """ @@ -115,7 +110,7 @@ Given detector must be one of the detectors listed below. @param status: unsigned int - status (0=air bubble, 1=fluid) to override detector with - @param index: integer - 0 for ADA status override, 1 for ADV status override + @param index: integer - 0 for ADV status override @param reset: integer - 1 to reset a previous override, 0 to override @return: 1 if successful, zero otherwise """ @@ -129,9 +124,7 @@ message_id=MsgIds.MSG_ID_HD_BUBBLE_STATUS_OVERRIDE.value, payload=payload) - if index == self.ADA: - self.logger.debug("Override air bubble detector ADA status value") - elif index == self.ADV: + if index == self.ADV: self.logger.debug("Override air bubble detector ADV status value") # Send message @@ -147,11 +140,11 @@ def cmd_air_bubble_self_test_request(self, index: int) -> int: """ - Request air bubble self-test for a given detector (ADA or ADV) + Request air bubble self-test for a given detector (ADV) Constraints: Must be logged into HD. - @param index: integer - 0 for ADA status override, 1 for ADV status override + @param index: integer - 0 for ADV status override @return: 1 if successful, zero otherwise """ @@ -161,9 +154,7 @@ message_id=MsgIds.MSG_ID_HD_BUBBLE_SELF_TEST_REQUEST.value, payload=payload) - if index == self.ADA: - self.logger.debug("Request air bubble self-test for detector ADA") - elif index == self.ADV: + if index == self.ADV: self.logger.debug("Request air bubble self-test for detector ADV") # Send message Index: tests/test_uf.py =================================================================== diff -u -re21625cbe20d1a836cb78dbc1350fcd894bdcb9f -r4b8fb150f3de89c148809f7fa294ea76c28dceb3 --- tests/test_uf.py (.../test_uf.py) (revision e21625cbe20d1a836cb78dbc1350fcd894bdcb9f) +++ tests/test_uf.py (.../test_uf.py) (revision 4b8fb150f3de89c148809f7fa294ea76c28dceb3) @@ -19,6 +19,7 @@ from dialin.hd.hemodialysis_device import HD from dialin.dg.dialysate_generator import DG from dialin.dg.temperature_sensors import TemperatureSensorsNames +from dialin.hd.valves import ValvesEnum from time import sleep if __name__ == "__main__": @@ -58,7 +59,15 @@ ultraFilt = ", RfUF, " + '{:9.2f}'.format(hd.dialysate_outlet_flow.reference_dialysate_outlet_uf_volume) + \ ", MsUF, " + '{:9.2f}'.format(hd.dialysate_outlet_flow.measured_dialysate_outlet_uf_volume) + \ ", Act.Res, " + '{:1d}'.format(dg.reservoirs.active_reservoir) - valves = ", Vlv, " + '{:4X}'.format(dg.valves.valve_states_all) + valves = ", DGVlvs, " + '{:4X}'.format(dg.valves.valve_states_all) + \ + ", VBA, " + hd.valves.valves_status[ValvesEnum.VBA.name]["PosID"] + \ + ", VBV, " + hd.valves.valves_status[ValvesEnum.VBV.name]["PosID"] + \ + ", VDi, " + hd.valves.valves_status[ValvesEnum.VDI.name]["PosID"] + \ + ", VDo, " + hd.valves.valves_status[ValvesEnum.VDO.name]["PosID"] + \ + ", VBT, " + hd.valves.hd_air_trap_status + air = ", ADV, " + '{:1d}'.format(hd.air_bubbles.air_bubbles_status[0]) + \ + ", ULBl, " + '{:1d}'.format(hd.air_trap.lower_level) + \ + ", ULBu, " + '{:1d}'.format(hd.air_trap.upper_level) pumpSetPts = ", BP.s, " + '{:4d}'.format(hd.bloodflow.target_blood_flow_rate) + \ ", DPi.s, " + '{:4d}'.format(hd.dialysate_inlet_flow.target_dialysate_inlet_flow_rate) + \ ", ROP.s, " + '{:9.2f}'.format(dg.ro_pump.target_pressure_psi) + \ @@ -123,6 +132,7 @@ f.write(hdPress) f.write(Temps) f.write(htrs) + f.write(air) f.write("\n") # print to console @@ -137,6 +147,7 @@ print(" HD Pressures: "+hdPress) print(" DG Heaters: "+htrs) print(" Temperatures: "+Temps) + print(" Air: "+air) print(" Accelerometer: "+accels) print(" Alarms: "+alarms)