Index: dialin/hd/valves.py =================================================================== diff -u -r87cf0bc784212d2608c58d1388b37396aa0a4656 -re2d925f873714f2bc9a4b90ce7b72fd78919f391 --- dialin/hd/valves.py (.../valves.py) (revision 87cf0bc784212d2608c58d1388b37396aa0a4656) +++ dialin/hd/valves.py (.../valves.py) (revision e2d925f873714f2bc9a4b90ce7b72fd78919f391) @@ -40,8 +40,6 @@ \brief Hemodialysis Device (HD) Dialin API sub-class for valves related commands. """ - MSG_ID_TEMP_FAST_HD_VALVES_REMOVE_LATER = 0x6D # TODO Remove - # Valves states publish message field positions START_POS_VALVES_ID = DenaliMessage.PAYLOAD_START_INDEX END_POS_VALVES_ID = START_POS_VALVES_ID + 4 @@ -76,15 +74,6 @@ START_AIR_TRAP_VALVE_STATUS = END_VALVES_PWM END_AIR_TRAP_VALVE_STATUS = START_AIR_TRAP_VALVE_STATUS + 4 - # TODO Fast publish REMOVE LATER - START_FAST_VALVES_POS = DenaliMessage.PAYLOAD_START_INDEX - END_FAST_VALVES_POS = START_FAST_VALVES_POS + 2 - START_FAST_VALVES_CURR = END_FAST_VALVES_POS - END_FAST_VALVES_CURR = START_FAST_VALVES_CURR + 4 - START_FAST_VALVES_CMD = END_FAST_VALVES_CURR - END_FAST_VALVES_CMD = START_FAST_VALVES_CMD + 2 - # TODO Fast publish REMOVE LATER - def __init__(self, can_interface, logger: Logger): """ DGDrainPump constructor @@ -101,24 +90,12 @@ self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_hd_valves_sync) - # TODO remove - msg_id2 = self.MSG_ID_TEMP_FAST_HD_VALVES_REMOVE_LATER - self.can_interface.register_receiving_publication_function(channel_id, msg_id2, - self.handler_hd_valves_fast_temp_sync) - # TODO remove - # A dictionary of the valves with the status self.valves_status = {ValvesEnum.VDI.name:{}, ValvesEnum.VDO.name:{}, ValvesEnum.VBA.name:{}, ValvesEnum.VBV.name:{}} self.hd_air_trap_status = 0 - #TODO Remove these later - self.hd_valve_fast_pos = 0 - self.hd_valve_fast_current = 0 - self.hd_valves_fast_cmd = 0 - #TODO Remove these later - def cmd_hd_valves_broadcast_interval_override(self, ms, reset=NO_RESET): """ Constructs and sends broadcast time interval @@ -316,19 +293,3 @@ self.hd_air_trap_status = AirTrapState(air_trap).name except: self.hd_air_trap_status = 'Valve Status Unknown' - - #TODO REMOVE THIS FUNCTION - def handler_hd_valves_fast_temp_sync(self, message): - - fast_pos = struct.unpack('h', bytearray( - message['message'][self.START_FAST_VALVES_POS:self.END_FAST_VALVES_POS])) - fast_current = struct.unpack('f', bytearray( - message['message'][self.START_FAST_VALVES_CURR:self.END_FAST_VALVES_CURR])) - - fast_pos_cmd = struct.unpack('h', bytearray( - message['message'][self.START_FAST_VALVES_CMD:self.END_FAST_VALVES_CMD])) - - self.hd_valve_fast_pos = fast_pos[0] - self.hd_valve_fast_current = fast_current[0] - self.hd_valves_fast_cmd = fast_pos_cmd[0] - #TODO REMOVE THIS FUNCTION Index: tests/hd_valves_test.py =================================================================== diff -u -r87cf0bc784212d2608c58d1388b37396aa0a4656 -re2d925f873714f2bc9a4b90ce7b72fd78919f391 --- tests/hd_valves_test.py (.../hd_valves_test.py) (revision 87cf0bc784212d2608c58d1388b37396aa0a4656) +++ tests/hd_valves_test.py (.../hd_valves_test.py) (revision e2d925f873714f2bc9a4b90ce7b72fd78919f391) @@ -4,6 +4,7 @@ from dialin.hd.hemodialysis_device import HD from dialin.hd.valves import ValvesEnum from dialin.hd.valves import AirTrapState +from dialin.hd.valves import ValvesPositions from time import sleep if __name__ == "__main__": @@ -18,91 +19,27 @@ #valves.cmd_open_hd_air_trap_valve(AirTrapState.STATE_OPEN) #sleep(2) - #valves.cmd_home_hd_valve(2) - #sleep(4) - counter = 0 overall_counter = 0 sleep_time = 0.01 - overall_time_seconds = 1 - """ - while overall_counter < (overall_time_seconds/sleep_time): + overall_time_seconds = 4 - if counter >= 10: - print("Valve, {}, State, {}, Curr_Pos_ID, {}, Curr_Pos_Cnt, {}, Next_Pos_Cnt, {}, " - "Current, {}, Pos_C, {}, Pos_A, {}, Pos_B, {}" - .format(valves.hd_valve_ID, valves.hd_valve_state, valves.hd_valve_curr_pos_ID, - valves.hd_valve_curr_pos_cnt, valves.hd_valve_next_pos_cnt, valves.hd_valve_current, - valves.hd_valves_pos_c, valves.hd_valves_pos_a, valves.hd_valves_pos_b)) - counter = 0 + valves.cmd_home_hd_valve(ValvesEnum.VBA.value) + sleep(3) - print("Pos, {}, Cmd, {}, Curr, {}".format(valves.hd_valve_fast_pos, - valves.hd_valves_fast_cmd, valves.hd_valve_fast_current)) - - counter = counter + 1 - overall_counter = overall_counter + 1 - - sleep(sleep_time) - - """ - print( "Transitioning to ") - #counter = 0 - #overall_counter = 0 - # 1 Insert/Eject - # 2 Open - # 3 Close - """" - valves.cmd_home_hd_valve(0) - sleep(2) - valves.cmd_home_hd_valve(1) - sleep(2) - valves.cmd_home_hd_valve(2) - sleep(2) - valves.cmd_home_hd_valve(3) - sleep(2) - - #valves.cmd_set_hd_valve_pwm(2, 100, 1) - valves.cmd_set_hd_valve_position(0, 2) - """ - - #valves.cmd_home_hd_valve(2) - #sleep(2) - - #valves.cmd_hd_valves_broadcast_interval_override(10, reset=RESET) - #sleep(3) - - #valves.cmd_home_hd_valve(2) - #sleep(3) - valves.cmd_hd_valves_broadcast_interval_override(10) sleep(3) - valves.cmd_set_hd_valve_position(2, 2) + valves.cmd_set_hd_valve_position(ValvesEnum.VBA.value, ValvesPositions.VALVE_POSITION_C_CLOSE.value) while overall_counter < (overall_time_seconds/sleep_time): - if counter >= 10: - #print("Valve, {}, State, {}, Curr_Pos_ID, {}, Curr_Pos_Cnt, {}, Next_Pos_Cnt, {}, " - # "Current, {}, Pos_C, {}, Pos_A, {}, Pos_B, {}" - # .format(valves.hd_valve_ID, valves.hd_valve_state, valves.hd_valve_curr_pos_ID, - # valves.hd_valve_curr_pos_cnt, valves.hd_valve_next_pos_cnt, valves.hd_valve_current, - # valves.hd_valves_pos_c, valves.hd_valves_pos_a, valves.hd_valves_pos_b)) - counter = 0 print(valves.valves_status[ValvesEnum.VBA.name]) - #print("Valve, {}, Pos, {}, Cmd, {}, Curr, {}, PosA, {}, PosB, {}, PosC, {}, State, {}, PWM, {}".format( - # valves.hd_valve_ID, valves.hd_valve_fast_pos, - # valves.hd_valves_fast_cmd, valves.hd_valve_fast_current, - # valves.hd_valves_pos_a, valves.hd_valves_pos_b, - # valves.hd_valves_pos_c, valves.hd_valve_state, - # valves.hd_valves_pwm)) - counter = counter + 1 overall_counter = overall_counter + 1 sleep(sleep_time) """ - valves.cmd_set_hd_valve_pwm(2, 0, 0, reset=RESET) - print("Reset") #valves.cmd_set_hd_valve_pwm(2, 50, 0) sleep(2)