#---------------------
# 全局变量声明
#---------------------
global mom_tool_name
global mom_tool_diameter
global mom_tool_corner1_radius
global mom_tool_lower_corner_radius
global mom_tool_type
global mom_tool_number
global mom_tool_taper_angle
global mom_tool_point_angle
global mom_tool_adjust_register
global mom_tool_cutcom_register
global mom_tool_diameter_defined
global mom_tool_diameter_nominal
#---------------------
# 补偿号赋值
#-----------------------
set H_code $mom_tool_adjust_register
# 安全获取D_code
if {[info exists mom_tool_cutcom_register] && $mom_tool_cutcom_register != ""} {
set D_code $mom_tool_cutcom_register
} else {
set D_code ""
}
# 全局变量声明
global mom_operation_type # 当前加工操作类型
global mom_stock_part # 侧面余量(XY方向)
global mom_stock_floor # 底面余量(Z方向)
global mom_wall_stock # 壁余量
global mom_tool_cutcom_register # 刀具补偿寄存器
global mom_stock_part_use # 余量同步标志
# 余量同步处理
if {[info exists mom_stock_part_use] && $mom_stock_part_use} {
set mom_stock_floor $mom_stock_part
}
# 壁余量特殊处理
if {[info exists mom_wall_stock]} {
if {$mom_wall_stock != 0} {
set mom_stock_part $mom_wall_stock
}
}
# 仅对非点钻类操作处理
if {$mom_operation_type ni {"Point to Point" "Drilling"}} {
set fmt "%.3f"
# 格式化XY余量
set xy_val [expr {double($mom_stock_part)}]
set xy [string trimright [format $fmt $xy_val] "0"]
if {[string first "." $xy] == -1} { append xy "." }
if {$xy eq "."} { set xy "0." }
# 格式化Z余量
set z_val [expr {double($mom_stock_floor)}]
set z [string trimright [format $fmt $z_val] "0"]
if {[string first "." $z] == -1} { append z "." }
if {$z eq "."} { set z "0." }
# 输出逻辑
if {[info exists mom_tool_cutcom_register] && $mom_tool_cutcom_register != 0} {
# 有有效刀补时显示寄存器号(刀具补偿寄存器为大于0的整数,显示刀具补偿寄存器数值)
set msg "D.N=D[format %1.0f $mom_tool_cutcom_register] XY=$xy mm Z=$z mm"
} else {
# 无刀补或刀具补偿寄存器为0时只显示 X Y 余量
set msg "XY=$xy mm Z=$z mm"
}