Index: leahi_dialin/common/msg_ids.py =================================================================== diff -u -radd1665bb756188ddca1b7e26728a6a80598d0da -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision add1665bb756188ddca1b7e26728a6a80598d0da) +++ leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -97,19 +97,14 @@ MSG_ID_DD_PRE_GEN_DIALYSATE_STATE_DATA = 0x4A MSG_ID_DD_POST_GEN_DIALYSATE_STATE_DATA = 0x4B MSG_ID_DD_PRE_GEN_DIALYSATE_REQUEST_DATA = 0x4C - MSG_ID_RO_PRE_GEN_WATER_MODE_DATA = 0x4D MSG_ID_TD_EJECTOR_DATA = 0x4E - MSG_ID_TD_TREATMENT_SET_POINTS = 0x4F - MSG_ID_RO_BOOST_PUMP_DATA = 0x50 - MSG_ID_TD_SERIAL_RESPONSE = 0x51 - MSG_ID_DD_SERIAL_RESPONSE = 0x52 - MSG_ID_TD_TEMPERATURE_DATA = 0x53 - MSG_ID_TD_BATTERY_DATA = 0x54 + MSG_ID_TD_TREATMENT_SET_POINTS_DATA = 0x4F + MSG_ID_DD_SERIAL_RESPONSE = 0x88 + MSG_ID_TD_TEMPERATURE_DATA = 0x91 + MSG_ID_TD_BATTERY_DATA = 0x94 + MSG_ID_TD_SERIAL_RESPONSE = 0x99 - MSG_ID_DD_PISTON_PUMP_CONTROL_DATA = 0xF0 - - - MSG_ID_TD_TESTER_LOGIN_REQUEST = 0x8000 + MSG_ID_TESTER_LOGIN_REQUEST = 0x8000 MSG_ID_TD_SOFTWARE_RESET_REQUEST = 0x8001 MSG_ID_TD_SEND_TEST_CONFIGURATION = 0x8002 MSG_ID_TD_BUBBLE_OVERRIDE_REQUEST = 0x8003 @@ -156,14 +151,8 @@ MSG_ID_TD_TMP_PRESSURE_OVERRIDE_REQUEST = 0x802C MSG_ID_TD_REQ_CURRENT_TREATMENT_PARAMETERS = 0x802D MSG_ID_TD_RSP_CURRENT_TREATMENT_PARAMETERS = 0x802E - MSG_ID_TD_SET_TREATMENT_PARAMETER = 0x802F - MSG_ID_TD_OP_MODE_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0x8030 - MSG_ID_TD_OP_MODE_OVERRIDE_REQUEST = 0x8031 - MSG_ID_TD_EJECTOR_MOTOR_SET_SPEED_REQUEST = 0x8032 - MSG_ID_TD_EJECTOR_COMMAND = 0x8033 - MSG_ID_TD_EJECTOR_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0x8034 - MSG_ID_TD_SET_AIR_TRAP_CONTROL = 0x8035 - MSG_ID_TD_HOME_BLOOD_PUMP_REQUEST = 0x8036 + MSG_ID_TD_OP_MODE_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0x802F + MSG_ID_TD_OP_MODE_OVERRIDE_REQUEST = 0x8030 MSG_ID_DD_TESTER_LOGIN_REQUEST = 0xA000 MSG_ID_DD_SOFTWARE_RESET_REQUEST = 0xA001 @@ -236,7 +225,7 @@ MSG_ID_DD_PISTON_PUMP_START_STOP_OVERRIDE_REQUEST = 0xAF01 MSG_ID_DD_PISTON_PUMP_FILL_AFTER_DISPENSE_OVERRIDE_REQUEST = 0xAF02 - MSG_ID_RO_TESTER_LOGIN_REQUEST = 0xB000 + MSG_ID_FIRST_RO_TESTER_MESSAGE = 0xB000 MSG_ID_RO_SOFTWARE_RESET_REQUEST = 0xB001 MSG_ID_RO_SEND_TEST_CONFIGURATION = 0xB002 MSG_ID_RO_VALVE_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0xB003 @@ -264,10 +253,6 @@ MSG_ID_RO_TEMPERATURE_OVERRIDE_REQUEST = 0xB019 MSG_ID_RO_FILTERED_FLOW_RATE_OVERRIDE_REQUEST = 0xB01A MSG_ID_RO_FILTERED_FLOW_TEMP_OVERRIDE_REQUEST = 0xB01B - MSG_ID_RO_PRE_GEN_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0xB01C - MSG_ID_RO_SET_OP_MODE_REQUEST = 0xB01D - MSG_ID_RO_OPERATION_MODE_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0xB01E - MSG_ID_RO_TEMPERATURE_SENSOR_PUBLISH_INTERVAL_OVERRIDE_REQUEST = 0xB01F MSG_ID_TD_DEBUG_EVENT = 0xFFF1 MSG_ID_DD_DEBUG_EVENT = 0xFFF2 Index: leahi_dialin/dd/dialysate_delivery.py =================================================================== diff -u -r2dab2b0329a56006e07cd36a3883ed099d7a367a -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/dd/dialysate_delivery.py (.../dialysate_delivery.py) (revision 2dab2b0329a56006e07cd36a3883ed099d7a367a) +++ leahi_dialin/dd/dialysate_delivery.py (.../dialysate_delivery.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -23,9 +23,7 @@ from .modules.heaters import DDHeaters from .modules.levels import DDLevels from .modules.piston_pump import DDPistonPumps -from .modules.post_gen_dialysate import DDPostGenDialysate from .modules.pressure_sensors import DDPressureSensors -from .modules.pre_gen_dialysate import DDPreGenDialysate from .modules.temperature_sensors import DDTemperatureSensors from .modules.valves import DDValves @@ -122,9 +120,7 @@ self.heaters = DDHeaters(self.can_interface, self.logger) self.levels = DDLevels(self.can_interface, self.logger) self.piston_pumps = DDPistonPumps(self.can_interface, self.logger) - self.post_gen_dialysate = DDPostGenDialysate(self.can_interface, self.logger) self.pressure_sensors = DDPressureSensors(self.can_interface, self.logger) - self.pre_gen_dialysate = DDPreGenDialysate(self.can_interface, self.logger) self.temperature_sensors = DDTemperatureSensors(self.can_interface, self.logger) self.valves = DDValves(self.can_interface, self.logger) @@ -191,7 +187,7 @@ """ message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, - message_id=MsgIds.MSG_ID_DD_TESTER_LOGIN_REQUEST.value, + message_id=MsgIds.MSG_ID_TESTER_LOGIN_REQUEST.value, payload=list(map(int, map(ord, self.DD_LOGIN_PASSWORD)))) self.logger.debug("Logging in...") Index: leahi_dialin/dd/modules/concentrate_pump.py =================================================================== diff -u -r24490d7f6c02832fd39dcb8d3fc8bd8b8cf853df -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/dd/modules/concentrate_pump.py (.../concentrate_pump.py) (revision 24490d7f6c02832fd39dcb8d3fc8bd8b8cf853df) +++ leahi_dialin/dd/modules/concentrate_pump.py (.../concentrate_pump.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -29,8 +29,8 @@ class ConcentratePumpsEnum(DialinEnum): D11_CP1_ACID = 0 D10_CP2_BICARB = 1 - D76_UF = 2 + @unique class DDConcentratePumpsStates(DialinEnum): CONCENTRATE_PUMP_OFF_STATE = 0 @@ -59,35 +59,24 @@ self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_concentrate_pumps_sync) - - self.d10_current_state = 0 - self.d10_current_set_speed = 0.0 - self.d10_measured_speed = 0.0 - self.d10_target_speed = 0.0 - self.d10_pulse_us = 0.0 - self.d10_target_rev_count = 0 - self.d10_measured_rev_count = 0 - self.d10_parked = False - self.d10_park_fault = False - - self.d11_current_state = 0 - self.d11_current_set_speed = 0.0 - self.d11_measured_speed = 0.0 - self.d11_target_speed = 0.0 - self.d11_pulse_us = 0.0 - self.d11_target_rev_count = 0 - self.d11_measured_rev_count = 0 - self.d11_parked = False - self.d11_park_fault = False - - self.d76_current_state = 0 - self.d76_current_set_speed = 0.0 - self.d76_measured_speed = 0.0 - self.d76_target_speed = 0.0 - self.d76_pulse_us = 0.0 - self.d76_target_rev_count = 0 - self.d76_measured_rev_count = 0 - + self.d11_cp1_current_set_speed = 0.0 + self.d11_cp1_measured_speed = 0.0 + self.d11_cp1_target_speed = 0.0 + self.d10_cp2_current_set_speed = 0.0 + self.d10_cp2_measured_speed = 0.0 + self.d10_cp2_target_speed = 0.0 + self.d11_cp1_current_state = 0 + self.d10_cp2_current_state = 0 + self.d11_cp1_target_rev_count = 0 + self.d10_cp2_target_rev_count = 0 + self.d11_cp1_measured_rev_count = 0 + self.d10_cp2_measured_rev_count = 0 + self.d11_cp1_parked = False + self.d10_cp2_parked = False + self.d11_cp1_park_fault = False + self.d10_cp2_park_fault = False + self.d11_cp1_pulse_us = 0.0 + self.d10_cp2_pulse_us = 0.0 self.dd_concentrate_pump_timestamp = 0.0 @publish(["dd_concentrate_pump_timestamp", @@ -97,11 +86,7 @@ "d11_cp1_target_rev_count", "d10_cp2_target_rev_count", "d11_cp1_measured_rev_count", "d10_cp2_measured_rev_count", "d11_cp1_parked", "d10_cp2_parked", - "d11_cp1_park_fault", "d10_cp2_park_fault", - "d76_current_state","d76_current_set_speed", - "d76_measured_speed","d76_target_speed", - "d76_pulse_us","d76_target_rev_count", - "d76_measured_rev_count"]) + "d11_cp1_park_fault", "d10_cp2_park_fault"]) def _handler_concentrate_pumps_sync(self, message, timestamp=0.0): """ Handles published concentrate pumps' data messages. Concentrate pumps' speed data are captured @@ -111,56 +96,49 @@ @return: None """ - self.d11_current_set_speed = struct.unpack('f', bytearray( + self.d11_cp1_current_set_speed = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] - self.d11_measured_speed = struct.unpack('f', bytearray( + self.d11_cp1_measured_speed = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] - self.d10_current_set_speed = struct.unpack('f', bytearray( + + self.d10_cp2_current_set_speed = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3]))[0] self.d10_cp2_measured_speed = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4]))[0] - self.d11_target_rev_count = struct.unpack('i', bytearray( + + self.d11_cp1_target_rev_count = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5]))[0] - self.d11_measured_rev_count = struct.unpack('i', bytearray( + self.d11_cp1_measured_rev_count = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6]))[0] - self.d10_target_rev_count = struct.unpack('i', bytearray( + self.d10_cp2_target_rev_count = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7]))[0] - self.d10_measured_rev_count = struct.unpack('i', bytearray( + self.d10_cp2_measured_rev_count = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8]))[0] - self.d11_current_state = struct.unpack('i', bytearray( + + self.d11_cp1_current_state = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_9:MsgFieldPositions.END_POS_FIELD_9]))[0] - self.d10_current_state = struct.unpack('i', bytearray( + self.d10_cp2_current_state = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_10:MsgFieldPositions.END_POS_FIELD_10]))[0] - self.d11_pulse_us = struct.unpack('f', bytearray( + + self.d11_cp1_pulse_us = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_11:MsgFieldPositions.END_POS_FIELD_11]))[0] - self.d10_pulse_us = struct.unpack('f', bytearray( + self.d10_cp2_pulse_us = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_12:MsgFieldPositions.END_POS_FIELD_12]))[0] - self.d11_target_speed = struct.unpack('f', bytearray( + + self.d11_cp1_target_speed = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_13:MsgFieldPositions.END_POS_FIELD_13]))[0] - self.d10_target_speed = struct.unpack('f', bytearray( + self.d10_cp2_target_speed = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_14:MsgFieldPositions.END_POS_FIELD_14]))[0] - self.d11_parked = True if struct.unpack('I', bytearray( + + self.d11_cp1_parked = True if struct.unpack('I', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_15:MsgFieldPositions.END_POS_FIELD_15]))[0] == 1 else False - self.d10_parked = True if struct.unpack('I', bytearray( + self.d10_cp2_parked = True if struct.unpack('I', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_16:MsgFieldPositions.END_POS_FIELD_16]))[0] == 1 else False - self.d11_park_fault = True if struct.unpack('I', bytearray( + + self.d11_cp1_park_fault = True if struct.unpack('I', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_17:MsgFieldPositions.END_POS_FIELD_17]))[0] == 1 else False - self.d10_park_fault = True if struct.unpack('I', bytearray( + self.d10_cp2_park_fault = True if struct.unpack('I', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_18:MsgFieldPositions.END_POS_FIELD_18]))[0] == 1 else False - self.d76_target_speed = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_19:MsgFieldPositions.END_POS_FIELD_19]))[0] - self.d76_current_set_speed = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_20:MsgFieldPositions.END_POS_FIELD_20]))[0] - self.d76_measured_speed = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_21:MsgFieldPositions.END_POS_FIELD_21]))[0] - self.d76_target_rev_count = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_22:MsgFieldPositions.END_POS_FIELD_22]))[0] - self.d76_measured_rev_count = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_23:MsgFieldPositions.END_POS_FIELD_23]))[0] - self.d76_current_state = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_24:MsgFieldPositions.END_POS_FIELD_24]))[0] - self.d76_pulse_us = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_25:MsgFieldPositions.END_POS_FIELD_25]))[0] self.dd_concentrate_pump_timestamp = timestamp Index: leahi_dialin/dd/modules/dialysate_pump.py =================================================================== diff -u -r2692cff9c528ec1517638b54b8e6291b0e201c6b -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/dd/modules/dialysate_pump.py (.../dialysate_pump.py) (revision 2692cff9c528ec1517638b54b8e6291b0e201c6b) +++ leahi_dialin/dd/modules/dialysate_pump.py (.../dialysate_pump.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -349,7 +349,7 @@ self.logger.error("Timeout!!!!") return False - def cmd_dialysate_set_start_stop(self, pump_id: int, command: int, speed: int, control: int ) -> int: + def cmd_dialysate_set_start_stop(self, pump_id: int, command: int, speed: int ) -> int: """ Constructs and sends the dialysate pump start stop command @@ -363,8 +363,7 @@ pmp = integer_to_bytearray(pump_id) cmd = integer_to_bytearray(command) rpm = integer_to_bytearray(speed) - ctl = integer_to_bytearray(control) - payload = pmp + cmd + rpm + ctl + payload = pmp + cmd + rpm message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, message_id=MsgIds.MSG_ID_DD_DIALYSATE_PUMPS_START_STOP_OVERRIDE_REQUEST.value, Index: leahi_dialin/dd/modules/gen_dialysate.py =================================================================== diff -u -r4356d86fbeba5afa08ebe258b9ad271f345e1b82 -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/dd/modules/gen_dialysate.py (.../gen_dialysate.py) (revision 4356d86fbeba5afa08ebe258b9ad271f345e1b82) +++ leahi_dialin/dd/modules/gen_dialysate.py (.../gen_dialysate.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -259,34 +259,4 @@ return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: self.logger.error("Timeout!!!!") - return False - - def cmd_stop_gen_mode_override(self, state: int, reset: int = NO_RESET) -> int: - """ - Constructs and sends start pre gen mode override request - - @param state: int - value to override state - @param reset: integer - 1 to reset a previous override, 0 to override - @return: 1 if successful, zero otherwise - - """ - - reset_value = integer_to_bytearray(reset) - interval_value = integer_to_bytearray(state) - payload = reset_value + interval_value - - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, - message_id=MsgIds.MSG_ID_DD_STOP_GEN_DIALYSATE_MODE_OVERRIDE_REQUEST.value, - payload=payload) - - self.logger.debug("Sending {} start pre gen mode override".format(state)) - # Send message - received_message = self.can_interface.send(message) - - # If there is content in message - if received_message is not None: - # Response payload is OK or not - return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] - else: - self.logger.debug("Timeout!!!!") return False \ No newline at end of file Index: leahi_dialin/dd/modules/heaters.py =================================================================== diff -u -r153c499fbd4a9e70ae6d6f8441edeb094ddffd9d -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/dd/modules/heaters.py (.../heaters.py) (revision 153c499fbd4a9e70ae6d6f8441edeb094ddffd9d) +++ leahi_dialin/dd/modules/heaters.py (.../heaters.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -84,7 +84,6 @@ self.dbg6 = 0.0 self.dbg7 = 0.0 self.dbg8 = 0.0 - self.dbg9 = 0.0 if self.can_interface is not None: @@ -137,9 +136,8 @@ message['message'][MsgFieldPositions.START_POS_FIELD_15:MsgFieldPositions.END_POS_FIELD_15]))[0] self.dbg8 = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_16:MsgFieldPositions.END_POS_FIELD_16]))[0] - self.dbg9 = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_17:MsgFieldPositions.END_POS_FIELD_17]))[0] + self.dg_heaters_timestamp = timestamp def cmd_heaters_broadcast_interval_override(self, ms: int, reset: int = NO_RESET) -> int: Fisheye: Tag eb02c56e88faeeda46ed62b1c0ec841dca0b9aba refers to a dead (removed) revision in file `leahi_dialin/dd/modules/post_gen_dialysate.py'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag eb02c56e88faeeda46ed62b1c0ec841dca0b9aba refers to a dead (removed) revision in file `leahi_dialin/dd/modules/pre_gen_dialysate.py'. Fisheye: No comparison available. Pass `N' to diff? Index: leahi_dialin/dd/modules/temperature_sensors.py =================================================================== diff -u -r80e3a4d6a11fc14c975740531b9cf2b825915781 -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/dd/modules/temperature_sensors.py (.../temperature_sensors.py) (revision 80e3a4d6a11fc14c975740531b9cf2b825915781) +++ leahi_dialin/dd/modules/temperature_sensors.py (.../temperature_sensors.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -33,11 +33,10 @@ D50_TEMP = 3 # Trimmer heater temperature sensor BARO_TEMP = 4 # Barometric temperature sensor BRD_TEMP = 5 # DD board temperature sensor ( thermistor ) - D16_TEMP = 6 # D16 temperature value - D28_TEMP = 7 # D28 temperature value - D30_TEMP = 8 # D30 temperature value - D44_TEMP = 9 # D44 temperature value - D75_TEMP = 10 # D75 temperature value + D16_TEMP = 6 # Bicarb only conductivity sensor temp + D28_TEMP = 7 # Acid and Bicarb mix conductivity sensor - 1 temp + D30_TEMP = 8 # Acid and Bicarb mix conductivity sensor - 2 temp + D44_TEMP = 9 # Spent dialysate conductivity sensor temp class DDTemperatureSensors(AbstractSubSystem): @@ -59,8 +58,7 @@ DDTemperaturesNames.D16_TEMP.name: 0.0, DDTemperaturesNames.D28_TEMP.name: 0.0, DDTemperaturesNames.D30_TEMP.name: 0.0, - DDTemperaturesNames.D44_TEMP.name: 0.0, - DDTemperaturesNames.D75_TEMP.name: 0.0} + DDTemperaturesNames.D44_TEMP.name: 0.0,} if self.can_interface is not None: channel_id = DenaliChannels.dd_sync_broadcast_ch_id @@ -88,10 +86,10 @@ self.dd_temperatures[DDTemperaturesNames.D50_TEMP.name] = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4]))[0] - self.dd_temperatures[DDTemperaturesNames.BRD_TEMP.name] = struct.unpack('f', bytearray( + self.dd_temperatures[DDTemperaturesNames.BARO_TEMP.name] = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5]))[0] - self.dd_temperatures[DDTemperaturesNames.BARO_TEMP.name] = struct.unpack('f', bytearray( + self.dd_temperatures[DDTemperaturesNames.BRD_TEMP.name] = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6]))[0] self.dd_temperatures[DDTemperaturesNames.D16_TEMP.name] = struct.unpack('f', bytearray( @@ -106,9 +104,6 @@ self.dd_temperatures[DDTemperaturesNames.D44_TEMP.name] = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_10:MsgFieldPositions.END_POS_FIELD_10]))[0] - self.dd_temperatures[DDTemperaturesNames.D75_TEMP.name] = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_11:MsgFieldPositions.END_POS_FIELD_11]))[0] - self.dd_temperatures_timestamp = timestamp def cmd_temperatures_data_broadcast_interval_override(self, ms: int, reset: int = NO_RESET) -> int: Index: leahi_dialin/dd/proxies/ro_proxy.py =================================================================== diff -u -rad1d08ef189799e3f31dcf4e630c21d9f98c33d7 -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/dd/proxies/ro_proxy.py (.../ro_proxy.py) (revision ad1d08ef189799e3f31dcf4e630c21d9f98c33d7) +++ leahi_dialin/dd/proxies/ro_proxy.py (.../ro_proxy.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -40,7 +40,7 @@ # no current registered call back methods - def cmd_dd_send_ro_start_stop_request(self, cmdID: int = 0, start: bool = 0, ro_rate: float = 0): + def cmd_dd_send_ro_start_stop_request(self, start: bool = 0, ro_rate: float = 0): """ Constructs and sends a DD command response to the RO. @@ -49,10 +49,9 @@ @param: rejection_code: The rejection reason. @return: none """ - cmd = integer_to_bytearray(cmdID) stt = integer_to_bytearray(start) rtt = float_to_bytearray(ro_rate) - payload = cmd + stt + rtt + payload = rtt + stt message = DenaliMessage.build_message(channel_id=DenaliChannels.dd_to_ro_ch_id, message_id=MsgIds.MSG_ID_DD_RO_START_STOP_CMD_REQUEST.value, payload=payload) Index: leahi_dialin/dd/proxies/td_proxy.py =================================================================== diff -u -r2dab2b0329a56006e07cd36a3883ed099d7a367a -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/dd/proxies/td_proxy.py (.../td_proxy.py) (revision 2dab2b0329a56006e07cd36a3883ed099d7a367a) +++ leahi_dialin/dd/proxies/td_proxy.py (.../td_proxy.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -98,35 +98,11 @@ byp = integer_to_bytearray(bypass) acd = integer_to_bytearray(acid) bic = integer_to_bytearray(bicarb) + #payload = bic +acd + byp + temp + uf + dial + stt payload = stt + dial + uf + temp + byp + acd + bic - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, + message = DenaliMessage.build_message(channel_id=DenaliChannels.td_to_dd_ch_id, message_id=MsgIds.MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA.value, payload=payload) self.logger.debug("Sending TD gen dialysate data request to DD.") - self.can_interface.send(message, 0) - - 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 ): - """ - Constructs and sends a TD start pre gen dialysate request to the DD. - :param start: start and stop boolean - :param dialysate_rate: dialysate rate in ml/min - :param dialysate_temp: dialysate temp in c - :param acid_type: acid type - :param bicarb_type: bicarb type - :return: - """ - 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 - - 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) - - self.logger.debug("Sending TD start pre gen request to DD.") self.can_interface.send(message, 0) \ No newline at end of file Index: leahi_dialin/fp/filtration_purification.py =================================================================== diff -u -rf5ff90469cd1520361a823923ad0b58ab4a23a45 -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/fp/filtration_purification.py (.../filtration_purification.py) (revision f5ff90469cd1520361a823923ad0b58ab4a23a45) +++ leahi_dialin/fp/filtration_purification.py (.../filtration_purification.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -16,17 +16,16 @@ import struct from .modules.conductivity_sensors import FPConductivitySensors -from .modules.constants import NO_RESET, RESET from .modules.flow_sensors import FPFlowSensors +from .modules.boost_pump import FPPumps +from .modules.flow_sensors import FPFlowSensors from .modules.levels import FPLevels from .modules.pressure_sensors import FPPressureSensors from .modules.temperatures import FPTemperatureSensors from .modules.valves import FPValves -from .modules.water_pumps import FPPumps from ..common.msg_defs import MsgIds, MsgFieldPositions -from ..common.fp_defs import FPOpModes from ..protocols.CAN import DenaliMessage, DenaliCanMessenger, DenaliChannels from ..utils.base import AbstractSubSystem, publish, LogManager from ..utils.checks import check_broadcast_interval_override_ms @@ -96,7 +95,7 @@ self.fp_op_mode_timestamp = 0.0 self.fp_debug_events_timestamp = 0.0 self.ui_version_info_response_timestamp = 0.0 - self.fp_operation_mode = FPOpModes.MODE_INIT.value + self.fp_operation_sub_mode = 0 self.fp_logged_in = False self.fp_set_logged_in_status(False) @@ -179,7 +178,7 @@ """ message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_fp_ch_id, - message_id=MsgIds.MSG_ID_RO_TESTER_LOGIN_REQUEST.value, + message_id=MsgIds.MSG_ID_FIRST_RO_TESTER_MESSAGE.value, payload=list(map(int, map(ord, self.FP_LOGIN_PASSWORD)))) self.logger.debug("Logging in...") @@ -255,47 +254,4 @@ self.logger.debug("Sent request to FP to reset...") self.fp_set_logged_in_status(False) - def cmd_op_mode_broadcast_interval_override(self, ms: int, reset: int = NO_RESET) -> int: - """ - Constructs and sends the measured op mode broadcast interval override command - Constraints: - Must be logged into FP. - Given interval must be non-zero and a multiple of the FP general task interval (50 ms). - @param ms: integer - interval (in ms) to override with - @param reset: integer - 1 to reset a previous override, 0 to override - @return: 1 if successful, zero otherwise - """ - - if not check_broadcast_interval_override_ms(ms): - return False - - rst = integer_to_bytearray(reset) - mis = integer_to_bytearray(ms) - payload = rst + mis - - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_fp_ch_id, - message_id=MsgIds.MSG_ID_RO_OPERATION_MODE_PUBLISH_INTERVAL_OVERRIDE_REQUEST.value, - payload=payload) - - self.logger.debug("override op mode broadcast interval") - - # Send message - received_message = self.can_interface.send(message) - - # If there is content... - if received_message is not None: - # self.logger.debug(received_message) - if reset == RESET: - str_res = "reset back to normal: " - else: - str_res = str(ms) + " ms: " - self.logger.debug("operation mode broadcast interval overridden to " + str_res + - str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) - # response payload is OK or not OK - return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] - else: - self.logger.debug("Timeout!!!!") - return False - - Index: leahi_dialin/fp/modules/boost_pump.py =================================================================== diff -u --- leahi_dialin/fp/modules/boost_pump.py (revision 0) +++ leahi_dialin/fp/modules/boost_pump.py (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -0,0 +1,256 @@ +########################################################################### +# +# Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. +# +# 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 boost_pump.py +# +# @author (last) Micahel Garthwaite +# @date (last) 17-Aug-2023 +# @author (original) Peter Lucia +# @date (original) 02-Apr-2020 +# +############################################################################ +import struct +from enum import unique +from logging import Logger + +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, 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 FPPumpNames(DialinEnum): + P12_PUMP_RO = 0 + P40_PUMP_BOOSTER = 1 + + +class FPPumps(AbstractSubSystem): + """ + Dialin API sub-class for RO pump related commands. + """ + + def __init__(self, can_interface, logger: Logger): + """ + FPPumps constructor + """ + super().__init__() + self.can_interface = can_interface + self.logger = logger + + if self.can_interface is not None: + channel_id = DenaliChannels.fp_sync_broadcast_ch_id + msg_id = MsgIds.MSG_ID_RO_PUMP_DATA.value + self.can_interface.register_receiving_publication_function(channel_id, msg_id, + self._handler_boost_pump_sync) + self.ro_pump_timestamp = 0.0 + self.p12_ro_pump_state = 0 + self.p12_ro_pump_duty_cycle = 0.0 + self.p12_ro_pump_fb_duty_cycle = 0.0 + self.p12_ro_pump_speed = 0.0 + self.p40_boost_pump_state = 0 + self.p40_boost_pump_duty_cycle = 0.0 + self.p40_boost_pump_fb_duty_cycle = 0.0 + self.p40_boost_pump_speed = 0.0 + + + @publish(["ro_pump_timestamp", "p12_ro_pump_state", "p12_ro_pump_duty_cycle", "p12_ro_pump_fb_duty_cycle", + "p12_ro_pump_speed", "p40_boost_pump_state", "p40_boost_pump_duty_cycle", + "p40_boost_pump_fb_duty_cycle", "p40_boost_pump_speed"]) + def _handler_boost_pump_sync(self, message, timestamp=0.0): + """ + Handles published RO pump data messages. RO pump data is captured + for reference. + + @param message: published RO pump data message + @return: none + """ + + rps = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1])) + rpdc = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2])) + rpfbdc = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3])) + rprpm = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4])) + bps = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5])) + bpdc = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6])) + bpfbdc = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7])) + bprpm = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8])) + + self.ro_pump_timestamp = timestamp + self.p12_ro_pump_state = rps[0] + self.p12_ro_pump_duty_cycle = rpdc[0] + self.p12_ro_pump_fb_duty_cycle = rpfbdc[0] + self.p12_ro_pump_speed = rprpm[0] + self.p40_boost_pump_state = bps[0] + self.p40_boost_pump_duty_cycle = bpdc[0] + self.p40_boost_pump_fb_duty_cycle = bpfbdc[0] + self.p40_boost_pump_speed = bprpm[0] + + + + def cmd_boost_pump_set_speed_rate_override(self, pump: int, rpm: int, reset: int = NO_RESET) -> int: + """ + Constructs and sends the boost pump set point command + Constraints: + Must be logged into FP. + + @param rpm: integer - speed set point (in rpm) + @return: 1 if successful, zero otherwise + """ + rst = integer_to_bytearray(reset) + rpm = integer_to_bytearray(rpm) + pmp = integer_to_bytearray(pump) + payload = rst + rpm + pmp + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_fp_ch_id, + message_id=MsgIds.MSG_ID_RO_BOOST_PUMP_SPEED_OVERRIDE_REQUEST.value, + payload=payload) + + self.logger.debug("override blood flow set point") + + # Send message + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + if reset == RESET: + str_res = "reset back to normal" + else: + str_res = str(rpm) + + self.logger.debug("rpm overridden to " + str_res) + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("Timeout!!!!") + return False + + def cmd_boost_pump_set_pwm_request(self, pump: int, pwm: int) -> int: + """ + Constructs and sends set pwm request for RO pumps \n + command. + Constraints: + Must be logged into FP. + + @param pwm: integer - counts to override the pwm ( 0 - 500 ) + @param reset: integer - 1 to reset a previous override, 0 to override + @return: 1 if successful, zero otherwise + """ + + spd = integer_to_bytearray(pwm) + pmp = integer_to_bytearray(pump) + payload = pmp + spd + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_fp_ch_id, + message_id=MsgIds.MSG_ID_RO_BOOST_PUMP_SET_PWM_REQUEST.value, + payload=payload) + + self.logger.debug("setting pump {} to pwm count {}".format(pump,pwm)) + + # Send message + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + + self.logger.debug("pwm set to " + str(pwm)) + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("Timeout!!!!") + return False + + def cmd_boost_pump_read_pwm_override(self, pump: int, pwm: float, reset: int = NO_RESET) -> int: + """ + Constructs and sends the read pwm override for the RO pumps \n + command. + Constraints: + Must be logged into FP. + + @param pwm: float - pwm in percentage to override with + @param reset: integer - 1 to reset a previous override, 0 to override + @return: 1 if successful, zero otherwise + """ + + rst = integer_to_bytearray(reset) + rpwm = float_to_bytearray(pwm) + pmp = integer_to_bytearray(pump) + payload = rst + rpwm + pmp + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_fp_ch_id, + message_id=MsgIds.MSG_ID_RO_BOOST_PUMP_READ_PWM_OVERRIDE_REQUEST.value, + payload=payload) + + self.logger.debug("override read pwm for pump".format(pump)) + + # Send message + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + if reset == RESET: + str_res = "reset back to normal" + else: + str_res = str(rpwm) + + self.logger.debug("pwm overridden to " + str_res) + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("Timeout!!!!") + return False + + def cmd_boost_pump_broadcast_interval_override(self, ms: int, reset: int = NO_RESET) -> int: + """ + Constructs and sends the RO pump broadcast interval override command + Constraints: + Must be logged into FP. + Given interval must be non-zero and a multiple of the FP general task interval (50 ms). + + @param ms: integer - interval (in ms) to override with + @param reset: integer - 1 to reset a previous override, 0 to override + @return: 1 if successful, zero otherwise + """ + + if not check_broadcast_interval_override_ms(ms): + return False + + rst = integer_to_bytearray(reset) + mis = integer_to_bytearray(ms) + payload = rst + mis + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_fp_ch_id, + message_id=MsgIds.MSG_ID_RO_BOOST_PUMPS_PUBLISH_INTERVAL_OVERRIDE_REQUEST.value, + payload=payload) + + self.logger.debug("override FP pump broadcast interval") + + # Send message + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + # self.logger.debug(received_message) + if reset == RESET: + str_res = "reset back to normal" + else: + str_res = str(mis) + + self.logger.debug("broadcast overridden to " + str_res) + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("Timeout!!!!") + return False \ No newline at end of file Index: leahi_dialin/fp/modules/flow_sensors.py =================================================================== diff -u -rad1d08ef189799e3f31dcf4e630c21d9f98c33d7 -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/fp/modules/flow_sensors.py (.../flow_sensors.py) (revision ad1d08ef189799e3f31dcf4e630c21d9f98c33d7) +++ leahi_dialin/fp/modules/flow_sensors.py (.../flow_sensors.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -80,7 +80,7 @@ self.p16_temp = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4]))[0] - self.fp_flow_timestamp = timestamp + self.fp_flows_timestamp = timestamp def cmd_flow_sensor_broadcast_interval_override(self, ms: int, reset: int = NO_RESET) -> int: """ Index: leahi_dialin/fp/modules/levels.py =================================================================== diff -u -r72c423da1d07c40699f40b5da5bee6d992d3082c -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/fp/modules/levels.py (.../levels.py) (revision 72c423da1d07c40699f40b5da5bee6d992d3082c) +++ leahi_dialin/fp/modules/levels.py (.../levels.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -91,7 +91,7 @@ payload = reset_value + interval_value message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_fp_ch_id, - message_id=MsgIds.MSG_ID_RO_LEVEL_PUBLISH_INTERVAL_OVERRIDE_REQUEST.value, + message_id=MsgIds.MSG_ID_RO_LEVELS_PUBLISH_INTERVAL_OVERRIDE_REQUEST.value, payload=payload) self.logger.debug("Sending {} ms publish interval to the FP Levels module".format(ms)) @@ -106,20 +106,21 @@ self.logger.debug("Timeout!!!!") return False - def cmd_level_status_override(self, status: int, reset: int = NO_RESET) -> int: + def cmd_level_status_override(self, level_sensor: int, status: int, reset: int = NO_RESET) -> int: """ Constructs and sends level status override command. Must be logged into FP. + @param level_sensor: integer - the level sensor to override its value @param status: integer - the status value to override @param reset: (int) 1 to reset a previous override, 0 to override @returns 1 if successful, zero otherwise """ reset_value = integer_to_bytearray(reset) - sts = integer_to_bytearray(status) - payload = reset_value + sts + lvl = integer_to_bytearray(level) + payload = reset_value + lvl message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_fp_ch_id, - message_id=MsgIds.MSG_ID_RO_LEVEL_OVERRIDE_REQUEST.value, + message_id=MsgIds.MSG_ID_RO_LEVELS_STATUS_OVERRIDE_REQUEST.value, payload=payload) # Send message Index: leahi_dialin/fp/modules/pressure_sensors.py =================================================================== diff -u -r80f84ad5638667894e9df2161b9c5d9b8f27ed9b -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/fp/modules/pressure_sensors.py (.../pressure_sensors.py) (revision 80f84ad5638667894e9df2161b9c5d9b8f27ed9b) +++ leahi_dialin/fp/modules/pressure_sensors.py (.../pressure_sensors.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -33,10 +33,6 @@ P13_PRES = 3 P17_PRES = 4 X1_PRES = 5 - X2_PRES = 6 - X3_PRES = 7 - X4_PRES = 8 - X5_PRES = 9 class FPPressureSensors(AbstractSubSystem): @@ -66,26 +62,28 @@ self.p13_pres = 0.0 self.p17_pres = 0.0 self.x1_pres = 0.0 - self.x2_pres = 0.0 - self.x3_pres = 0.0 - self.x4_pres = 0.0 - self.x5_pres = 0.0 self.m1_pres_temp = 0.0 self.m3_pres_temp = 0.0 self.p8_pres_temp = 0.0 self.p13_pres_temp = 0.0 self.p17_pres_temp = 0.0 self.x1_pres_temp = 0.0 - self.x2_pres_temp = 0.0 - self.x3_pres_temp = 0.0 - self.x4_pres_temp = 0.0 - self.x5_pres_temp = 0.0 + @publish([ - "fp_pressure_timestamp", "m1_pres", "m3_pres", "p8_pres", "p13_pres", "p17_pres", - "x1_pres", "x2_pres", "x3_pres", "x4_pres", "x5_pres", - "m1_pres_temp", "m3_pres_temp", "p8_pres_temp", "p13_pres_temp", "p17_pres_temp", - "x1_pres_temp", "x2_pres_temp", "x3_pres_temp", "x4_pres_temp", "x5_pres_temp", + "fp_pressure_timestamp", + "m1_pres", + "m3_pres", + "p8_pres", + "p13_pres", + "p17_pres", + "x1_pres", + "m1_pres_temp", + "m3_pres_temp", + "p8_pres_temp", + "p13_pres_temp", + "p17_pres_temp", + "x1_pres_temp" ]) def _handler_pressure_sync(self, message, timestamp=0.0): """ @@ -96,48 +94,46 @@ @return: none """ - self.m1_pres = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] - self.m3_pres = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] - self.p8_pres = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3]))[0] - self.p13_pres = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4]))[0] - self.p17_pres = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5]))[0] - self.x1_pres = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6]))[0] - self.x2_pres = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7]))[0] - self.x3_pres = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8]))[0] - self.x4_pres = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_9:MsgFieldPositions.END_POS_FIELD_9]))[0] - self.x5_pres = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_10:MsgFieldPositions.END_POS_FIELD_10]))[0] + pre_reg_wi = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1])) + post_reg_wi = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2])) + pre_cond_wi = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3])) + pre_ro = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4])) + post_ro = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5])) + pre_pump = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6])) - self.m1_pres_temp = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_11:MsgFieldPositions.END_POS_FIELD_11]))[0] - self.m3_pres_temp = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_12:MsgFieldPositions.END_POS_FIELD_12]))[0] - self.p8_pres_temp = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_13:MsgFieldPositions.END_POS_FIELD_13]))[0] - self.p13_pres_temp = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_14:MsgFieldPositions.END_POS_FIELD_14]))[0] - self.p17_pres_temp = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_15:MsgFieldPositions.END_POS_FIELD_15]))[0] - self.x1_pres_temp = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_16:MsgFieldPositions.END_POS_FIELD_16]))[0] - self.x2_pres_temp = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_17:MsgFieldPositions.END_POS_FIELD_17]))[0] - self.x3_pres_temp = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_18:MsgFieldPositions.END_POS_FIELD_18]))[0] - self.x4_pres_temp = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_19:MsgFieldPositions.END_POS_FIELD_19]))[0] - self.x5_pres_temp = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_20:MsgFieldPositions.END_POS_FIELD_20]))[0] + pre_reg_wi_temp = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7])) + post_reg_wi_temp = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8])) + pre_cond_wi_temp = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_9:MsgFieldPositions.END_POS_FIELD_9])) + pre_ro_temp = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_10:MsgFieldPositions.END_POS_FIELD_10])) + post_ro_temp = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_11:MsgFieldPositions.END_POS_FIELD_11])) + pre_pump_temp = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_12:MsgFieldPositions.END_POS_FIELD_12])) + self.m1_pres = pre_reg_wi[0] + self.m3_pres = post_reg_wi[0] + self.p8_pres = pre_cond_wi[0] + self.p13_pres = pre_ro[0] + self.p17_pres = post_ro[0] + self.x1_pres = pre_pump[0] + + self.m1_pres_temp = pre_reg_wi_temp[0] + self.m3_pres_temp = post_reg_wi_temp[0] + self.p8_pres_temp = pre_cond_wi_temp[0] + self.p13_pres_temp = pre_ro_temp[0] + self.p17_pres_temp = post_ro_temp[0] + self.x1_pres_temp = pre_pump_temp[0] + self.fp_pressure_timestamp = timestamp def cmd_pressure_sensor_override(self, sensor: int, pressure: float, reset: int = NO_RESET) -> int: Index: leahi_dialin/fp/modules/temperatures.py =================================================================== diff -u -rad1d08ef189799e3f31dcf4e630c21d9f98c33d7 -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/fp/modules/temperatures.py (.../temperatures.py) (revision ad1d08ef189799e3f31dcf4e630c21d9f98c33d7) +++ leahi_dialin/fp/modules/temperatures.py (.../temperatures.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -42,12 +42,12 @@ if self.can_interface is not None: - channel_id = DenaliChannels.fp_sync_broadcast_ch_id + channel_id = DenaliChannels.dd_sync_broadcast_ch_id msg_id = MsgIds.MSG_ID_RO_TEMPERATURE_DATA.value self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_temperature_sensors_sync) - self.fp_temperature_sensors_timestamp = 0 + self.fp_temperature_sensors_timestamp = 0.0 self.fp_temperatures = {FPTemperaturesNames.P23_TEMP.name: 0.0, FPTemperaturesNames.P22_TEMP.name: 0.0, FPTemperaturesNames.P10_TEMP.name: 0.0, @@ -77,9 +77,7 @@ self.fp_temperatures[FPTemperaturesNames.FP_BOARD_TEMP.name] = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5]))[0] - self.fp_temperature_sensors_timestamp = timestamp - def cmd_temperatures_data_broadcast_interval_override(self, ms: int, reset: int = NO_RESET) -> int: """ Constructs and sends broadcast time interval. Fisheye: Tag eb02c56e88faeeda46ed62b1c0ec841dca0b9aba refers to a dead (removed) revision in file `leahi_dialin/fp/modules/water_pumps.py'. Fisheye: No comparison available. Pass `N' to diff? Index: leahi_dialin/td/modules/air_pump.py =================================================================== diff -u -r7f463d8649e41b995e1a94cc001ffc50541cafb7 -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/td/modules/air_pump.py (.../air_pump.py) (revision 7f463d8649e41b995e1a94cc001ffc50541cafb7) +++ leahi_dialin/td/modules/air_pump.py (.../air_pump.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -71,21 +71,28 @@ def cmd_air_pump_set_state(self, state: int, power: int) -> int: """ Constructs and sends the air pump set state command. + AIR_PUMP_STATE_INIT = 0, ///< Air Pump Initialize state + AIR_PUMP_STATE_OFF, ///< Air Pump Off state + AIR_PUMP_STATE_ON, ///< Air Pump On state + NUM_OF_AIR_PUMP_STATES, ///< Number of air pump states Constraints: Must be logged into TD. + @param state: integer - state value to set the air pump @param power: integer - 0-255 value to set the air pump power @return: 1 if successful, zero otherwise """ - sts = integer_to_bytearray(state) + idx = integer_to_bytearray(state) pwr = integer_to_bytearray(power) - payload = sts + pwr + payload = idx + pwr message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_td_ch_id, message_id=MsgIds.MSG_ID_TD_AIR_PUMP_SET_STATE_REQUEST.value, payload=payload) + self.logger.debug("setting air pump state to" + str(state)) + # Send message received_message = self.can_interface.send(message) Index: leahi_dialin/td/modules/air_trap.py =================================================================== diff -u -rdf2b51a17a2ccdaf3587f631de7623fa7fcae624 -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/td/modules/air_trap.py (.../air_trap.py) (revision df2b51a17a2ccdaf3587f631de7623fa7fcae624) +++ leahi_dialin/td/modules/air_trap.py (.../air_trap.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -234,7 +234,7 @@ vlv = integer_to_bytearray(valve) sts = integer_to_bytearray(valve_state) - payload = vlv + sts + payload = sts + vlv message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_td_ch_id, message_id=MsgIds.MSG_ID_TD_2_WAY_VALVE_SET_STATE_REQUEST.value, @@ -245,34 +245,7 @@ # If there is content... if received_message is not None: # response payload is OK or not OK - self.logger.debug("Air trap valve " + str(valve) + " set to " + str(valve_state)) return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: self.logger.debug("timeout!!") return False - - def cmd_set_td_air_trap_control(self, control: int = 0) -> int: - """ - Constructs and sends a set control command to the TD air trap. - - @param control: start/stop for air trap control (0=stop, 1=start) - @returns 1 if successful, zero otherwise - """ - - ctl = integer_to_bytearray(control) - payload = ctl - - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_td_ch_id, - message_id=MsgIds.MSG_ID_TD_SET_AIR_TRAP_CONTROL.value, - payload=payload) - # 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 - self.logger.debug("Air trap control set to " + str(control)) - return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] - else: - self.logger.debug("timeout!!") - return False \ No newline at end of file Index: leahi_dialin/td/modules/blood_flow.py =================================================================== diff -u -rdf2b51a17a2ccdaf3587f631de7623fa7fcae624 -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/td/modules/blood_flow.py (.../blood_flow.py) (revision df2b51a17a2ccdaf3587f631de7623fa7fcae624) +++ leahi_dialin/td/modules/blood_flow.py (.../blood_flow.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -55,7 +55,7 @@ self.h4_rotor_hall_state = 0 - @publish(["td_blood_flow_timestamp", "h4_set_blood_flow_rate", "h4_measured_blood_flow_rate", "h4_measured_blood_pump_rotor_speed", + @publish(["td_blood_flow_timestamp", "set_blood_flow_rate", "h4_measured_blood_flow_rate", "h4_measured_blood_pump_rotor_speed", "h4_measured_blood_pump_speed", "h4_measured_blood_pump_motor_current", "h4_set_rpm", "h4_rotor_count", "h4_pres_blood_flow_rate", "h4_rotor_hall_state"]) def _handler_blood_flow_sync(self, message, timestamp=0.0): @@ -67,25 +67,34 @@ @return: none """ - self.h4_set_blood_flow_rate = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] - self.h4_measured_blood_flow_rate = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] - self.h4_measured_blood_pump_rotor_speed = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3]))[0] - self.h4_measured_blood_pump_speed = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4]))[0] - self.h4_measured_blood_pump_motor_current = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5]))[0] - self.h4_set_rpm = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6]))[0] - self.h4_rotor_count = struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7]))[0] - self.h4_pres_blood_flow_rate = struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8]))[0] - self.h4_rotor_hall_state = struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_9:MsgFieldPositions.END_POS_FIELD_9]))[0] + tgt = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1])) + flow = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2])) + rotor = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3])) + speed = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4])) + mccurr = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5])) + rpm = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6])) + rot = struct.unpack('I', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7])) + pres = struct.unpack('I', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8])) + hal = struct.unpack('I', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_9:MsgFieldPositions.END_POS_FIELD_9])) + self.h4_set_blood_flow_rate = tgt[0] + self.h4_measured_blood_flow_rate = flow[0] + self.h4_measured_blood_pump_rotor_speed = rotor[0] + self.h4_measured_blood_pump_speed = speed[0] + self.h4_measured_blood_pump_motor_current = mccurr[0] + self.h4_set_rpm = rpm[0] + self.h4_rotor_count = rot[0] + self.h4_pres_blood_flow_rate = pres[0] + self.h4_rotor_hall_state = hal[0] self.td_blood_flow_timestamp = timestamp def cmd_blood_flow_set_flow_rate_request(self, flow: int, mode: int = PUMP_CONTROL_MODE_CLOSED_LOOP) -> int: @@ -357,28 +366,3 @@ else: self.logger.debug("Timeout!!!!") return False - - def cmd_home_blood_pump(self) -> int: - """ - Constructs and sends home blood pump command. - Constraints: - Must be logged into TD. - - @return: 1 if successful, zero otherwise - """ - - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_td_ch_id, - message_id=MsgIds.MSG_ID_TD_HOME_BLOOD_PUMP_REQUEST.value) - - self.logger.debug("homing blood pump") - - # 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 True - else: - self.logger.debug("Timeout!!!!") - return False Index: leahi_dialin/td/modules/bubble_detector.py =================================================================== diff -u -rbcee4d024cee5855b3662785cad1c6834c5dc858 -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/td/modules/bubble_detector.py (.../bubble_detector.py) (revision bcee4d024cee5855b3662785cad1c6834c5dc858) +++ leahi_dialin/td/modules/bubble_detector.py (.../bubble_detector.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -68,20 +68,23 @@ @publish(["td_air_bubbles_timestamp", "h18_air_bubbles_status", "h18_air_bubbles_state"]) def _handler_air_bubbles_data_sync(self, message, timestamp=0.0): """ - Handles published air bubbles data messages. Air bubble status and state are captured. + Handles published air bubbles data messages. Air bubble status and state are captured + for ADV detector. - @param message: published air bubbles data message as: h18 bubble status, h18 bubble state + @param message: published air bubbles data message as: ADV status, ADV state @return: None """ - self.h18_air_bubbles_status = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] - self.h18_air_bubbles_state = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] + adv_status = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1])) + adv_state = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2])) + self.h18_air_bubbles_status = [adv_status[0]] + self.h18_air_bubbles_state = [adv_state[0]] self.td_air_bubbles_timestamp = timestamp - def cmd_air_bubble_status_override(self, index: int, status: int, reset: int = NO_RESET) -> int: + def cmd_air_bubble_status_override(self, status: int, index: int, reset: int = NO_RESET) -> int: """ Constructs and sends the air bubble detector status override command Constraints: @@ -103,6 +106,9 @@ message_id=MsgIds.MSG_ID_TD_BUBBLE_OVERRIDE_REQUEST.value, payload=payload) + if index == self.ADV: + self.logger.debug("Override air bubble detector ADV status value") + # Send message received_message = self.can_interface.send(message) Fisheye: Tag eb02c56e88faeeda46ed62b1c0ec841dca0b9aba refers to a dead (removed) revision in file `leahi_dialin/td/modules/ejector.py'. Fisheye: No comparison available. Pass `N' to diff? Index: leahi_dialin/td/modules/pressure_sensors.py =================================================================== diff -u -rb0d9d887e826ed5f1acd355f0c568822412bf1bb -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/td/modules/pressure_sensors.py (.../pressure_sensors.py) (revision b0d9d887e826ed5f1acd355f0c568822412bf1bb) +++ leahi_dialin/td/modules/pressure_sensors.py (.../pressure_sensors.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -109,7 +109,8 @@ def cmd_pressure_sensor_override(self, pressure: float, sensor: int, reset: int = NO_RESET) -> int: """ Constructs and sends the measured arterial pressure override command - . + PRESSURE_SENSOR_ARTERIAL = 0 ///< Arterial blood line pressure sensor + PRESSURE_SENSOR_VENOUS = 1 ///< Vensous blood line pressure sensor Constraints: Must be logged into TD. @@ -124,7 +125,7 @@ prs = float_to_bytearray(pressure) payload = rst + prs + sen - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_td_ch_id, + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_TD_ch_id, message_id=MsgIds.MSG_ID_TD_PRESSURE_OVERRIDE_REQUEST.value, payload=payload) Index: leahi_dialin/td/modules/switches.py =================================================================== diff -u -r7f463d8649e41b995e1a94cc001ffc50541cafb7 -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/td/modules/switches.py (.../switches.py) (revision 7f463d8649e41b995e1a94cc001ffc50541cafb7) +++ leahi_dialin/td/modules/switches.py (.../switches.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -75,7 +75,6 @@ message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] self.td_switches_status[TDSwitchesNames.H9_FRONT_DOOR.name] = TDSwitchStatus(front_door).value - self.td_switches_timestamp = timestamp def cmd_switch_status_override(self, switch: int, status: int, reset: int = NO_RESET) -> int: """ Index: leahi_dialin/td/modules/treatment.py =================================================================== diff -u -r0ca34ba27790b8aeb6c368190cc770ca3f345184 -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/td/modules/treatment.py (.../treatment.py) (revision 0ca34ba27790b8aeb6c368190cc770ca3f345184) +++ leahi_dialin/td/modules/treatment.py (.../treatment.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -15,40 +15,15 @@ ############################################################################ import struct from logging import Logger -from enum import unique 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, DialinEnum +from leahi_dialin.utils.base import AbstractSubSystem, publish 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 TDTreatmentParameters(DialinEnum): - TREATMENT_PARAM_BLOOD_FLOW = 0 # Blood flow rate (in mL/min) - TREATMENT_PARAM_DIALYSATE_FLOW = 1 # Dialysate flow rate (in mL/min) - TREATMENT_PARAM_TREATMENT_DURATION = 2 # Treatment duration (in minutes) - TREATMENT_PARAM_SALINE_BOLUS_VOLUME = 3 # Saline bolus volume (in mL) - TREATMENT_PARAM_HEPARIN_STOP_TIME = 4 # Heparin stop time (in minutes) - TREATMENT_PARAM_HEPARIN_TYPE = 5 # Heparin type (enum) - TREATMENT_PARAM_ACID_CONCENTRATE = 6 # Acid concentrate type (enum) - TREATMENT_PARAM_BICARB_CONCENTRATE = 7 # Bicarbonate concentrate type (enum) - TREATMENT_PARAM_DIALYZER_TYPE = 8 # Dialysate type (enum) - TREATMENT_PARAM_BP_MEAS_INTERVAL = 9 # Blood pressure measurement interval (in minutes) - TREATMENT_PARAM_RINSEBACK_FLOW_RATE = 10 # Rinseback flow rate (in mL/min) - TREATMENT_PARAM_RINSEBACK_VOLUME = 11 # Rinseback volume (in mL) - TREATMENT_PARAM_ART_PRES_LIMIT_WINDOW = 12 # Arterial pressure alarm limit window (in mmHg) - TREATMENT_PARAM_VEN_PRES_LIMIT_WINDOW = 13 # Venous pressure alarm limit window (in mmHg) - TREATMENT_PARAM_VEN_PRES_LIMIT_ASYMMETRIC = 14 # Venous pressure alarm limit asymmetric (in mmHg) - TREATMENT_PARAM_TMP_PRES_LIMIT_WINDOW = 15 # TMP alarm limit window (in mmHg) - TREATMENT_PARAM_DIALYSATE_TEMPERATURE = 16 # Dialysate temperature (in degC) - TREATMENT_PARAM_HEPARIN_DISPENSE_RATE = 17 # Heparin dispense rate (in mL/hr) - TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME = 18 # Heparin bolus volume (in mL) - TREATMENT_PARAM_UF_VOLUME = 19 # Ultrafiltration volume (in liters) - provided separately by UI - NUM_OF_TREATMENT_PARAMS = 20 # Total number of treatment parameters - class TDTreatment(AbstractSubSystem): """ Treatment Delivery (TD) Dialin API sub-class for treatment related commands. @@ -80,9 +55,6 @@ msg_id = MsgIds.MSG_ID_TD_TREATMENT_STATE_DATA.value self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_treatment_state_sync) - msg_id = MsgIds.MSG_ID_TD_RSP_CURRENT_TREATMENT_PARAMETERS.value - self.can_interface.register_receiving_publication_function(channel_id, msg_id, - self._handler_resp_treatment_parameters_sync) # Treatment param ranges data self.min_tx_time = 0 @@ -124,29 +96,6 @@ self.tx_end_state = 0 self.tx_state_timestamp = 0 - # Treatment Parameters Data. Most recent response. - self.blood_flow_rate = 0 - self.dialysate_flow_rate = 0 - self.tx_duration = 0 - self.saline_bolus_volume = 0 - self.hep_stop_time = 0 - self.hep_time = 0 - self.acid_con = 0 - self.bicarb_con = 0 - self.dialyzer_type = 0 - self.bp_interval = 0 - self.rb_flow_rate = 0 - self.rb_volume = 0 - self.art_pressure_window = 0 - self.venous_pressure_window = 0 - self.venous_asymm_window = 0 - self.tmp_limit_window = 0 - self.dialysate_temp = 0.0 - self.hep_dispense_rate = 0.0 - self.hep_bolus_vol = 0.0 - self.uf_vol = 0.0 - self.tx_param_req_timestamp = 0 - @publish(["min_tx_time","max_tx_time","min_uf_volume","max_uf_volume", "min_dial_rate","max_dial_rate","tx_params_timestamp"]) def _handler_treatment_param_ranges_sync(self, message, timestamp=0.0): @@ -261,98 +210,3 @@ message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8]))[0] self.tx_state_timestamp = timestamp - - @publish(["blood_flow_rate", "dialysate_flow_rate", "tx_duration", "saline_bolus_volume", - "hep_stop_time", "hep_time", "acid_con", "bicarb_con", - "dialyzer_type", "bp_interval", "rb_flow_rate", "rb_volume", - "art_pressure_window","venous_pressure_window","venous_asymm_window","tmp_limit_window", - "dialysate_temp", "hep_dispense_rate", "hep_bolus_vol", "uf_vol"]) - def _handler_resp_treatment_parameters_sync(self, message, timestamp=0.0): - """ - Handles published treatment parameter response data messages. - - @param message: published treatment parameter response data message - @return: none - """ - - self.blood_flow_rate = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] - self.dialysate_flow_rate = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] - self.tx_duration = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3]))[0] - self.saline_bolus_volume = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4]))[0] - self.hep_stop_time = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5]))[0] - self.hep_time = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6]))[0] - self.acid_con = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7]))[0] - self.bicarb_con = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8]))[0] - self.dialyzer_type = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_9:MsgFieldPositions.END_POS_FIELD_9]))[0] - self.bp_interval = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_10:MsgFieldPositions.END_POS_FIELD_10]))[0] - self.rb_flow_rate = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_11:MsgFieldPositions.END_POS_FIELD_11]))[0] - self.rb_volume = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_12:MsgFieldPositions.END_POS_FIELD_12]))[0] - self.art_pressure_window = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_13:MsgFieldPositions.END_POS_FIELD_13]))[0] - self.venous_pressure_window = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_14:MsgFieldPositions.END_POS_FIELD_14]))[0] - self.venous_asymm_window = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_15:MsgFieldPositions.END_POS_FIELD_15]))[0] - self.tmp_limit_window = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_16:MsgFieldPositions.END_POS_FIELD_16]))[0] - self.dialysate_temp = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_17:MsgFieldPositions.END_POS_FIELD_17]))[0] - self.hep_dispense_rate = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_18:MsgFieldPositions.END_POS_FIELD_18]))[0] - self.hep_bolus_vol = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_19:MsgFieldPositions.END_POS_FIELD_19]))[0] - self.uf_vol = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_20:MsgFieldPositions.END_POS_FIELD_20]))[0] - - self.tx_param_req_timestamp = timestamp - - def cmd_set_treatment_parameter(self, tx_param_id: int = 0, tx_param_value = 0 ): - """ - Constructs and sends set treatment parameter command to the TD. - - Constraints: - Must be logged into TD. - @param tx_param_value: varied - value to set the treatment parameter - @param tx_param_id: integer - the param id of the treatment paramter - - @return: 1 if successful, zero otherwise - """ - idx = integer_to_bytearray(tx_param_id) - - if tx_param_id <= TDTreatmentParameters.TREATMENT_PARAM_RINSEBACK_VOLUME.value: - tpv = integer_to_bytearray(tx_param_value) - - elif tx_param_id >= TDTreatmentParameters.TREATMENT_PARAM_DIALYSATE_TEMPERATURE.value: - tpv = float_to_bytearray(tx_param_value) - - else: - tpv = integer_to_bytearray(tx_param_value) - - payload = idx + tpv - - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_td_ch_id, - message_id=MsgIds.MSG_ID_TD_SET_TREATMENT_PARAMETER.value, - payload=payload) - - # 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 \ No newline at end of file Index: leahi_dialin/td/modules/valves.py =================================================================== diff -u -r7f463d8649e41b995e1a94cc001ffc50541cafb7 -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/td/modules/valves.py (.../valves.py) (revision 7f463d8649e41b995e1a94cc001ffc50541cafb7) +++ leahi_dialin/td/modules/valves.py (.../valves.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -24,7 +24,7 @@ from leahi_dialin.protocols.CAN import DenaliMessage, DenaliChannels 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, short_to_bytearray +from leahi_dialin.utils.conversions import integer_to_bytearray @unique @@ -157,18 +157,19 @@ self.logger.debug("Timeout!!!!") return False - def cmd_set_valve_position(self, valve: int, position: int) -> int: + def cmd_set_valve_position(self, valve: int, position: int, reset: int = NO_RESET) -> int: """ Constructs and sends the TD valves set position for a valve @param valve: integer - Valve number. Defined in ValvesEnum class @param position: integer - Position number: Defined in ValvesPositions class + @param reset: integer - 1 to reset a previous override, 0 to override @returns 1 if successful, zero otherwise """ - + reset_value = integer_to_bytearray(reset) vlv = integer_to_bytearray(valve) pos = integer_to_bytearray(position) - payload = vlv + pos + payload = reset_value + pos + vlv message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_td_ch_id, message_id=MsgIds.MSG_ID_TD_PINCH_VALVE_SET_POSITION_REQUEST.value, @@ -184,17 +185,15 @@ self.logger.debug("TD cmd_valve_override Timeout!!!") return False - def cmd_home_valve(self, valve: int, force_home: int, cartridge: int) -> int: + def cmd_home_valve(self, valve: int) -> int: """ Constructs and sends the TD valves home command @param valve: integer - Valve number. Defined in ValvesEnum class @returns 1 if successful, zero otherwise """ - vlv = integer_to_bytearray(valve) - frc = integer_to_bytearray(force_home) - cart = integer_to_bytearray(cartridge) - payload = vlv + frc + cart + payload = integer_to_bytearray(valve) + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_td_ch_id, message_id=MsgIds.MSG_ID_TD_PINCH_VALVE_HOME_REQUEST.value, payload=payload) Index: leahi_dialin/td/proxies/dd_proxy.py =================================================================== diff -u -r2dab2b0329a56006e07cd36a3883ed099d7a367a -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/td/proxies/dd_proxy.py (.../dd_proxy.py) (revision 2dab2b0329a56006e07cd36a3883ed099d7a367a) +++ leahi_dialin/td/proxies/dd_proxy.py (.../dd_proxy.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -23,12 +23,12 @@ class DDProxy(AbstractSubSystem): """ - Treatment Delivery (DD) Dialin API sub-class for DD proxy ( injection ) related commands. + Dialysate Delivery (DD) Dialin API sub-class for RO proxy ( injection ) related commands. """ def __init__(self, can_interface: DenaliCanMessenger, logger: Logger): """ - DDProxy constructor + HD_Buttons constructor @param can_interface: the Denali CAN interface object """ @@ -38,3 +38,25 @@ self.logger = logger # no current registered call back methods + + 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): + """ + Constructs and sends a TD gen dialysate request to the DD. + + @return: none + """ + stt = integer_to_bytearray(start) + dial = float_to_bytearray(dial_rate) + 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 = bic +acd + byp + temp + uf + dial + stt + message = DenaliMessage.build_message(channel_id=DenaliChannels.td_to_dd_ch_id, + message_id=MsgIds.MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA.value, + payload=payload) + + self.logger.debug("Sending TD gen dialysate data request to DD.") + self.can_interface.send(message, 0) \ No newline at end of file Index: leahi_dialin/td/proxies/ro_proxy.py =================================================================== diff -u --- leahi_dialin/td/proxies/ro_proxy.py (revision 0) +++ leahi_dialin/td/proxies/ro_proxy.py (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -0,0 +1 @@ \ No newline at end of file Fisheye: Tag eb02c56e88faeeda46ed62b1c0ec841dca0b9aba refers to a dead (removed) revision in file `leahi_dialin/td/proxies/ui_proxy.py'. Fisheye: No comparison available. Pass `N' to diff? Index: leahi_dialin/td/treatment_delivery.py =================================================================== diff -u -rb3774ad1df35c613de1c09bef40a55eb0ce4af36 -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/td/treatment_delivery.py (.../treatment_delivery.py) (revision b3774ad1df35c613de1c09bef40a55eb0ce4af36) +++ leahi_dialin/td/treatment_delivery.py (.../treatment_delivery.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -21,8 +21,6 @@ from .modules.blood_flow import TDBloodFlow from .modules.bubble_detector import TDBubbleDectector from .modules.buttons import TDButtons -from .modules.constants import NO_RESET, RESET -from .modules.ejector import TDEjector from .modules.pressure_sensors import TDPressureSensors from .modules.switches import TDSwitches from .modules.treatment import TDTreatment @@ -123,7 +121,6 @@ self.blood_flow = TDBloodFlow(self.can_interface, self.logger) self.bubbles = TDBubbleDectector(self.can_interface, self.logger) self.buttons = TDButtons(self.can_interface, self.logger) - self.ejector = TDEjector(self.can_interface, self.logger) self.pressure_sensors = TDPressureSensors(self.can_interface, self.logger) self.switches = TDSwitches(self.can_interface, self.logger) self.treatment = TDTreatment(self.can_interface, self.logger) @@ -226,7 +223,7 @@ """ message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_td_ch_id, - message_id=MsgIds.MSG_ID_TD_TESTER_LOGIN_REQUEST.value, + message_id=MsgIds.MSG_ID_TESTER_LOGIN_REQUEST.value, payload=list(map(int, map(ord, self.TD_LOGIN_PASSWORD)))) self.logger.debug("Logging in...") Index: leahi_dialin/ui/td_messaging_alarms.py =================================================================== diff -u -r287c39e4bb0d8f8d66a4f556f18ffc4e51f1e977 -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- leahi_dialin/ui/td_messaging_alarms.py (.../td_messaging_alarms.py) (revision 287c39e4bb0d8f8d66a4f556f18ffc4e51f1e977) +++ leahi_dialin/ui/td_messaging_alarms.py (.../td_messaging_alarms.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -31,26 +31,30 @@ self.can_enabled = True - def cmd_activate_alarm_id(self, - state: int = AlarmPriority.ALARM_HIGH, - alarm: int = 0, - silence_expires: int = 0, - flags: int = 0): + def cmd_activate_alarm_id(self, state: int = AlarmPriority.ALARM_HIGH, + alarm: int = 0, + escalates_in: int = 0, + silence_expires: int = 0, + flags: int = 0): """ Activates the specified alarm @param state: (int) Alarm priority @param alarm: (int) the alarm id + @param escalates_in: (int) how long until the alarm escalates @param silence_expires: (int) seconds until silence expires @param flags: (int) See 'cmd_make_alarm_flags' @return: None """ - payload = conversions.integer_to_bytearray (state ) - payload += conversions.integer_to_bytearray (alarm ) - payload += conversions.integer_to_bytearray (silence_expires) - payload += conversions.short_to_bytearray (flags ) + state = conversions.integer_to_bytearray(state) + top = conversions.integer_to_bytearray(alarm) + escalates_in = conversions.integer_to_bytearray(escalates_in) + silence_expires = conversions.integer_to_bytearray(silence_expires) + flags = conversions.integer_to_bytearray(flags) + payload = state + top + escalates_in + silence_expires + flags + message = CAN.DenaliMessage.build_message( channel_id=CAN.DenaliChannels.td_alarm_broadcast_ch_id, message_id=CAN.MsgIds.MSG_ID_ALARM_STATUS_DATA.value, @@ -59,42 +63,35 @@ self.can_interface.send(message, 0) - def cmd_send_active_list_response(self, accept: bool, reason: int = 0, - a0: int = 0, a1: int = 0, a2: int = 0, a3: int = 0, a4: int = 0, - a5: int = 0, a6: int = 0, a7: int = 0, a8: int = 0, a9: int = 0) -> None: + def cmd_send_general_response(self, message_id: int, accepted: int, reason: int, + is_pure_data: bool = False, + has_parameters: bool = False, + parameters_payload: any = 0x00, + channel_id=CAN.DenaliChannels.td_to_ui_ch_id) -> None: """ - send the list of active alarms - @param accept: boolean value true if the request accepted - @param reason: the rejection reason - @param a0: alarm id 0 in the list - First - @param a1: alarm id 1 in the list - @param a2: alarm id 2 in the list - @param a3: alarm id 3 in the list - @param a4: alarm id 4 in the list - @param a5: alarm id 5 in the list - @param a6: alarm id 6 in the list - @param a7: alarm id 7 in the list - @param a8: alarm id 8 in the list - @param a9: alarm id 9 in the list - Last + a general method to send any standard response message, by it's id and list of parameters. + @param message_id: the id of the message + @param accepted: the standard accepted parameter of any response message + @param reason: the standard rejection reason parameter of any response message + @param is_pure_data: The message only has data + @param has_parameters: if the message has parameter this needs to be true. + @param parameters_payload: the list of parameters pre-converted and ready to be concatenated to the payload. + @param channel_id: (int) indicates the channel @return: None """ - payload = conversions.integer_to_bytearray(accept) - payload += conversions.integer_to_bytearray(reason) - payload += conversions.integer_to_bytearray(a0) - payload += conversions.integer_to_bytearray(a1) - payload += conversions.integer_to_bytearray(a2) - payload += conversions.integer_to_bytearray(a3) - payload += conversions.integer_to_bytearray(a4) - payload += conversions.integer_to_bytearray(a5) - payload += conversions.integer_to_bytearray(a6) - payload += conversions.integer_to_bytearray(a7) - payload += conversions.integer_to_bytearray(a8) - payload += conversions.integer_to_bytearray(a9) + payload = "" + if not is_pure_data: + payload = conversions.integer_to_bytearray(accepted) + payload += conversions.integer_to_bytearray(reason ) + + if has_parameters: + payload = parameters_payload + message = CAN.DenaliMessage.build_message( - channel_id=CAN.DenaliChannels.td_to_ui_ch_id, - message_id=CAN.MsgIds.MSG_ID_TD_ACTIVE_ALARMS_LIST_REQUEST_RESPONSE.value, - payload=payload) + channel_id, + message_id, + payload + ) self.can_interface.send(message, 0) - Fisheye: Tag eb02c56e88faeeda46ed62b1c0ec841dca0b9aba refers to a dead (removed) revision in file `tests/unit_tests/depreciated_tests/test_dg_temperature_sensors.py'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag eb02c56e88faeeda46ed62b1c0ec841dca0b9aba refers to a dead (removed) revision in file `tests/unit_tests/depreciated_tests/test_ui_proxy.py'. Fisheye: No comparison available. Pass `N' to diff? Index: tests/unit_tests/test_constructors.py =================================================================== diff -u -r72c423da1d07c40699f40b5da5bee6d992d3082c -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- tests/unit_tests/test_constructors.py (.../test_constructors.py) (revision 72c423da1d07c40699f40b5da5bee6d992d3082c) +++ tests/unit_tests/test_constructors.py (.../test_constructors.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -16,19 +16,22 @@ import unittest import sys sys.path.append("../../") -from leahi_dialin import TD, DD, FP +from dialin import HDSimulator, DGSimulator, HD, DG class Test(unittest.TestCase): - def test_td(self): - TD() + def test_hd_simulator(self): + HDSimulator() - def test_dd(self): - DD() + def test_dg_simulator(self): + DGSimulator() - def test_fp(self): - FP() + def test_hd(self): + HD() + def test_dg(self): + DG() + if __name__ == '__main__': sys.exit(unittest.main(verbosity=2).result.wasSuccessful()) Index: tests/unit_tests/test_dg_temperature_sensors.py =================================================================== diff -u --- tests/unit_tests/test_dg_temperature_sensors.py (revision 0) +++ tests/unit_tests/test_dg_temperature_sensors.py (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -0,0 +1,34 @@ +########################################################################### +# +# Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. +# +# 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 test_dg_temperature_sensors.py +# +# @author (last) Dara Navaei +# @date (last) 01-Dec-2021 +# @author (original) Peter Lucia +# @date (original) 24-Aug-2020 +# +############################################################################ +import unittest +import sys +sys.path.append("../..") + + +class DGTemperatureSensors(unittest.TestCase): + + def test_temperature_sensors(self): + from dialin.dg.temperatures import DGTemperaturesNames + + i = 0 + for e in DGTemperaturesNames: + self.assertEqual(e.name, getattr(DGTemperaturesNames, e.name).name) + self.assertEqual(e.value, i) + i += 1 + + +if __name__ == '__main__': + sys.exit(unittest.main(verbosity=2).result.wasSuccessful()) Index: tests/unit_tests/test_enums.py =================================================================== diff -u -r72c423da1d07c40699f40b5da5bee6d992d3082c -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- tests/unit_tests/test_enums.py (.../test_enums.py) (revision 72c423da1d07c40699f40b5da5bee6d992d3082c) +++ tests/unit_tests/test_enums.py (.../test_enums.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -22,15 +22,15 @@ def test_msg_defs(self): try: - from leahi_dialin.common.msg_defs import MsgIds - from leahi_dialin.common.msg_defs import RequestRejectReasons + from dialin.common.msg_defs import MsgIds + from dialin.common.msg_defs import RequestRejectReasons except ValueError as e: self.fail("Could not import msg_defs: {0}".format(e)) def test_alarms(self): try: - from leahi_dialin.common import AlarmList - from leahi_dialin.common import AlarmPriorities + from dialin.common import AlarmList + from dialin.common import AlarmPriorities except ValueError as e: self.fail("Could not import alarm_defs: {0}".format(e)) Index: tests/unit_tests/test_imports.py =================================================================== diff -u -r72c423da1d07c40699f40b5da5bee6d992d3082c -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- tests/unit_tests/test_imports.py (.../test_imports.py) (revision 72c423da1d07c40699f40b5da5bee6d992d3082c) +++ tests/unit_tests/test_imports.py (.../test_imports.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -20,119 +20,85 @@ class Test(unittest.TestCase): - def test_td_imports(self): + def test_hd_imports(self): + from dialin.hd.alarms import HDAlarms + from dialin.hd.blood_flow import HDBloodFlow + from dialin.hd.buttons import HDButtons + from dialin.hd.constants import RESET, NO_RESET + from dialin.hd.dialysate_inlet_flow import HDDialysateInletFlow + from dialin.hd.dialysate_outlet_flow import HDDialysateOutletFlow + from dialin.hd.hemodialysis_device import HD + from dialin.hd.pressure_occlusion import HDPressureOcclusion + from dialin.hd.rtc import HDRTC + from dialin.hd.treatment import HDTreatment + from dialin.hd.ui_proxy import HDUIProxy + from dialin.hd.watchdog import HDWatchdog - from leahi_dialin.td import TD - from leahi_dialin.td.modules.air_pump import TDAirPump - from leahi_dialin.td.modules.air_trap import TDAirTrap - from leahi_dialin.td.modules.alarms import TDAlarms - from leahi_dialin.td.modules.blood_flow import TDBloodFlow - from leahi_dialin.td.modules.bubble_detector import TDBubbleDectector - from leahi_dialin.td.modules.ejector import TDEjector - from leahi_dialin.td.modules.pressure_sensors import TDPressureSensors - from leahi_dialin.td.modules.switches import TDSwitches - from leahi_dialin.td.modules.treatment import TDTreatment - from leahi_dialin.td.modules.valves import TDValves - from leahi_dialin.td.modules.voltages import TDVoltages + def test_dg_imports(self): - from leahi_dialin.td.proxies.dd_proxy import DDProxy + from dialin.dg.dialysate_generator import DG + from dialin.dg.drain_pump import DGDrainPump + from dialin.dg.hd_proxy import DGHDProxy + from dialin.dg.load_cells import DGLoadCells + from dialin.dg.pressures import DGPressures + from dialin.dg.reservoirs import DGReservoirs - def test_dd_imports(self): - from leahi_dialin.dd.dialysate_delivery import DD - from leahi_dialin.dd.modules.balancing_chamber import DDBalancingChamber - from leahi_dialin.dd.modules.concentrate_pump import DDConcentratePumps - from leahi_dialin.dd.modules.conductivity_sensors import DDConductivitySensors - from leahi_dialin.dd.modules.dialysate_pump import DDDialysatePumps - from leahi_dialin.dd.modules.gen_dialysate import DDGenDialysate - from leahi_dialin.dd.modules.heaters import DDHeaters - from leahi_dialin.dd.modules.levels import DDLevels - from leahi_dialin.dd.modules.piston_pump import DDPistonPumps - from leahi_dialin.dd.modules.post_gen_dialysate import DDPostGenDialysate - from leahi_dialin.dd.modules.pre_gen_dialysate import DDPreGenDialysate - from leahi_dialin.dd.modules.pressure_sensors import DDPressureSensors - from leahi_dialin.dd.modules.temperature_sensors import DDTemperatureSensors - from leahi_dialin.dd.modules.valves import DDValves - - def test_fp_imports(self): - - from leahi_dialin.fp.filtration_purification import FP - from leahi_dialin.fp.modules.conductivity_sensors import FPConductivitySensors - from leahi_dialin.fp.modules.flow_sensors import FPFlowSensors - from leahi_dialin.fp.modules.levels import FPLevels - from leahi_dialin.fp.modules.pressure_sensors import FPPressureSensors - from leahi_dialin.fp.modules.temperatures import FPTemperatureSensors - from leahi_dialin.fp.modules.valves import FPValves - from leahi_dialin.fp.modules.water_pumps import FPPumps - - def test_protocols_imports(self): - from leahi_dialin.protocols.CAN import (DenaliCanMessenger, + from dialin.protocols.CAN import (DenaliCanMessenger, DenaliMessage, DenaliChannels, LongDenaliMessageBuilder) def test_utils_imports(self): - from leahi_dialin.utils.conversions import (integer_to_bytearray, + from dialin.utils.conversions import (integer_to_bytearray, float_to_bytearray) def test_api_version(self): - import leahi_dialin - print(leahi_dialin.__version__) + import dialin + print(dialin.__version__) def test_package_imports(self): - from leahi_dialin import TD, DD, FP + from dialin import HD, HDSimulator, DG - from leahi_dialin.td import TD - from leahi_dialin.td.modules.air_pump import TDAirPump - from leahi_dialin.td.modules.air_trap import TDAirTrap - from leahi_dialin.td.modules.alarms import TDAlarms - from leahi_dialin.td.modules.blood_flow import TDBloodFlow - from leahi_dialin.td.modules.bubble_detector import TDBubbleDectector - from leahi_dialin.td.modules.ejector import TDEjector - from leahi_dialin.td.modules.pressure_sensors import TDPressureSensors - from leahi_dialin.td.modules.switches import TDSwitches - from leahi_dialin.td.modules.treatment import TDTreatment - from leahi_dialin.td.modules.valves import TDValves - from leahi_dialin.td.modules.voltages import TDVoltages + from dialin.hd import HD + from dialin.hd import HDAlarms + from dialin.hd import HDBloodFlow + from dialin.hd import HDButtons + from dialin.hd import RESET, NO_RESET, BUTTON_PRESSED, BUTTON_RELEASED + from dialin.hd import HDDialysateInletFlow + from dialin.hd import HDDialysateOutletFlow + from dialin.hd import HDPressureOcclusion + from dialin.hd import HDRTC + from dialin.hd import HDTreatment + from dialin.hd import HDUIProxy + from dialin.hd import HDWatchdog - from leahi_dialin.td.proxies.dd_proxy import DDProxy + from dialin.dg import DG + from dialin.dg import RESET, NO_RESET + from dialin.dg import DGDrainPump + from dialin.dg import DGHDProxy + from dialin.dg import Heaters + from dialin.dg import DGLoadCells + from dialin.dg import DGPressures + from dialin.dg import DGReservoirs + from dialin.dg import DGROPump + from dialin.dg import TemperatureSensors + from dialin.dg import DGValves - from leahi_dialin.dd.dialysate_delivery import DD - from leahi_dialin.dd.modules.balancing_chamber import DDBalancingChamber - from leahi_dialin.dd.modules.concentrate_pump import DDConcentratePumps - from leahi_dialin.dd.modules.conductivity_sensors import DDConductivitySensors - from leahi_dialin.dd.modules.dialysate_pump import DDDialysatePumps - from leahi_dialin.dd.modules.gen_dialysate import DDGenDialysate - from leahi_dialin.dd.modules.heaters import DDHeaters - from leahi_dialin.dd.modules.levels import DDLevels - from leahi_dialin.dd.modules.piston_pump import DDPistonPumps - from leahi_dialin.dd.modules.post_gen_dialysate import DDPostGenDialysate - from leahi_dialin.dd.modules.pre_gen_dialysate import DDPreGenDialysate - from leahi_dialin.dd.modules.pressure_sensors import DDPressureSensors - from leahi_dialin.dd.modules.temperature_sensors import DDTemperatureSensors - from leahi_dialin.dd.modules.valves import DDValves + from dialin.ui import HDSimulator - from leahi_dialin.fp.filtration_purification import FP - from leahi_dialin.fp.modules.conductivity_sensors import FPConductivitySensors - from leahi_dialin.fp.modules.flow_sensors import FPFlowSensors - from leahi_dialin.fp.modules.levels import FPLevels - from leahi_dialin.fp.modules.pressure_sensors import FPPressureSensors - from leahi_dialin.fp.modules.temperatures import FPTemperatureSensors - from leahi_dialin.fp.modules.valves import FPValves - from leahi_dialin.fp.modules.water_pumps import FPPumps - - def test_common(self): - from leahi_dialin.common import (AlarmList, + from dialin.common import (AlarmList, AlarmPriority, AlarmFlags, AlarmPriorities, MsgIds, MsgFieldPositions, + Ranges, RequestRejectReasons) Index: tests/unit_tests/test_msg_ids.py =================================================================== diff -u -r72c423da1d07c40699f40b5da5bee6d992d3082c -reb02c56e88faeeda46ed62b1c0ec841dca0b9aba --- tests/unit_tests/test_msg_ids.py (.../test_msg_ids.py) (revision 72c423da1d07c40699f40b5da5bee6d992d3082c) +++ tests/unit_tests/test_msg_ids.py (.../test_msg_ids.py) (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -18,7 +18,7 @@ import sys import os sys.path.append("../../") -from leahi_dialin.common import MsgIds +from dialin.common import MsgIds class Test(unittest.TestCase): Index: tests/unit_tests/test_ui_proxy.py =================================================================== diff -u --- tests/unit_tests/test_ui_proxy.py (revision 0) +++ tests/unit_tests/test_ui_proxy.py (revision eb02c56e88faeeda46ed62b1c0ec841dca0b9aba) @@ -0,0 +1,122 @@ +########################################################################### +# +# Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. +# +# 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 test_ui_proxy.py +# +# @author (last) Micahel Garthwaite +# @date (last) 17-Aug-2023 +# @author (original) Peter Lucia +# @date (original) 16-Dec-2020 +# +############################################################################ +import unittest +import sys +import struct +sys.path.append("../../") +from dialin import HD +from dialin.utils import setup_virtual_can_interface +from collections import OrderedDict +from dialin.utils.conversions import integer_to_bytearray, float_to_bytearray +from dialin.protocols.CAN import (DenaliMessage, + DenaliChannels) +from dialin.common import MsgIds, TreatmentParameters +from dialin.utils import is_interface_up, is_interface_present + + +class Test(unittest.TestCase): + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + if not is_interface_present("can0") or not is_interface_up("can0"): + setup_virtual_can_interface() + self.hd = HD() + self.params = OrderedDict([ + ("bld_flow", 100 ), + ("dia_flow", 100 ), + ("duration", 60 ), + ("hep_rate", 0.1 ), + ("hep_bol" , 0.2 ), + ("hep_stop", 1 ), + ("sal_bol" , 100 ), + ("acid" , 0 ), + ("bicarb" , 0 ), + ("dialyzer", 0 ), + ("hep_type", 0 ), + ("dia_temp", 35.0 ), + ("art_win" , 120 ), + ("ven_win" , 100 ), + ("ven_asy" , 20 ), + ("bp_intvl", 15 ), + ("rb_flow" , 50 ) + ]) + + def test_treatment_parameters(self): + + result = [] + for key, value in self.params.items(): + result.append(value) + + self.hd.ui.cmd_set_treatment_parameters(**self.params) + + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_BLOOD_FLOW_RATE_ML_MIN.value] , self.params.get("bld_flow", None)) + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_DIALYSATE_FLOW_RATE_ML_MIN.value] , self.params.get("dia_flow", None)) + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_TREATMENT_DURATION_MIN.value] , self.params.get("duration", None)) + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_HEPARIN_DISPENSE_RATE_ML_HR.value] , self.params.get("hep_rate", None)) + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME_ML.value] , self.params.get("hep_bol" , None)) + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_HEPARIN_PRESTOP_MIN.value] , self.params.get("hep_stop", None)) + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_SALINE_BOLUS_VOLUME_ML.value] , self.params.get("sal_bol" , None)) + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_ACID_CONCENTRATE.value] , self.params.get("acid" , None)) + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_BICARB_CONCENTRATE.value] , self.params.get("bicarb" , None)) + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_DIALYZER_TYPE.value] , self.params.get("dialyzer", None)) + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_HEPARIN_TYPE.value] , self.params.get("hep_type", None)) + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_DIALYSATE_TEMPERATURE_C.value] , self.params.get("dia_temp", None)) + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_ART_PRES_LIMIT_WINDOW.value] , self.params.get("art_win" , None)) + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_VEN_PRES_LIMIT_WINDOW.value] , self.params.get("ven_win" , None)) + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_VEN_PRES_LIMIT_ASYMMETRIC.value] , self.params.get("ven_asy" , None)) + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_BLOOD_PRESSURE_MEAS_INTERVAL_MIN.value] , self.params.get("bp_intvl", None)) + self.assertEqual(self.hd.ui.treatment_parameters[TreatmentParameters.TREATMENT_PARAM_RINSEBACK_FLOW_RATE_ML_MIN.value] , self.params.get("rb_flow" , None)) + + + def test_treatment_parameters_settings_normal(self): + test_timestamp = 0.0 + payload = integer_to_bytearray(self.params.get("bld_flow", None)) + payload += integer_to_bytearray(self.params.get("dia_flow", None)) + payload += integer_to_bytearray(self.params.get("duration", None)) + payload += float_to_bytearray(self.params.get("hep_rate", None)) + payload += float_to_bytearray(self.params.get("hep_bol", None)) + payload += integer_to_bytearray(self.params.get("hep_stop", None)) + payload += integer_to_bytearray(self.params.get("sal_bol", None)) + payload += integer_to_bytearray(self.params.get("acid", None)) + payload += integer_to_bytearray(self.params.get("bicarb", None)) + payload += integer_to_bytearray(self.params.get("dialyzer", None)) + payload += integer_to_bytearray(self.params.get("hep_type", None)) + payload += float_to_bytearray(self.params.get("dia_temp", None)) + payload += integer_to_bytearray(self.params.get("art_win", None)) + payload += integer_to_bytearray(self.params.get("ven_win", None)) + payload += integer_to_bytearray(self.params.get("ven_asy", None)) + payload += integer_to_bytearray(self.params.get("bp_intvl", None)) + payload += integer_to_bytearray(self.params.get("rb_flow", None)) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.ui_to_hd_ch_id, + message_id=MsgIds.MSG_ID_UI_NEW_TREATMENT_PARAMS_REQUEST.value, + payload=payload) + + self.assertIsNone(self.hd.ui._handler_treatment_param_settings(message, test_timestamp)) + + def test_treatment_parameters_settings_wrong_type(self): + test_timestamp = 0.0 + payload = bytearray() + + message = DenaliMessage.build_message(channel_id=DenaliChannels.ui_to_hd_ch_id, + message_id=MsgIds.MSG_ID_UI_NEW_TREATMENT_PARAMS_REQUEST.value, + payload=payload) + + self.assertRaises(struct.error, self.hd.ui._handler_treatment_param_settings, message, test_timestamp) + + +if __name__ == '__main__': + sys.exit(unittest.main(verbosity=2).result.wasSuccessful())