增加了HSMO整线优化方法,读取数据增加了供料器部分
This commit is contained in:
@@ -355,15 +355,12 @@ def output_optimize_result(file_path, component_data, pcb_data, optimizer_result
|
||||
if 'desc' not in output_data.columns:
|
||||
column_index = int(np.where(output_data.columns.values.reshape(-1) == 'part')[0][0])
|
||||
output_data.insert(loc=column_index + 1, column='desc', value='')
|
||||
file_dir = file_path[:file_path.rfind('/') + 1]
|
||||
if not os.path.exists(file_dir):
|
||||
os.makedirs(file_dir)
|
||||
|
||||
output_data.to_excel(file_path + '.xlsx', sheet_name='tb1', float_format='%.3f', na_rep='')
|
||||
output_data.to_csv('result/' + file_path + '.txt', sep='\t', float_format='%.3f', header=False, index=False)
|
||||
|
||||
|
||||
def optimization_assign_result(component_data, pcb_data, optimizer_result, nozzle_hinter=False, component_hinter=False,
|
||||
feeder_hinter=False):
|
||||
feeder_hinter=False, placement_hinter=False):
|
||||
if nozzle_hinter:
|
||||
columns = ['H{}'.format(i + 1) for i in range(max_head_index)] + ['cycle']
|
||||
|
||||
@@ -428,6 +425,29 @@ def optimization_assign_result(component_data, pcb_data, optimizer_result, nozzl
|
||||
print(feedr_assign)
|
||||
print('')
|
||||
|
||||
if placement_hinter:
|
||||
columns = ['H{}'.format(i + 1) for i in range(max_head_index)] + ['cycle']
|
||||
|
||||
placement_assign = pd.DataFrame(columns=columns)
|
||||
for cycle, _ in enumerate(optimizer_result.placement_assign):
|
||||
placement_assign.loc[cycle, 'cycle'] = 1
|
||||
for head in range(max_head_index):
|
||||
point = optimizer_result.placement_assign[cycle][head]
|
||||
if point != -1:
|
||||
placement_assign.loc[cycle, 'H{}'.format(head + 1)] = 'P{}'.format(point)
|
||||
else:
|
||||
placement_assign.loc[cycle, 'H{}'.format(head + 1)] = ''
|
||||
|
||||
headseq_assign = pd.DataFrame(columns=columns)
|
||||
for cycle, headseq in enumerate(optimizer_result.head_sequence):
|
||||
headseq_assign.loc[cycle, 'cycle'] = 1
|
||||
for head in range(len(headseq)):
|
||||
headseq_assign.loc[cycle, 'H{}'.format(head + 1)] = 'H{}'.format(headseq[head])
|
||||
|
||||
print(placement_assign)
|
||||
print(headseq_assign)
|
||||
print('')
|
||||
|
||||
|
||||
def placement_info_evaluation(component_data, pcb_data, optimizer_result, hinter=False):
|
||||
# === 优化结果参数 ===
|
||||
@@ -555,28 +575,43 @@ def placement_info_evaluation(component_data, pcb_data, optimizer_result, hinter
|
||||
|
||||
# 贴装路径
|
||||
if optimizer_result.placement_assign and optimizer_result.head_sequence:
|
||||
head_angle = [0 for _ in range(max_head_index)]
|
||||
for head in optimizer_result.head_sequence[cycle]:
|
||||
index = optimizer_result.placement_assign[cycle][head]
|
||||
if index == -1:
|
||||
continue
|
||||
mount_pos.append([pcb_data.iloc[index]['x'] - head * head_interval + stopper_pos[0],
|
||||
pcb_data.iloc[index]['y'] + stopper_pos[1]])
|
||||
mount_angle.append(pcb_data.iloc[index]['r'])
|
||||
head_angle[head] = pcb_data.iloc[index]['r']
|
||||
|
||||
# 单独计算贴装路径
|
||||
for cntPoints in range(len(mount_pos) - 1):
|
||||
info.place_distance += max(abs(mount_pos[cntPoints][0] - mount_pos[cntPoints + 1][0]),
|
||||
abs(mount_pos[cntPoints][1] - mount_pos[cntPoints + 1][1]))
|
||||
|
||||
if mount_pos[0][0] < mount_pos[-1][0]:
|
||||
mount_pos = reversed(mount_pos)
|
||||
|
||||
# 考虑R轴预旋转,补偿同轴角度转动带来的额外贴装用时
|
||||
info.operation_time += head_rotary_time(mount_angle[0]) # 补偿角度转动带来的额外贴装用时
|
||||
info.operation_time += t_nozzle_put * nozzle_put_counter + t_nozzle_pick * nozzle_pick_counter
|
||||
for idx, pos in enumerate(mount_pos):
|
||||
info.operation_time += t_place
|
||||
move_time = max(axis_moving_time(cur_pos[0] - pos[0], 0), axis_moving_time(cur_pos[1] - pos[1], 1))
|
||||
|
||||
if idx == 0:
|
||||
move_time = max(axis_moving_time(cur_pos[0] - pos[0], 0),
|
||||
axis_moving_time(cur_pos[1] - pos[1], 1))
|
||||
info.round_time += move_time
|
||||
else:
|
||||
|
||||
cur_head = optimizer_result.head_sequence[cycle][idx]
|
||||
side_head = cur_head - 1 if cur_head % 2 else cur_head + 1
|
||||
if optimizer_result.head_sequence[cycle][idx - 1] != side_head:
|
||||
move_time = max(axis_moving_time(cur_pos[0] - pos[0], 0),
|
||||
axis_moving_time(cur_pos[1] - pos[1], 1))
|
||||
else:
|
||||
move_time = max(axis_moving_time(cur_pos[0] - pos[0], 0),
|
||||
axis_moving_time(cur_pos[1] - pos[1], 1),
|
||||
head_rotary_time(head_angle[cur_head] - head_angle[side_head]))
|
||||
info.place_time += move_time
|
||||
|
||||
info.total_distance += max(abs(cur_pos[0] - pos[0]), abs(cur_pos[1] - pos[1]))
|
||||
@@ -594,5 +629,3 @@ def placement_info_evaluation(component_data, pcb_data, optimizer_result, hinter
|
||||
return info
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user