def start_ps_train(coord_vib): phantom_res_list, vib_duration = generate_tactile_brush_results( 1, v_distance_inter_actu.get(), 2000) #print(coord_vib) phantom_list = [] for phantom_item in phantom_res_list: if coord_vib == phantom_item[0] and phantom_item[1] == 0: phantom_list.append(coord_vib) phantom_list.append(0) phantom_list.append(phantom_item[2]) phantom_list.append(phantom_item[3]) phantom_list.append(phantom_item[4]) phantom_list.append(phantom_item[5]) phantom_list.append(2000) # print(phantom_list) try: _thread.start_new_thread(generate_phantom_arduino, (phantom_list, )) except: print('Start thread exception')
def start_ps(): phantom_res_list, vib_duration = generate_tactile_brush_results( float(str(v.get())), int(str(txt_distance.get())), int(str(txt_T.get()))) phantom_list = [] for phantom_item in phantom_res_list: if int(txt_end_x.get()) == phantom_item[0] and int( txt_end_y.get()) == phantom_item[1]: phantom_list.append(int(txt_end_x.get())) phantom_list.append(int(txt_end_y.get())) phantom_list.append(phantom_item[2]) phantom_list.append(phantom_item[3]) phantom_list.append(phantom_item[4]) phantom_list.append(phantom_item[5]) phantom_list.append(int(str(txt_T.get()))) change_color_tactor(phantom_list) try: _thread.start_new_thread(generate_phantom_arduino, (phantom_list, )) except: print('Start thread exception')
def start_atm_duration(int_direction, duration): distance = 20 no_direction = int_direction phantom_res_list, vib_duration = generate_tactile_brush_results(0.7, distance, duration) start_vib_list = [] end_vib_list = [] temp_start_x = 0 temp_start_y = 0 temp_end_x = 0 temp_end_y = 0 if no_direction == 1: temp_start_x = 0 temp_start_y = distance temp_end_x = distance temp_end_y = distance elif no_direction == 2: temp_start_x = distance temp_start_y = distance temp_end_x = distance temp_end_y = 0 elif no_direction == 3: temp_start_x = distance temp_start_y = 0 temp_end_x = 0 temp_end_y = 0 elif no_direction == 4: temp_start_x = 0 temp_start_y = 0 temp_end_x = 0 temp_end_y = distance elif no_direction == 5: temp_start_x = 0 temp_start_y = distance temp_end_x = distance temp_end_y = 0 elif no_direction == 6: temp_start_x = 0 temp_start_y = 0 temp_end_x = distance temp_end_y = distance if no_direction != 0: for phantom_item in phantom_res_list: if temp_start_x == phantom_item[0] and temp_start_y == phantom_item[1]: start_vib_list.append(temp_start_x) start_vib_list.append(temp_start_y) start_vib_list.append(phantom_item[2]) start_vib_list.append(phantom_item[3]) start_vib_list.append(phantom_item[4]) start_vib_list.append(phantom_item[5]) start_vib_list.append(vib_duration) for phantom_item_end in phantom_res_list: if temp_end_x == phantom_item_end[0] and temp_end_y == phantom_item_end[1]: end_vib_list.append(temp_end_x) end_vib_list.append(temp_end_y) end_vib_list.append(phantom_item_end[2]) end_vib_list.append(phantom_item_end[3]) end_vib_list.append(phantom_item_end[4]) end_vib_list.append(phantom_item_end[5]) end_vib_list.append(vib_duration) time_SOA = generate_SOA(duration, vib_duration) try: _thread.start_new_thread(generate_atm_arduino_without_single_vibration_overview, (start_vib_list, end_vib_list, time_SOA)) except: print('Infrared ATM error') print('Start Vib List: ') print(start_vib_list) print('End Vib List: ') print(end_vib_list)
def click_btn_train(): int_direction_list = [1, 2, 3, 4, 5, 6, 7, 8] global flag_train_svp global flag_train_atm block_value = v_block.get() ti_value = v_technique.get() if block_value == 'A': layout_value = 'Square' elif block_value == 'B': layout_value = 'Cross' elif block_value == 'C': layout_value = 'Square' else: layout_value = 'Cross' if layout_value == 'Square': print('Train Square') if ti_value == 'SVP': if flag_train_svp <= 7: direction_item = int_direction_list[flag_train_svp] svp_vib_list = [] if direction_item == 1: print('Up') svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(1) elif direction_item == 2: print('Top Right') svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(0) elif direction_item == 3: print('Right') svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(1) svp_vib_list.append(0) elif direction_item == 4: print('Bottom Right') svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) elif direction_item == 5: print('Down') svp_vib_list.append(1) svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) elif direction_item == 6: print('Bottom Left') svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(0) elif direction_item == 7: print('Left') svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) else: print('Top Left') svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) try: _thread.start_new_thread(generate_vibration_simple, (svp_vib_list, 200)) except: print('SVP Square Train Error') flag_train_svp = flag_train_svp + 1 else: flag_train_svp = 0 else: int_distance_value = 40 if flag_train_atm <= 7: direction_item = int_direction_list[flag_train_atm] phantom_res_list, vib_duration = generate_tactile_brush_results( 1.0, int_distance_value, 200) start_vib_list = [] end_vib_list = [] if direction_item == 1: print('ATM Up') start_x = 0 start_y = 0 print('ATM Up END') end_x = 0 end_y = int_distance_value elif direction_item == 2: print('ATM Top Right') start_x = 0 start_y = 0 print('ATM Top Right END') end_x = int_distance_value end_y = int_distance_value elif direction_item == 3: print('ATM Right') start_x = 0 start_y = 0 print('ATM Right END') end_x = int_distance_value end_y = 0 elif direction_item == 4: print('ATM Bottom Right') start_x = 0 start_y = int_distance_value print('ATM Bottom Right END') end_x = int_distance_value end_y = 0 elif direction_item == 5: print('ATM Down') start_x = int_distance_value start_y = int_distance_value print('ATM Down END') end_x = int_distance_value end_y = 0 elif direction_item == 6: print('ATM Bottom Left') start_x = int_distance_value start_y = int_distance_value print('ATM Bottom Left END') end_x = 0 end_y = 0 elif direction_item == 7: print('ATM Left') start_x = int_distance_value start_y = int_distance_value print('ATM Left END') end_x = 0 end_y = int_distance_value else: print('ATM Top Left') start_x = int_distance_value start_y = 0 print('ATM Top Left END') end_x = 0 end_y = int_distance_value for phantom_item in phantom_res_list: if int(start_x) == phantom_item[0] and int( start_y) == phantom_item[1]: start_vib_list.append(int(start_x)) start_vib_list.append(int(start_y)) start_vib_list.append(phantom_item[2]) start_vib_list.append(phantom_item[3]) start_vib_list.append(phantom_item[4]) start_vib_list.append(phantom_item[5]) start_vib_list.append(vib_duration) for phantom_item in phantom_res_list: if int(end_x) == phantom_item[0] and int( end_y) == phantom_item[1]: end_vib_list.append(int(end_x)) end_vib_list.append(int(end_y)) end_vib_list.append(phantom_item[2]) end_vib_list.append(phantom_item[3]) end_vib_list.append(phantom_item[4]) end_vib_list.append(phantom_item[5]) end_vib_list.append(vib_duration) time_SOA = generate_SOA(200, vib_duration) try: _thread.start_new_thread( generate_atm_arduino, (start_vib_list, end_vib_list, time_SOA)) except: print('ATM Square Train Error!') flag_train_atm = flag_train_atm + 1 else: flag_train_atm = 0 else: print('Train Cross') if ti_value == 'SVP': if flag_train_svp <= 7: direction_item = int_direction_list[flag_train_svp] svp_vib_list = [] if direction_item == 1: print('Up') svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) elif direction_item == 2: print('Top Right') svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(1) elif direction_item == 3: print('Right') svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(0) elif direction_item == 4: print('Bottom Right') svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(1) svp_vib_list.append(0) elif direction_item == 5: print('Down') svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) elif direction_item == 6: print('Bottom Left') svp_vib_list.append(1) svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) elif direction_item == 7: print('Left') svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(0) else: print('Top Left') svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) try: _thread.start_new_thread(generate_vibration_simple, (svp_vib_list, 200)) except: print('SVP Cross Train Error') flag_train_svp = flag_train_svp + 1 else: flag_train_svp = 0 else: int_distance_value = 40 if flag_train_atm <= 7: direction_item = int_direction_list[flag_train_atm] phantom_res_list, vib_duration = generate_tactile_brush_results( 1.0, int_distance_value, 200) start_vib_list = [] end_vib_list = [] if direction_item == 1: print('ATM Up') start_x = int_distance_value start_y = 0 print('ATM Up END') end_x = 0 end_y = int_distance_value elif direction_item == 2: print('ATM Top Right') start_x = 0 start_y = 0 print('ATM Top Right END') end_x = 0 end_y = int_distance_value elif direction_item == 3: print('ATM Right') start_x = 0 start_y = 0 print('ATM Right END') end_x = int_distance_value end_y = int_distance_value elif direction_item == 4: print('ATM Bottom Right') start_x = 0 start_y = 0 print('ATM Bottom Right END') end_x = int_distance_value end_y = 0 elif direction_item == 5: print('ATM Down') start_x = 0 start_y = int_distance_value print('ATM Down END') end_x = int_distance_value end_y = 0 elif direction_item == 6: print('ATM Bottom Left') start_x = int_distance_value start_y = int_distance_value print('ATM Bottom Left END') end_x = int_distance_value end_y = 0 elif direction_item == 7: print('ATM Left') start_x = int_distance_value start_y = int_distance_value print('ATM Left END') end_x = 0 end_y = 0 else: print('ATM Top Left') start_x = int_distance_value start_y = int_distance_value print('ATM Top Left END') end_x = 0 end_y = int_distance_value for phantom_item in phantom_res_list: if int(start_x) == phantom_item[0] and int( start_y) == phantom_item[1]: start_vib_list.append(int(start_x)) start_vib_list.append(int(start_y)) start_vib_list.append(phantom_item[2]) start_vib_list.append(phantom_item[3]) start_vib_list.append(phantom_item[4]) start_vib_list.append(phantom_item[5]) start_vib_list.append(vib_duration) for phantom_item in phantom_res_list: if int(end_x) == phantom_item[0] and int( end_y) == phantom_item[1]: end_vib_list.append(int(end_x)) end_vib_list.append(int(end_y)) end_vib_list.append(phantom_item[2]) end_vib_list.append(phantom_item[3]) end_vib_list.append(phantom_item[4]) end_vib_list.append(phantom_item[5]) end_vib_list.append(vib_duration) time_SOA = generate_SOA(200, vib_duration) try: _thread.start_new_thread( generate_atm_arduino, (start_vib_list, end_vib_list, time_SOA)) except: print('ATM Train Error!') flag_train_atm = flag_train_atm + 1 else: flag_train_atm = 0
def click_btn_start_vib(): participant_value = txt_participant.get() block_value = v_block.get() ti_value = v_technique.get() order_value = v_order.get() order_arr = order_value.strip('(').strip(')').split(', ') global flag_svp global flag_atm if block_value == 'A': position_value = 'Hand' layout_value = 'Square' elif block_value == 'B': position_value = 'Hand' layout_value = 'Cross' elif block_value == 'C': position_value = 'FingerHand' layout_value = 'Square' else: position_value = 'FingerHand' layout_value = 'Cross' if layout_value == 'Square': print('Square') if ti_value == 'SVP': if flag_svp <= 23: result_list = [] direction_value = order_arr[flag_svp] result_list.append(participant_value) result_list.append(position_value) result_list.append(layout_value) result_list.append(ti_value) result_list.append(direction_value) v_result.set(result_list) int_direction_value = int(direction_value) svp_vib_list = [] if int_direction_value == 1: print('Up') svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(1) elif int_direction_value == 2: print('Top Right') svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(0) elif int_direction_value == 3: print('Right') svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(1) svp_vib_list.append(0) elif int_direction_value == 4: print('Bottom Right') svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) elif int_direction_value == 5: print('Down') svp_vib_list.append(1) svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) elif int_direction_value == 6: print('Bottom Left') svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(0) elif int_direction_value == 7: print('Left') svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) else: print('Top Left') svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) try: _thread.start_new_thread(generate_vibration_simple, (svp_vib_list, 200)) except: print('Square SVP Error') flag_svp = flag_svp + 1 else: print('Max Square SVP Value') else: if flag_atm <= 23: int_distance_value = 40 result_list = [] direction_value = order_arr[flag_atm] result_list.append(participant_value) result_list.append(position_value) result_list.append(layout_value) result_list.append(ti_value) result_list.append(direction_value) v_result.set(result_list) int_direction_value = int(direction_value) phantom_res_list, vib_duration = generate_tactile_brush_results( 1.0, int_distance_value, 200) start_vib_list = [] end_vib_list = [] if int_direction_value == 1: print('ATM Up') start_x = 0 start_y = 0 print('ATM Up END') end_x = 0 end_y = int_distance_value elif int_direction_value == 2: print('ATM Top Right') start_x = 0 start_y = 0 print('ATM Top Right END') end_x = int_distance_value end_y = int_distance_value elif int_direction_value == 3: print('ATM Right') start_x = 0 start_y = 0 print('ATM Right END') end_x = int_distance_value end_y = 0 elif int_direction_value == 4: print('ATM Bottom Right') start_x = 0 start_y = int_distance_value print('ATM Bottom Right END') end_x = int_distance_value end_y = 0 elif int_direction_value == 5: print('ATM Down') start_x = int_distance_value start_y = int_distance_value print('ATM Down END') end_x = int_distance_value end_y = 0 elif int_direction_value == 6: print('ATM Bottom Left') start_x = int_distance_value start_y = int_distance_value print('ATM Bottom Left END') end_x = 0 end_y = 0 elif int_direction_value == 7: print('ATM Left') start_x = int_distance_value start_y = int_distance_value print('ATM Left END') end_x = 0 end_y = int_distance_value else: print('ATM Top Left') start_x = int_distance_value start_y = 0 print('ATM Top Left END') end_x = 0 end_y = int_distance_value for phantom_item in phantom_res_list: if int(start_x) == phantom_item[0] and int( start_y) == phantom_item[1]: start_vib_list.append(int(start_x)) start_vib_list.append(int(start_y)) start_vib_list.append(phantom_item[2]) start_vib_list.append(phantom_item[3]) start_vib_list.append(phantom_item[4]) start_vib_list.append(phantom_item[5]) start_vib_list.append(vib_duration) for phantom_item in phantom_res_list: if int(end_x) == phantom_item[0] and int( end_y) == phantom_item[1]: end_vib_list.append(int(end_x)) end_vib_list.append(int(end_y)) end_vib_list.append(phantom_item[2]) end_vib_list.append(phantom_item[3]) end_vib_list.append(phantom_item[4]) end_vib_list.append(phantom_item[5]) end_vib_list.append(vib_duration) time_SOA = generate_SOA(200, vib_duration) try: _thread.start_new_thread( generate_atm_arduino, (start_vib_list, end_vib_list, time_SOA)) except: print('Square ATM Error!') flag_atm = flag_atm + 1 else: print('Max Square ATM Value') else: print('Cross') if ti_value == 'SVP': if flag_svp <= 23: result_list = [] direction_value = order_arr[flag_svp] result_list.append(participant_value) result_list.append(position_value) result_list.append(layout_value) result_list.append(ti_value) result_list.append(direction_value) v_result.set(result_list) int_direction_value = int(direction_value) svp_vib_list = [] if int_direction_value == 1: print('Up') svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) elif int_direction_value == 2: print('Top Right') svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(1) elif int_direction_value == 3: print('Right') svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(0) elif int_direction_value == 4: print('Bottom Right') svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(1) svp_vib_list.append(0) elif int_direction_value == 5: print('Down') svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) elif int_direction_value == 6: print('Bottom Left') svp_vib_list.append(1) svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) elif int_direction_value == 7: print('Left') svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(0) else: print('Top Left') svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) try: _thread.start_new_thread(generate_vibration_simple, (svp_vib_list, 200)) except: print('Cross SVP Error') flag_svp = flag_svp + 1 else: print('Max Cross SVP Value') else: if flag_atm <= 23: int_distance_value = 40 result_list = [] direction_value = order_arr[flag_atm] result_list.append(participant_value) result_list.append(position_value) result_list.append(layout_value) result_list.append(ti_value) result_list.append(direction_value) v_result.set(result_list) int_direction_value = int(direction_value) phantom_res_list, vib_duration = generate_tactile_brush_results( 1.0, int_distance_value, 200) start_vib_list = [] end_vib_list = [] if int_direction_value == 1: print('ATM Up') start_x = int_distance_value start_y = 0 print('ATM Up END') end_x = 0 end_y = int_distance_value elif int_direction_value == 2: print('ATM Top Right') start_x = 0 start_y = 0 print('ATM Top Right END') end_x = 0 end_y = int_distance_value elif int_direction_value == 3: print('ATM Right') start_x = 0 start_y = 0 print('ATM Right END') end_x = int_distance_value end_y = int_distance_value elif int_direction_value == 4: print('ATM Bottom Right') start_x = 0 start_y = 0 print('ATM Bottom Right END') end_x = int_distance_value end_y = 0 elif int_direction_value == 5: print('ATM Down') start_x = 0 start_y = int_distance_value print('ATM Down END') end_x = int_distance_value end_y = 0 elif int_direction_value == 6: print('ATM Bottom Left') start_x = int_distance_value start_y = int_distance_value print('ATM Bottom Left END') end_x = int_distance_value end_y = 0 elif int_direction_value == 7: print('ATM Left') start_x = int_distance_value start_y = int_distance_value print('ATM Left END') end_x = 0 end_y = 0 else: print('ATM Top Left') start_x = int_distance_value start_y = int_distance_value print('ATM Top Left END') end_x = 0 end_y = int_distance_value for phantom_item in phantom_res_list: if int(start_x) == phantom_item[0] and int( start_y) == phantom_item[1]: start_vib_list.append(int(start_x)) start_vib_list.append(int(start_y)) start_vib_list.append(phantom_item[2]) start_vib_list.append(phantom_item[3]) start_vib_list.append(phantom_item[4]) start_vib_list.append(phantom_item[5]) start_vib_list.append(vib_duration) for phantom_item in phantom_res_list: if int(end_x) == phantom_item[0] and int( end_y) == phantom_item[1]: end_vib_list.append(int(end_x)) end_vib_list.append(int(end_y)) end_vib_list.append(phantom_item[2]) end_vib_list.append(phantom_item[3]) end_vib_list.append(phantom_item[4]) end_vib_list.append(phantom_item[5]) end_vib_list.append(vib_duration) time_SOA = generate_SOA(200, vib_duration) try: _thread.start_new_thread( generate_atm_arduino, (start_vib_list, end_vib_list, time_SOA)) except: print('Cross ATM Error!') flag_atm = flag_atm + 1 else: print('Max Cross ATM Value')
def click_btn_start_vib(): duration_value = v_duration.get() order_value = v_label_order.get() technique_value = v_technique.get() order_arr = order_value.strip('(').strip(')').split(', ') global flag_svp global flag_atm if technique_value == 'SVP': if flag_svp <= 15: direction_value = order_arr[flag_svp] result_list = [] result_list.append(str(duration_value)) result_list.append(technique_value) result_list.append(direction_value) v_result.set(result_list) int_direction_value = int(direction_value) svp_vib_list = [] if int_direction_value == 1: print('Up') svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(1) elif int_direction_value == 2: print('Top Right') svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(0) elif int_direction_value == 3: print('Right') svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(1) svp_vib_list.append(0) elif int_direction_value == 4: print('Bottom Right') svp_vib_list.append(0) svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) elif int_direction_value == 5: print('Down') svp_vib_list.append(1) svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) elif int_direction_value == 6: print('Bottom Left') svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(0) elif int_direction_value == 7: print('Left') svp_vib_list.append(1) svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) else: print('Top Left') svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(0) svp_vib_list.append(1) try: _thread.start_new_thread( generate_vibration_simple, (svp_vib_list, int(duration_value))) except: print('SVP Error') flag_svp = flag_svp + 1 else: print('Max SVP Value') else: if flag_atm <= 15: int_distance_value = 40 direction_value = order_arr[flag_atm] result_list = [] result_list.append(duration_value) result_list.append(technique_value) result_list.append(direction_value) v_result.set(result_list) int_direction_value = int(direction_value) phantom_res_list, vib_duration = generate_tactile_brush_results( 1.0, int_distance_value, int(duration_value)) start_vib_list = [] end_vib_list = [] if int_direction_value == 1: print('ATM Up') start_x = 0 start_y = 0 print('ATM Up END') end_x = 0 end_y = int_distance_value elif int_direction_value == 2: print('ATM Top Right') start_x = 0 start_y = 0 print('ATM Top Right END') end_x = int_distance_value end_y = int_distance_value elif int_direction_value == 3: print('ATM Right') start_x = 0 start_y = 0 print('ATM Right END') end_x = int_distance_value end_y = 0 elif int_direction_value == 4: print('ATM Bottom Right') start_x = 0 start_y = int_distance_value print('ATM Bottom Right END') end_x = int_distance_value end_y = 0 elif int_direction_value == 5: print('ATM Down') start_x = int_distance_value start_y = int_distance_value print('ATM Down END') end_x = int_distance_value end_y = 0 elif int_direction_value == 6: print('ATM Bottom Left') start_x = int_distance_value start_y = int_distance_value print('ATM Bottom Left END') end_x = 0 end_y = 0 elif int_direction_value == 7: print('ATM Left') start_x = int_distance_value start_y = int_distance_value print('ATM Left END') end_x = 0 end_y = int_distance_value else: print('ATM Top Left') start_x = int_distance_value start_y = 0 print('ATM Top Left END') end_x = 0 end_y = int_distance_value for phantom_item in phantom_res_list: if int(start_x) == phantom_item[0] and int( start_y) == phantom_item[1]: start_vib_list.append(int(start_x)) start_vib_list.append(int(start_y)) start_vib_list.append(phantom_item[2]) start_vib_list.append(phantom_item[3]) start_vib_list.append(phantom_item[4]) start_vib_list.append(phantom_item[5]) start_vib_list.append(vib_duration) for phantom_item in phantom_res_list: if int(end_x) == phantom_item[0] and int( end_y) == phantom_item[1]: end_vib_list.append(int(end_x)) end_vib_list.append(int(end_y)) end_vib_list.append(phantom_item[2]) end_vib_list.append(phantom_item[3]) end_vib_list.append(phantom_item[4]) end_vib_list.append(phantom_item[5]) end_vib_list.append(vib_duration) time_SOA = generate_SOA(int(duration_value), vib_duration) try: _thread.start_new_thread( generate_atm_arduino, (start_vib_list, end_vib_list, time_SOA)) except: print('ATM Error!') flag_atm = flag_atm + 1 else: print('Max ATM Value')
def click_btn_train_atm(): int_distance_value = 40 int_direction_list = [1, 2, 3, 4, 5, 6, 7, 8] global flag_train_atm if flag_train_atm <= 7: direction_item = int_direction_list[flag_train_atm] phantom_res_list, vib_duration = generate_tactile_brush_results( 1.0, int_distance_value, int(v_duration.get())) start_vib_list = [] end_vib_list = [] if direction_item == 1: print('ATM Up') start_x = 0 start_y = 0 print('ATM Up END') end_x = 0 end_y = int_distance_value elif direction_item == 2: print('ATM Top Right') start_x = 0 start_y = 0 print('ATM Top Right END') end_x = int_distance_value end_y = int_distance_value elif direction_item == 3: print('ATM Right') start_x = 0 start_y = 0 print('ATM Right END') end_x = int_distance_value end_y = 0 elif direction_item == 4: print('ATM Bottom Right') start_x = 0 start_y = int_distance_value print('ATM Bottom Right END') end_x = int_distance_value end_y = 0 elif direction_item == 5: print('ATM Down') start_x = int_distance_value start_y = int_distance_value print('ATM Down END') end_x = int_distance_value end_y = 0 elif direction_item == 6: print('ATM Bottom Left') start_x = int_distance_value start_y = int_distance_value print('ATM Bottom Left END') end_x = 0 end_y = 0 elif direction_item == 7: print('ATM Left') start_x = int_distance_value start_y = int_distance_value print('ATM Left END') end_x = 0 end_y = int_distance_value else: print('ATM Top Left') start_x = int_distance_value start_y = 0 print('ATM Top Left END') end_x = 0 end_y = int_distance_value for phantom_item in phantom_res_list: if int(start_x) == phantom_item[0] and int( start_y) == phantom_item[1]: start_vib_list.append(int(start_x)) start_vib_list.append(int(start_y)) start_vib_list.append(phantom_item[2]) start_vib_list.append(phantom_item[3]) start_vib_list.append(phantom_item[4]) start_vib_list.append(phantom_item[5]) start_vib_list.append(vib_duration) for phantom_item in phantom_res_list: if int(end_x) == phantom_item[0] and int( end_y) == phantom_item[1]: end_vib_list.append(int(end_x)) end_vib_list.append(int(end_y)) end_vib_list.append(phantom_item[2]) end_vib_list.append(phantom_item[3]) end_vib_list.append(phantom_item[4]) end_vib_list.append(phantom_item[5]) end_vib_list.append(vib_duration) time_SOA = generate_SOA(int(v_duration.get()), vib_duration) try: _thread.start_new_thread( generate_atm_arduino, (start_vib_list, end_vib_list, time_SOA)) except: print('ATM Train Error!') flag_train_atm = flag_train_atm + 1 else: flag_train_atm = 0
def start_atm(int_direction): distance = 20 no_direction = int_direction phantom_res_list, vib_duration = generate_tactile_brush_results(1.0, distance, 500) start_vib_list = [] end_vib_list = [] temp_start_x = 0 temp_start_y = 0 temp_end_x = 0 temp_end_y = 0 if no_direction == 1: print('!!!!!!!!!!!!!!!!!!----1') temp_start_x = 0 temp_start_y = 0 temp_end_x = distance temp_end_y = 0 elif no_direction == 2: print('!!!!!!!!!!!!!!!!!!----2') temp_start_x = 0 temp_start_y = 0 temp_end_x = 0 temp_end_y = distance elif no_direction == 3: print('!!!!!!!!!!!!!!!!!!----3') temp_start_x = 0 temp_start_y = 0 temp_end_x = distance temp_end_y = distance elif no_direction == 4: print('!!!!!!!!!!!!!!!!!!----4') temp_start_x = 0 temp_start_y = distance temp_end_x = distance temp_end_y = 0 if no_direction != 0: for phantom_item in phantom_res_list: if temp_start_x == phantom_item[0] and temp_start_y == phantom_item[1]: start_vib_list.append(temp_start_x) start_vib_list.append(temp_start_y) start_vib_list.append(phantom_item[2]) start_vib_list.append(phantom_item[3]) start_vib_list.append(phantom_item[4]) start_vib_list.append(phantom_item[5]) start_vib_list.append(vib_duration) for phantom_item_end in phantom_res_list: if temp_end_x == phantom_item_end[0] and temp_end_y == phantom_item_end[1]: end_vib_list.append(temp_end_x) end_vib_list.append(temp_end_y) end_vib_list.append(phantom_item_end[2]) end_vib_list.append(phantom_item_end[3]) end_vib_list.append(phantom_item_end[4]) end_vib_list.append(phantom_item_end[5]) end_vib_list.append(vib_duration) time_SOA = generate_SOA(500, vib_duration) try: #_thread.start_new_thread(stop_all_vibration_arduino, ()) _thread.start_new_thread(generate_atm_arduino, (start_vib_list, end_vib_list, time_SOA)) # _thread.start_new_thread(generate_atm_arduino, (end_vib_list, start_vib_list, time_SOA)) except: print('Infrared ATM error') print('Start Vib List: ') print(start_vib_list) print('End Vib List: ') print(end_vib_list) '''else:
def start_atm(): phantom_res_list, vib_duration = generate_tactile_brush_results( float(str(v.get())), int(str(txt_distance.get())), int(str(txt_T.get()))) start_vib_list = [] temp_start_x = 0 temp_start_y = 0 if tac_1_check_btn.get() == 1: temp_start_x = 0 temp_start_y = 0 elif tac_2_check_btn.get() == 1: temp_start_x = int(txt_distance.get()) temp_start_y = 0 elif tac_3_check_btn.get() == 1: temp_start_x = int(txt_distance.get()) temp_start_y = int(txt_distance.get()) elif tac_4_check_btn.get() == 1: temp_start_x = 0 temp_start_y = int(txt_distance.get()) for phantom_item in phantom_res_list: # print(phantom_item) if int(temp_start_x) == phantom_item[0] and int( temp_start_y) == phantom_item[1]: start_vib_list.append(int(temp_start_x)) start_vib_list.append(int(temp_start_y)) start_vib_list.append(phantom_item[2]) start_vib_list.append(phantom_item[3]) start_vib_list.append(phantom_item[4]) start_vib_list.append(phantom_item[5]) start_vib_list.append(vib_duration) print(start_vib_list) end_vib_list = [] if tac_1_check_btn_end.get() == 0 and tac_2_check_btn_end.get( ) == 0 and tac_3_check_btn_end.get() == 0 and tac_4_check_btn_end.get( ) == 0: if int(txt_end_x.get()) != temp_start_x and int( txt_end_y.get()) != temp_start_y: for phantom_item in phantom_res_list: # print(phantom_item) if int(txt_end_x.get()) == phantom_item[0] and int( txt_end_y.get()) == phantom_item[1]: end_vib_list.append(int(txt_end_x.get())) end_vib_list.append(int(txt_end_y.get())) end_vib_list.append(phantom_item[2]) end_vib_list.append(phantom_item[3]) end_vib_list.append(phantom_item[4]) end_vib_list.append(phantom_item[5]) #end_vib_list.append(int(str(txt_T.get()))) else: print('Can not choose this point') return 0 else: temp_end_x = 0 temp_end_y = 0 if tac_1_check_btn_end.get() == 1: temp_end_x = 0 temp_end_y = 0 elif tac_2_check_btn_end.get() == 1: temp_end_x = int(txt_distance.get()) temp_end_y = 0 elif tac_3_check_btn_end.get() == 1: temp_end_x = int(txt_distance.get()) temp_end_y = int(txt_distance.get()) elif tac_4_check_btn_end.get() == 1: temp_end_x = 0 temp_end_y = int(txt_distance.get()) for phantom_item in phantom_res_list: # print(phantom_item) if int(temp_end_x) == phantom_item[0] and int( temp_end_y) == phantom_item[1]: end_vib_list.append(int(temp_end_x)) end_vib_list.append(int(temp_end_y)) end_vib_list.append(phantom_item[2]) end_vib_list.append(phantom_item[3]) end_vib_list.append(phantom_item[4]) end_vib_list.append(phantom_item[5]) end_vib_list.append(vib_duration) change_color_tactor(start_vib_list) change_color_tactor(end_vib_list) print('66666666666666') print(vib_duration) print(end_vib_list) time_SOA = generate_SOA(int(str(txt_T.get())), vib_duration) try: _thread.start_new_thread( generate_atm_arduino_without_single_vibration, (start_vib_list, end_vib_list, time_SOA)) except: print('Start thread exception')