import sys sys.path.append("..") from dialin.hd.constants import RESET, NO_RESET from dialin.hd.hemodialysis_device import HD from time import sleep if __name__ == "__main__": # Create an instance of the DG Class hd = HD() if hd.cmd_log_in_to_hd() == 0: exit(1) valves = hd.valves #valves.cmd_open_hd_air_trap_valve() #sleep(2) #valves.cmd_close_hd_air_trap_valve() #sleep(2) #valves.cmd_home_hd_valve(2) #sleep(4) counter = 0 overall_counter = 0 sleep_time = 0.01 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, {}".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_set_hd_valve_position(2, 2) 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("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) 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) """""