########################################################################### # # Copyright (c) 2019-2020 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 hd_valves_test.py # # @author (last) Dara Navaei # @date (last) 02-Oct-2020 # @author (original) Dara Navaei # @date (original) 19-Aug-2020 # ############################################################################ import sys sys.path.append("..") from dialin.hd.constants import RESET, NO_RESET 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__": # Create an instance of the DG Class hd = HD(log_level='DEBUG') if hd.cmd_log_in_to_hd() == 0: exit(1) valves = hd.valves #valves.cmd_open_hd_air_trap_valve(AirTrapState.STATE_OPEN) #sleep(2) overall_counter = 0 sleep_time = 0.01 overall_time_seconds = 4 valves.cmd_home_hd_valve(ValvesEnum.VBA.value) sleep(3) valves.cmd_hd_valves_broadcast_interval_override(10) sleep(3) valves.cmd_set_hd_valve_position(ValvesEnum.VBA.value, ValvesPositions.VALVE_POSITION_C_CLOSE.value) while overall_counter < (overall_time_seconds/sleep_time): print(valves.valves_status[ValvesEnum.VBA.name]) overall_counter = overall_counter + 1 sleep(sleep_time) """ print("Reset") #valves.cmd_set_hd_valve_pwm(2, 50, 0) sleep(2) valves.cmd_set_hd_valve_position(2, 3) counter = 0 overall_counter = 0 overall_time_seconds = 3 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("Pos, {}, Cmd, {}, Curr, {}, PosA, {}, PosB, {}, PosC, {}, State, {}, PWM, {}".format(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) """""