|
|
(6).在"快速移动"事件下的G43 G0 G90 rap3 B C H1 M8行下面添加一个新行
G0 G90 文本元素 B C,将文本元素内容改成X$sx Y$sy Z$sz,添加输出
条件PB__CMD_check_block_rapid_move2,编辑TCL代码如下:
global dpp_path_type
global e1 e2 e3
global d1 d2 d3
global vx vy vz
global w1 w2 w3
global s s1 s2 s3 s4
global sx sy sz
global mom_out_angle_pos
global mom_pos
global rad_b rad_c
if {![string compare "5X" $dpp_path_type]} {
set rad_b [expr $mom_out_angle_pos(0)*0.01745329252]
set rad_c [expr $mom_out_angle_pos(1)*0.01745329252]
#****************************Calculate X******************************
# X = [cos4*cos5-1]*#101 + [cos4*sin5]*#102 + [-sin4]*#103 + [x]
set e1 [expr cos($rad_b)*cos($rad_c)-1.0]
set e2 [expr cos($rad_b)*sin($rad_c)]
set e3 [expr -1.0*sin($rad_b)]
set d1 [expr round($e1*1000000.0)/1000000.0]
set d2 [expr round($e2*1000000.0)/1000000.0]
set d3 [expr round($e3*1000000.0)/1000000.0]
set vx [expr round($mom_pos(0)*10000.0)/10000.0]
#////////////////////////w1/////////////////////////
set w1 [format "%.6f" $d1]
if {![string compare "-1.000000" $w1]} {
set s1 "-#101"
} elseif {![string compare "1.000000" $w1]} {
set s1 "#101"
} else {
if {[string index $w1 end-0] == "0"} {
if {[string index $w1 end-1] == "0"} {
if {[string index $w1 end-2] == "0"} {
if {[string index $w1 end-3] == "0"} {
if {[string index $w1 end-4] == "0"} {
if {[string index $w1 end-5] == "0"} {
set w1 [format "%d." [expr round($d1)]]
} else {
set w1 [format "%.1f" $d1]
}
} else {
set w1 [format "%.2f" $d1]
}
} else {
set w1 [format "%.3f" $d1]
}
} else {
set w1 [format "%.4f" $d1]
}
} else {
set w1 [format "%.5f" $d1]
}
}
if {$d1 != 0.0} {
set s1 [format "%s*#101" $w1]
} else {
set s1 "NONE"
}
}
#////////////////////////w2/////////////////////////
set w2 [format "%.6f" $d2]
if {![string compare "-1.000000" $w2]} {
set s2 "-#102"
} elseif {![string compare "1.000000" $w2]} {
set s2 "+#102"
} else {
if {[string index $w2 end-0] == "0"} {
if {[string index $w2 end-1] == "0"} {
if {[string index $w2 end-2] == "0"} {
if {[string index $w2 end-3] == "0"} {
if {[string index $w2 end-4] == "0"} {
if {[string index $w2 end-5] == "0"} {
set w2 [format "%d." [expr round($d2)]]
} else {
set w2 [format "%.1f" $d2]
}
} else {
set w2 [format "%.2f" $d2]
}
} else {
set w2 [format "%.3f" $d2]
}
} else {
set w2 [format "%.4f" $d2]
}
} else {
set w2 [format "%.5f" $d2]
}
}
if {$d2 > 0.0} {
set s2 [format "+%s*#102" $w2]
} elseif {$d2 < 0.0} {
set s2 [format "%s*#102" $w2]
} else {
set s2 "NONE"
}
}
#////////////////////////w3/////////////////////////
set w3 [format "%.6f" $d3]
if {![string compare "-1.000000" $w3]} {
set s3 "-#103"
} elseif {![string compare "1.000000" $w3]} {
set s3 "+#103"
} else {
if {[string index $w3 end-0] == "0"} {
if {[string index $w3 end-1] == "0"} {
if {[string index $w3 end-2] == "0"} {
if {[string index $w3 end-3] == "0"} {
if {[string index $w3 end-4] == "0"} {
if {[string index $w3 end-5] == "0"} {
set w3 [format "%d." [expr round($d3)]]
} else {
set w3 [format "%.1f" $d3]
}
} else {
set w3 [format "%.2f" $d3]
}
} else {
set w3 [format "%.3f" $d3]
}
} else {
set w3 [format "%.4f" $d3]
}
} else {
set w3 [format "%.5f" $d3]
}
}
if {$d3 > 0.0} {
set s3 [format "+%s*#103" $w3]
} elseif {$d3 < 0.0} {
set s3 [format "%s*#103" $w3]
} else {
set s3 "NONE"
}
}
#////////////////////////w4/////////////////////////
set w4 [format "%.4f" $vx]
if {[string index $w4 end-0] == "0"} {
if {[string index $w4 end-1] == "0"} {
if {[string index $w4 end-2] == "0"} {
if {[string index $w4 end-3] == "0"} {
set w4 [format "%d." [expr round($vx)]]
} else {
set w4 [format "%.1f" $vx]
}
} else {
set w4 [format "%.2f" $vx]
}
} else {
set w4 [format "%.3f" $vx]
}
}
if {$vx > 0.0} {
set s4 [format "+%s" $w4]
} elseif {$vx < 0.0} {
set s4 [format "%s" $w4]
} else {
set s4 "NONE"
}
#///////////////////////////////////////////////////////sy///////////////////////////////////////////////////////
if {[string compare "NONE" $s1] && [string compare "NONE" $s2] && [string compare "NONE" $s3]} {
set s [format "%s%s%s" $s1 $s2 $s3]
} elseif {[string compare "NONE" $s1] && ![string compare "NONE" $s2] && ![string compare "NONE" $s3]} {
set s $s1
} elseif {![string compare "NONE" $s1] && [string compare "NONE" $s2] && ![string compare "NONE" $s3]} {
set s $s2
} elseif {![string compare "NONE" $s1] && ![string compare "NONE" $s2] && [string compare "NONE" $s3]} {
set s $s3
} elseif {[string compare "NONE" $s1] && [string compare "NONE" $s2] && ![string compare "NONE" $s3]} {
set s [format "%s%s" $s1 $s2]
} elseif {[string compare "NONE" $s1] && ![string compare "NONE" $s2] && [string compare "NONE" $s3]} {
set s [format "%s%s" $s1 $s3]
} elseif {![string compare "NONE" $s1] && [string compare "NONE" $s2] && [string compare "NONE" $s3]} {
set s [format "%s%s" $s2 $s3]
} else {
set s "NONE"
}
if {[string compare "NONE" $s] && [string compare "NONE" $s4]} {
set sx [format "\[%s%s\]" $s $s4]
} elseif {![string compare "NONE" $s] && [string compare "NONE" $s4]} {
set sx $s4
} elseif {[string compare "NONE" $s] && ![string compare "NONE" $s4]} {
set sx [format "\[%s\]" $s]
} else {
set sx "0."
}
#******************Calculate Y**********************
# Y = [-sin5]*#101 + [cos5-1]*#102 + [y]
set e1 [expr -1.0*sin($rad_c)]
set e2 [expr cos($rad_c)-1.0]
set d1 [expr round($e1*1000000.0)/1000000.0]
set d2 [expr round($e2*1000000.0)/1000000.0]
set vy [expr round($mom_pos(1)*10000.0)/10000.0]
未完待续。。。。
|
|