|
发表于 2016-11-24 16:01:23
|
显示全部楼层
MOM_set_seq_on
set outputthd 1
global toollist mom_tool_cutcom_register mom_cutcom_adjust_register mom_tool_name mom_tool_diameter mom_tool_corner1_radius mom_tool_adjust_register mom_tool_adj_reg_defined mom_tool_number
set tdi [ format "%.2f" $mom_tool_diameter]
set tr [ format "%.2f" $mom_tool_corner1_radius]
if [info exists mom_tool_number] {
set tt $mom_tool_number
} else {
set tt 0
}
if [info exists mom_tool_adj_reg_defined] {
set th $mom_tool_adjust_register
} else {
set th 0
}
if [info exists mom_tool_adj_reg_defined] {
set td $mom_tool_cutcom_register
} else {
set td 0
}
set tt [format "%02.0f" $tt]
set th [format "%02.0f" $th]
set td [format "%02.0f" $td]
set tt [format "%02.0f" $tt]
set th [format "%02.0f" $th]
set td [format "%02.0f" $td]
if {$outputthd == 1 } {
MOM_output_literal "(T$tt:$mom_tool_name D=$tdi R=$tr H$th D$td)"
} else {
MOM_output_literal "(T00:$mom_tool_name D=$tdi R=$tr H00 D$td)"
}
MOM_set_seq_off
global mom_spindle_rpm
global mom_feed_cut_value
global mom_stock_part side
global mom_stock_floor
global mom_stock use floor same as side
global mom_operation_type
global mom_motion_type
global mom_operation_name
set partstock 0
set floorstock 0
if [info exists mom_stock_floor] {
set partstock [format "%.2f" $mom_stock_part side]
set floorstock [format "%.2f" $mom_stock_floor]
}
if {$mom_operation_type == "point to point"} {
set partstock 0
set floorstock 0
}
MOM_output_literal "(RMP:[format $mom_operation_name] S[format "%.0f" $mom_spindle_rpm] F[format %.1f $mom_feed_cut_value])"
MOM_output_literal "(Part stock=[format "%.2f" $partstock]MM floor stock=[format "%.2f" $floorstock]MM)"
global ptp_file_name
set tmp_file_name "${ptp_file_name}_"
if {[file exists $tmp_file_name]} {
MOM_remove_file $tmp_file_name
}
MOM_close_output_file $ptp_file_name
file rename $ptp_file_name $tmp_file_name
set ifile [open $tmp_file_name r]
set ofile [open $ptp_file_name w]
puts $ofile "%"
global mom_part_name
#puts $ofile "(Part: $mom_part_name)"
global mom_date
set datee [clock format [clock seconds] -format "%Y/%m/%d %H:%M /%w"]
puts $ofile "($datee)"
global mom_output_file_basename
#puts $ofile "(NC name: $mom_output_file_basename.nc)"
global mom_machine_time
puts $ofile "(Machine time: [format "%.2f" $mom_machine_time] MIN)"
#puts $ofile "(Writer: Mr.Zhang Mobile:15853875606)"
global toollist
if { [info exists toollist] } {
foreach tool $toollist {
puts $ofile "($tool)"
}
}
set buf ""
while { [gets $ifile buf] > 0 } {
puts $ofile $buf
}
close $ifile
close $ofile
MOM_remove_file $tmp_file_name
MOM_open_output_file $ptp_file_name
global mom_fixture_offset_value
if {$mom_fixture_offset_value>5} {
MOM_output_literal "G00G90G54.1P[expr $mom_fixture_offset_value-5]"
} else {
MOM_output_literal "G00G90G[expr $mom_fixture_offset_value+54]"
}
global toollist mom_tool_name mom_tool_diameter mom_tool_corner1_radius mom_tool_number
set mom_tool_number [format "%02.0f" $mom_tool_number]
set tool_mes [format "%-10s %-15s %-15s" T$mom_tool_number=$mom_tool_name D=[ format "%.2f" $mom_tool_diameter ] R=[ format "%.2f" $mom_tool_corner1_radius ] ]
#if { ![info exists toollist] } {
# set toollist $tool_mes
#} else {
lappend toollist $tool_mes
#}
set outputthd 1
global toollist mom_tool_cutcom_register mom_cutcom_adjust_register mom_tool_name mom_tool_diameter mom_tool_corner1_radius mom_tool_adjust_register mom_tool_adj_reg_defined mom_tool_number
set tdi [ format "%.2f" $mom_tool_diameter]
set tr [ format "%.2f" $mom_tool_corner1_radius]
if [info exists mom_tool_number] {
set tt $mom_tool_number
} else {
set tt 0
}
if [info exists mom_tool_adj_reg_defined] {
set th $mom_tool_adjust_register
} else {
set th 0
}
if [info exists mom_tool_adj_reg_defined] {
set td $mom_tool_cutcom_register
} else {
set td 0
}
set tt [format "%02.0f" $tt]
set th [format "%02.0f" $th]
set td [format "%02.0f" $td]
set tt [format "%02.0f" $tt]
set th [format "%02.0f" $th]
set td [format "%02.0f" $td]
if {$outputthd == 1 } {
#MOM_output_literal "(T$tt:$mom_tool_name D=$tdi R=$tr H$th D$td)"
} else {
#MOM_output_literal "(T00:$mom_tool_name D=$tdi R=$tr H00 D$00)"
}
global toollist max_z min_z mom_tool_number mom_tool_name
global toollist mom_tool_name mom_tool_diameter mom_tool_corner1_radius mom_tool_number
set zmax [ string trimright [ format %.2f $max_z ]mm 0 ]
set zmin [ string trimright [ format %.2f $min_z ]mm 0 ]
set mom_tool_number [format "%02.0f" $mom_tool_number]
set tool_mes [format "%-8s %-8s %-8s" T$mom_tool_number:$mom_tool_name D=[ format "%.2f" $mom_tool_diameter ] R=[ format "%.2f" $mom_tool_corner1_radius ]\ \ \H$th\ \ \D$td\ \ \MaxZ=[ format %.2f $max_z ]mm\ \ \MinZ=[ format %.2f $min_z ]mm ]
#if { ![info exists toollist] } {
# set toollist $tool_mes
#} else {
lappend toollist $tool_mes
#}
global ptp_file_name
set tmp_file_name "${ptp_file_name}_"
if {[file exists $tmp_file_name]} {
MOM_remove_file $tmp_file_name
}
MOM_close_output_file $ptp_file_name
file rename $ptp_file_name $tmp_file_name
set ifile [open $tmp_file_name r]
set ofile [open $ptp_file_name w]
global max_z min_z mom_tool_number mom_tool_name
set zmax [ string trimright [ format %.2f $max_z ]mm 0 ]
set zmin [ string trimright [ format %.2f $min_z ]mm 0 ]
puts $ofile "([format "%-10s %-15s %-15s" T$mom_tool_number=$mom_tool_name MaxZ=[ format %.2f $max_z ]mm MinZ=[ format %.2f $min_z ]mm ])"
set buf ""
while { [gets $ifile buf] > 0 } {
puts $ofile $buf
}
close $ifile
close $ofile
MOM_remove_file $tmp_file_name
MOM_open_output_file $ptp_file_name |
|