Index: leahi_dialin/dd/modules/piston_pump.py =================================================================== diff -u -rfdbc8e289849262ab4ceeb34d87d3e9a4420d820 -rfe37f0a0f2c683696f41f6a349cf2756ed09d5d7 --- leahi_dialin/dd/modules/piston_pump.py (.../piston_pump.py) (revision fdbc8e289849262ab4ceeb34d87d3e9a4420d820) +++ leahi_dialin/dd/modules/piston_pump.py (.../piston_pump.py) (revision fe37f0a0f2c683696f41f6a349cf2756ed09d5d7) @@ -97,6 +97,8 @@ message['message'][MsgFieldPositions.START_POS_FIELD_9:MsgFieldPositions.END_POS_FIELD_9]))[0] self.dd_piston_pump_timestamp = timestamp + + def cmd_piston_pump_broadcast_interval_override(self, ms: int, reset: int = NO_RESET) -> int: """ Constructs and sends the piston pump data broadcast interval override command Index: leahi_dialin/fp/modules/levels.py =================================================================== diff -u -r705f22414b70224dc1017379ce99e83d7dc07803 -rfe37f0a0f2c683696f41f6a349cf2756ed09d5d7 --- leahi_dialin/fp/modules/levels.py (.../levels.py) (revision 705f22414b70224dc1017379ce99e83d7dc07803) +++ leahi_dialin/fp/modules/levels.py (.../levels.py) (revision fe37f0a0f2c683696f41f6a349cf2756ed09d5d7) @@ -28,8 +28,8 @@ @unique class FPFloaterLevels(DialinEnum): LEVEL_STATE_LOW = 0 - LEVEL_STATE_HIGH = 1 - LEVEL_STATE_MEDIUM = 2 + LEVEL_STATE_MEDIUM = 1 + LEVEL_STATE_HIGH = 2 LEVEL_STATE_ILLEGAL = 3 @@ -52,7 +52,7 @@ if self.can_interface is not None: channel_id = DenaliChannels.fp_sync_broadcast_ch_id - msg_id = MsgIds.MSG_ID_RO_LEVEL_DATA.value + msg_id = MsgIds.MSG_ID_FP_LEVEL_DATA.value self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_levels_sync) self.p25_level = 0 @@ -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_FP_LEVEL_PUBLISH_INTERVAL_OVERRIDE_REQUEST.value, payload=payload) self.logger.debug("Sending {} ms publish interval to the FP Levels module".format(ms)) @@ -119,7 +119,7 @@ sts = integer_to_bytearray(status) payload = reset_value + sts 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_FP_LEVEL_OVERRIDE_REQUEST.value, payload=payload) # Send message Index: leahi_dialin/fp/modules/valves.py =================================================================== diff -u -r3be964d9e5d4ffd82198425658876bbc3f464637 -rfe37f0a0f2c683696f41f6a349cf2756ed09d5d7 --- leahi_dialin/fp/modules/valves.py (.../valves.py) (revision 3be964d9e5d4ffd82198425658876bbc3f464637) +++ leahi_dialin/fp/modules/valves.py (.../valves.py) (revision fe37f0a0f2c683696f41f6a349cf2756ed09d5d7) @@ -72,7 +72,7 @@ if self.can_interface is not None: channel_id = DenaliChannels.fp_sync_broadcast_ch_id - msg_id = MsgIds.MSG_ID_RO_VALVES_STATES_DATA.value + msg_id = MsgIds.MSG_ID_FP_VALVES_STATES_DATA.value self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_valves_sync) self.valve_states_all = 0x0000 @@ -205,7 +205,7 @@ payload = rst + ste + vlv message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_fp_ch_id, - message_id=MsgIds.MSG_ID_RO_VALVE_SENSED_STATE_OVERRIDE_REQUEST.value, + message_id=MsgIds.MSG_ID_FP_VALVE_SENSED_STATE_OVERRIDE_REQUEST.value, payload=payload) self.logger.debug("Override valve sensed state") @@ -240,7 +240,7 @@ payload = rst + ste + vlv message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_fp_ch_id, - message_id=MsgIds.MSG_ID_RO_VALVE_CMD_STATE_OVERRIDE_REQUEST.value, + message_id=MsgIds.MSG_ID_FP_VALVE_CMD_STATE_OVERRIDE_REQUEST.value, payload=payload) self.logger.debug("Override valve state") @@ -277,7 +277,7 @@ payload = rst + ivl message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_fp_ch_id, - message_id=MsgIds.MSG_ID_RO_VALVE_PUBLISH_INTERVAL_OVERRIDE_REQUEST.value, + message_id=MsgIds.MSG_ID_FP_VALVE_PUBLISH_INTERVAL_OVERRIDE_REQUEST.value, payload=payload) self.logger.debug("override FP valves states publish interval") Index: leahi_dialin/fp/modules/water_pumps.py =================================================================== diff -u -r4b1e41d69f00c40e84664f6581376d9c8db102c8 -rfe37f0a0f2c683696f41f6a349cf2756ed09d5d7 --- leahi_dialin/fp/modules/water_pumps.py (.../water_pumps.py) (revision 4b1e41d69f00c40e84664f6581376d9c8db102c8) +++ leahi_dialin/fp/modules/water_pumps.py (.../water_pumps.py) (revision fe37f0a0f2c683696f41f6a349cf2756ed09d5d7) @@ -34,7 +34,7 @@ class FPPumps(AbstractSubSystem): """ - Dialin API sub-class for RO pump related commands. + Dialin API sub-class for FP water pump driver related commands. """ def __init__(self, can_interface, logger: Logger): @@ -45,53 +45,8 @@ 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_pump_sync) - self.ro_pump_timestamp = 0.0 - self.p12_pump_state = 0 - self.p12_pump_duty_cycle = 0.0 - self.p12_pump_fb_duty_cycle = 0.0 - self.p12_pump_speed = 0.0 - self.p40_pump_state = 0 - self.p40_pump_duty_cycle = 0.0 - self.p40_pump_fb_duty_cycle = 0.0 - self.p40_pump_speed = 0.0 + # no current registered call back methods - - @publish(["ro_pump_timestamp", "p12_pump_state", "p12_pump_duty_cycle", "p12_pump_fb_duty_cycle", - "p12_pump_speed", "p40_pump_state", "p40_pump_duty_cycle", - "p40_pump_fb_duty_cycle", "p40_pump_speed"]) - def _handler_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 - """ - - self.p12_pump_state = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] - self.p12_pump_duty_cycle = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] - self.p12_pump_fb_duty_cycle = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3]))[0] - self.p12_pump_speed = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4]))[0] - self.p40_pump_state = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5]))[0] - self.p40_pump_duty_cycle = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6]))[0] - self.p40_pump_fb_duty_cycle = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7]))[0] - self.p40_pump_speed = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8]))[0] - - self.ro_pump_timestamp = timestamp - def cmd_pump_set_speed_rate_override(self, pump: int, rpm: int, reset: int = NO_RESET) -> int: """ Constructs and sends the boost pump set speed rate command @@ -107,7 +62,7 @@ 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, + message_id=MsgIds.MSG_ID_FP_BOOST_PUMP_SPEED_OVERRIDE_REQUEST.value, payload=payload) self.logger.debug("override pump set speed rate point") @@ -131,7 +86,7 @@ def cmd_pump_set_pwm_request(self, pump: int, pwm: int) -> int: """ - Constructs and sends set pwm request for RO pumps \n + Constructs and sends set pwm request for FP pumps \n command. Constraints: Must be logged into FP. @@ -146,7 +101,7 @@ 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, + message_id=MsgIds.MSG_ID_FP_BOOST_PUMP_SET_PWM_REQUEST.value, payload=payload) self.logger.debug("setting pump {} to pwm count {}".format(pump,pwm)) @@ -166,7 +121,7 @@ def cmd_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 + Constructs and sends the read pwm override for the FP pumps \n command. Constraints: Must be logged into FP. @@ -182,7 +137,7 @@ 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, + message_id=MsgIds.MSG_ID_FP_BOOST_PUMP_READ_PWM_OVERRIDE_REQUEST.value, payload=payload) self.logger.debug("override read pwm for pump".format(pump)) @@ -206,7 +161,7 @@ def cmd_pump_broadcast_interval_override(self, ms: int, reset: int = NO_RESET) -> int: """ - Constructs and sends the RO pump broadcast interval override command + Constructs and sends the FP 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). @@ -224,7 +179,7 @@ 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, + message_id=MsgIds.MSG_ID_FP_BOOST_PUMPS_PUBLISH_INTERVAL_OVERRIDE_REQUEST.value, payload=payload) self.logger.debug("override FP pump broadcast interval") Index: tests/depreciated_tests/test_uf.py =================================================================== diff -u --- tests/depreciated_tests/test_uf.py (revision 0) +++ tests/depreciated_tests/test_uf.py (revision fe37f0a0f2c683696f41f6a349cf2756ed09d5d7) @@ -0,0 +1,94 @@ +########################################################################### +# +# 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_uf.py +# +# @author (last) Sean Nash +# @date (last) 24-Sep-2022 +# @author (original) Peter Lucia +# @date (original) 14-Jul-2020 +# +############################################################################ + +import sys +sys.path.append("..") +from time import sleep + +from leahi_dialin.td.treatment_delivery import TD +#from leahi_dialin.dd.dialysate_delivery import DD +#from leahi_dialin.fp.reverse_osmosis import RO + +from leahi_dialin.td.modules.valves import ValvesEnum + +if __name__ == "__main__": + # create an TD object called td + td = TD(log_level="DEBUG") + # create a DD object called dd +# dd = DD(log_level="DEBUG") + # create a RO object called fp +# fp = RO(log_level="DEBUG") + sleep(2) + + # log in to TD, DD and RO as tester + if td.cmd_log_in_to_td() == 0: + exit(1) +# if dd.cmd_log_in_to_dd() == 0: +# exit(1) +# if fp.cmd_log_in_to_ro() == 0: +# exit(1) +# sleep(1) + + # send command to show round-trip communication w/ firmware is working + td.blood_flow.cmd_blood_flow_set_speed_rate_request(1000) + + # create log file + with open("TD_test.log", "w") as f: + + # collect data and display/log it + while True: + sleep(1) + modes = "TD.m, " + '{:2d}'.format(td.td_operation_mode) + \ + ", TD.s, " + '{:2d}'.format(td.td_operation_sub_mode) + # ", DD.m, " + '{:2d}'.format(dd.dd_operation_mode) + \ + # ", DD.s, " + '{:2d}'.format(dd.dd_operation_sub_mode) + pumpSetPts = ", BP.sf, " + '{:4d}'.format(td.blood_flow.set_blood_flow_rate) + \ + ", BP.ss, " + '{:9.2f}'.format(td.blood_flow.set_rpm) + # ", ROP.s, " + '{:9.2f}'.format(fp.ro_pump.TBD) + pumpMeasSpds = ", BP.m, " + '{:7.1f}'.format(td.blood_flow.measured_blood_pump_speed) + # ", BP.r, " + '{:6.1f}'.format(td.blood_flow.measured_blood_pump_rotor_speed) + \ + # ", BP.f, " + '{:7.1f}'.format(td.blood_flow.measured_blood_flow_rate) + press = ", PBA, " + '{:9.2f}'.format(td.pressure_sensors.arterial_pressure) + \ + ", PBV, " + '{:9.2f}'.format(td.pressure_sensors.venous_pressure) + # valves = ", VBA, " + td.valves.valves_status[ValvesEnum.VBA.name]["PosID"] + \ + # ", VBV, " + td.valves.valves_status[ValvesEnum.VBV.name]["PosID"] + # air = ", ADV, " + '{:1d}'.format(td.bubbles.air_bubbles_status) + \ + # ", ULBl, " + '{:1d}'.format(td.air_trap.lower_level) + \ + # ", ULBu, " + '{:1d}'.format(td.air_trap.upper_level) + \ + # ", AP, " + '{:1d}'.format(td.air_pump.air_pump_state) + \ + # ", VBT, " + '{:1d}'.format(td.air_trap.valve_state) + # alarms = ", AL.s, " + '{:1d}'.format(td.alarms.get_current_alarms_state()) + \ + # ", AL.t, " + '{:4d}'.format(td.alarms.alarm_top) + + # log data + f.write(modes) + f.write(pumpSetPts) + f.write(pumpMeasSpds) + f.write(press) + # f.write(valves) + # f.write(air) + # f.write(alarms) + f.write("\n") + + # print to console + print(" Modes: "+modes) + print("Pump Set Pts: "+pumpSetPts) + print(" Pump Speeds: "+pumpMeasSpds) + print(" Pressures: "+press) + # print(" Valves: "+valves) + # print(" Air: "+air) + # print(" Alarms: "+alarms) +