Initial commit
This commit is contained in:
879
feeds_speeds/ascii/machining_data.tcl
Normal file
879
feeds_speeds/ascii/machining_data.tcl
Normal file
@@ -0,0 +1,879 @@
|
||||
# *MACHINING_DATA.TCL
|
||||
###############################################################################
|
||||
# machining_DATA.tcl - DBC Event Handler for database stored as ascii file
|
||||
###############################################################################
|
||||
# Revisions
|
||||
# Date Who Reason
|
||||
# 22Oct2003 rlm Initial
|
||||
# 26Jan2004 rlm Return integers for cut feed percentages
|
||||
# 26Jan2004 rlm remove rest of debugging code
|
||||
# 30Jan2004 rlm Move ASC_write to dbc_ascii_general
|
||||
# 12Feb2004 rlm Add library revision information
|
||||
# 25Jun2004 rlm Enhance data interpolation
|
||||
# 26Oct2004 rlm Enhance for import machining data func
|
||||
# 13Apr2005 rlm Expand hierarchy for retrieve record selection
|
||||
# 24Jan2006 rlm fix ratio computation protection
|
||||
# 18Mar2008 rlm add missing continuation on first
|
||||
# ASC_interpolate_data call
|
||||
# 14Jan2009 rlm Fix test protecting zero divide when
|
||||
# computing local_ratio
|
||||
# 10Feb2009 rlm Fix second line of previous rev
|
||||
# 24Mar2009 rlm apply holder offset to tool length
|
||||
# 18Feb2010 rlm Add test for single record diameter match
|
||||
# 23Jul2010 rlm 6384077 Fix global reference in first fallback test
|
||||
# 13Apr2011 Peter Mao 1842883 Ignore tool length adjustment if shank is defined
|
||||
# 16Aug2012 R. Miner 1908948 Perform all tests on all records
|
||||
# 26Oct2018 Shorbojeet Das PR#8340732: Add customization support for double precision control.
|
||||
# 08Nov2018 Updates
|
||||
# 07Jul2020 Benson Wang 9697869 Fix the issue that ASC_get_tool_projection_length can't get correct tool length
|
||||
# 18Aug2020 Jingzhao Zhang PR#9607517 Support exact match only for maching data
|
||||
################################################################################
|
||||
#
|
||||
# The format of each line in the text file is:
|
||||
#
|
||||
# libref optype ptmtl tlmtl speed feed
|
||||
#
|
||||
# libref is a string
|
||||
# optype is "Milling" "Turning" "Drilling"
|
||||
# ptmtl is code number for now
|
||||
# tlmtl is "HSS" "Carbide" "CBN"
|
||||
# depth is a double
|
||||
# speed is a double
|
||||
# feed is a double
|
||||
#
|
||||
# The DB_ID of a DB_ALIAS is its field number in the line (0-based)
|
||||
###############################################################################
|
||||
#MOM_set_debug_mode ON
|
||||
#---------------------------------------------
|
||||
# Non DBC Global Variables
|
||||
#---------------------------------------------
|
||||
#set dbFileName "[MOM_ask_env_var UGII_CAM_LIBRARY_FEEDS_SPEEDS_DATA_DIR]machining_data.dat" ; # The ASCII Database File
|
||||
set DEBUG 1
|
||||
set fPointer ""
|
||||
|
||||
#---------------------------------------------
|
||||
# Global variables set by DBC for Input/Output
|
||||
#---------------------------------------------
|
||||
set dbc_lhs_exp ""
|
||||
set dbc_rhs_exp ""
|
||||
set dbc_relop ""
|
||||
set dbc_query ""
|
||||
set dbc_subqry1 ""
|
||||
set dbc_subqry2 ""
|
||||
set dbc_boolop ""
|
||||
set dbc_class_name ""
|
||||
set dbc_attr_count 0
|
||||
set dbc_attr_id ""
|
||||
set dbc_query_count 0
|
||||
set dbc_libref ""
|
||||
set dbc_var_list ""
|
||||
set dbc_tool_diameter ""
|
||||
set dbc_tool_height ""
|
||||
set dbc_part_units "english" ; # ( english : 0 , metric : 1)
|
||||
set dbc_cutmthd_libref ""
|
||||
set dbc_part_material_libref ""
|
||||
set dbc_tool_material_libref ""
|
||||
|
||||
# Default double precision value format.
|
||||
set double_precision_format "g"
|
||||
|
||||
#
|
||||
# Express feedrates for the following feed types
|
||||
# as percentages of Cut feedrate.
|
||||
# A value of 0 indicates no relation to Cut feedrate.
|
||||
#
|
||||
set dbc_engage_percent 90
|
||||
set dbc_first_cut_percent 60
|
||||
set dbc_approach_percent 0
|
||||
set dbc_stepover_percent 0
|
||||
set dbc_retract_percent 0
|
||||
set dbc_departure_percent 0
|
||||
set dbc_return_percent 0
|
||||
set asc_debug 0
|
||||
|
||||
proc ASC_t_create_filename {env_var_name filename} \
|
||||
{
|
||||
#
|
||||
# Creates a complete filename by evaluating an environment variable
|
||||
# for the directory information
|
||||
#
|
||||
set env_var [MOM_ask_env_var $env_var_name]
|
||||
|
||||
if { $env_var == "" } \
|
||||
{
|
||||
set message "Can't read environment variable $env_var_name"
|
||||
MOM_abort "\n $message"
|
||||
}
|
||||
|
||||
set fname ""
|
||||
set fname [append fname $env_var $filename]
|
||||
|
||||
return $fname
|
||||
|
||||
}
|
||||
|
||||
#---------------------------------------------
|
||||
proc MOM__boot {} {
|
||||
#---------------------------------------------
|
||||
|
||||
# source some general procedures
|
||||
|
||||
#
|
||||
# dbc_ascii_general.tcl
|
||||
#
|
||||
set filename \
|
||||
[ASC_t_create_filename "UGII_UG_LIBRARY_DIR" "dbc_ascii_general.tcl"]
|
||||
|
||||
|
||||
if { [catch {source $filename}] == "1" } \
|
||||
{
|
||||
set message "Can't load .tcl file: $filename"
|
||||
MOM_abort "\n $message"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
proc MOM__halt {} \
|
||||
{
|
||||
|
||||
}
|
||||
#---------------------------------------------
|
||||
proc DBC_init_db {} {
|
||||
#---------------------------------------------
|
||||
global DEBUG
|
||||
global dataBase
|
||||
global dbFileName
|
||||
global fPointer
|
||||
global asc_file_name
|
||||
global asc_database_count
|
||||
global dbc_dat_file_override
|
||||
global dbc_dat_file_name
|
||||
|
||||
set asc_file_name ""
|
||||
set asc_part_units ""
|
||||
set data_unit 0
|
||||
set mode 0
|
||||
|
||||
#
|
||||
# Set the filename for ASCII Data File
|
||||
#
|
||||
if {[info exists dbc_dat_file_override] } \
|
||||
{
|
||||
if {$dbc_dat_file_override == 1} \
|
||||
{
|
||||
set asc_file_name $dbc_dat_file_name
|
||||
} else \
|
||||
{
|
||||
ASC_set_data_file_name
|
||||
}
|
||||
} else \
|
||||
{
|
||||
ASC_set_data_file_name
|
||||
}
|
||||
|
||||
# Changed to improve performance
|
||||
# And load the file into memory
|
||||
#
|
||||
ASC_load_data_file $asc_file_name $data_unit $mode
|
||||
|
||||
}
|
||||
|
||||
#---------------------------------------------
|
||||
proc ASC_set_data_file_name {} {
|
||||
#---------------------------------------------
|
||||
global dbc_part_units
|
||||
global asc_file_name
|
||||
global asc_part_units
|
||||
|
||||
MOM_ask_part_units ;# writes to dbc_part_units
|
||||
|
||||
set env_var UGII_CAM_LIBRARY_FEEDS_SPEEDS_DATA_DIR
|
||||
set asc_file_name [ASC_t_create_filename "$env_var" "machining_data.dat"]
|
||||
set asc_part_units $dbc_part_units
|
||||
}
|
||||
|
||||
#---------------------------------------------
|
||||
proc ASC_get_tool_size { DB_ROW DIAMETER LENGTH } {
|
||||
#---------------------------------------------
|
||||
upvar $DB_ROW db_row
|
||||
upvar $DIAMETER asc_tool_diameter
|
||||
upvar $LENGTH asc_tool_length
|
||||
|
||||
global dbc_part_units
|
||||
|
||||
if { $dbc_part_units == "english"} \
|
||||
{
|
||||
set asc_tool_diameter [ASC_ask_att_val DIAM_IN $db_row \
|
||||
"%$::double_precision_format" 0 flag]
|
||||
set asc_tool_length [ASC_ask_att_val LENGTH_IN $db_row \
|
||||
"%$::double_precision_format" 0 flag]
|
||||
} else \
|
||||
{
|
||||
set asc_tool_diameter [ASC_ask_att_val DIAM_MM $db_row \
|
||||
"%$::double_precision_format" 0 flag]
|
||||
set asc_tool_length [ASC_ask_att_val LENGTH_MM $db_row \
|
||||
"%$::double_precision_format" 0 flag]
|
||||
}
|
||||
}
|
||||
|
||||
#---------------------------------------------
|
||||
proc ASC_get_machining_data { DB_ROW CUT_DEPTH STEPOVER FEED_VALUE SPEED_VALUE } {
|
||||
#---------------------------------------------
|
||||
upvar $DB_ROW db_row
|
||||
upvar $CUT_DEPTH asc_cut_value
|
||||
upvar $STEPOVER asc_stepover
|
||||
upvar $FEED_VALUE asc_feed_value
|
||||
upvar $SPEED_VALUE asc_speed_value
|
||||
|
||||
global dbc_part_units
|
||||
|
||||
if { $dbc_part_units == "english"} \
|
||||
{
|
||||
set asc_cut_value [ASC_ask_att_val DPT_CUT_IN $db_row \
|
||||
"%$::double_precision_format" 0 flag]
|
||||
set asc_stepover [ASC_ask_att_val STEPOVER_IN $db_row \
|
||||
"%$::double_precision_format" 0 flag]
|
||||
set asc_speed_value [ASC_ask_att_val SURF_SPEED_FPM $db_row \
|
||||
"%$::double_precision_format" 0 flag]
|
||||
set asc_feed_value [ASC_ask_att_val FEED_IPT $db_row \
|
||||
"%$::double_precision_format" 0 flag]
|
||||
} else \
|
||||
{
|
||||
set asc_cut_value [ASC_ask_att_val DPT_CUT_MM $db_row \
|
||||
"%$::double_precision_format" 0 flag]
|
||||
set asc_stepover [ASC_ask_att_val STEPOVER_MM $db_row \
|
||||
"%$::double_precision_format" 0 flag]
|
||||
set asc_speed_value [ASC_ask_att_val SURF_SPEED_MPM $db_row \
|
||||
"%$::double_precision_format" 0 flag]
|
||||
set asc_feed_value [ASC_ask_att_val FEED_MMPT $db_row \
|
||||
"%$::double_precision_format" 0 flag]
|
||||
}
|
||||
}
|
||||
|
||||
#---------------------------------------------
|
||||
proc ASC_get_feedrate_percentages { DB_ROW APPROACH_PERCENT ENGAGE_PERCENT \
|
||||
FIRSTCUT_PERCENT STEPOVER_PERCENT RETRACT_PERCENT RETURN_PERCENT DEPART_PERCENT } {
|
||||
#---------------------------------------------
|
||||
upvar $DB_ROW db_row
|
||||
upvar $APPROACH_PERCENT asc_approach_pct
|
||||
upvar $ENGAGE_PERCENT asc_engage_pct
|
||||
upvar $FIRSTCUT_PERCENT asc_firstcut_pct
|
||||
upvar $STEPOVER_PERCENT asc_stepover_pct
|
||||
upvar $RETRACT_PERCENT asc_retract_pct
|
||||
upvar $RETURN_PERCENT asc_return_pct
|
||||
upvar $DEPART_PERCENT asc_depart_pct
|
||||
|
||||
set asc_approach_pct [ASC_ask_att_val APPROACH_PCT $db_row \
|
||||
"%d" 0 flag]
|
||||
set asc_engage_pct [ASC_ask_att_val ENGAGE_PCT $db_row \
|
||||
"%d" 0 flag]
|
||||
set asc_firstcut_pct [ASC_ask_att_val FRSTCUT_PCT $db_row \
|
||||
"%d" 0 flag]
|
||||
set asc_stepover_pct [ASC_ask_att_val STEPOVER_PCT $db_row \
|
||||
"%d" 0 flag]
|
||||
set asc_retract_pct [ASC_ask_att_val RETRACT_PCT $db_row \
|
||||
"%d" 0 flag]
|
||||
set asc_return_pct [ASC_ask_att_val RETURN_PCT $db_row \
|
||||
"%d" 0 flag]
|
||||
set asc_depart_pct [ASC_ask_att_val DEPART_PCT $db_row \
|
||||
"%d" 0 flag]
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
proc DBC_create_query { } {
|
||||
#------------------------------------------------------------------------
|
||||
global DEBUG
|
||||
global dbc_query
|
||||
global dbc_subqry1
|
||||
global dbc_subqry2
|
||||
global dbc_boolop
|
||||
|
||||
# set dbc_query "$dbc_subqry1 $dbc_boolop $dbc_subqry2"
|
||||
|
||||
ASC_create_query
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
proc DBC_execute_query { } {
|
||||
#------------------------------------------------------------------------
|
||||
global asc_database_count
|
||||
|
||||
ASC_execute_query
|
||||
|
||||
}
|
||||
|
||||
proc ASC_set_engage_retract_to_rapid { } {
|
||||
if { $::dbc_engage_percent == 0 } \
|
||||
{
|
||||
set ::dbc_engage_percent "RAPID"
|
||||
}
|
||||
if { $::dbc_retract_percent == 0 } \
|
||||
{
|
||||
set ::dbc_retract_percent "RAPID"
|
||||
}
|
||||
}
|
||||
|
||||
#---------------------------------------------
|
||||
proc DBC_retrieve {} {
|
||||
#---------------------------------------------
|
||||
global DEBUG
|
||||
global dbc_event_error
|
||||
global dbc_part_units
|
||||
global dbc_cutmthd_libref
|
||||
global dbc_part_material_libref
|
||||
global dbc_tool_material_libref
|
||||
global dbc_tool_diameter
|
||||
global dbc_tool_length
|
||||
global dbc_tool_holder_offset
|
||||
|
||||
global dbc_surface_speed
|
||||
global dbc_feed_per_tooth
|
||||
global dbc_depth_of_cut
|
||||
global dbc_stepover
|
||||
|
||||
global dbc_approach_percent
|
||||
global dbc_engage_percent
|
||||
global dbc_first_cut_percent
|
||||
global dbc_stepover_percent
|
||||
global dbc_retract_percent
|
||||
global dbc_return_percent
|
||||
global dbc_departure_percent
|
||||
global fPointer
|
||||
global dbFileName
|
||||
global asc_database_count
|
||||
global asc_database
|
||||
global asc_file_name
|
||||
global file_unit
|
||||
global asc_units
|
||||
global asc_next_line
|
||||
global dbc_libref
|
||||
|
||||
global dbc_support_exact_match
|
||||
|
||||
# These hold data for finding nearest L/D ratio
|
||||
set index 0
|
||||
set low_record_indx -1
|
||||
set low_ratio_delta 99999
|
||||
set low_ratio 99999
|
||||
set high_record_indx -1
|
||||
set high_ratio_delta 99999
|
||||
set high_ratio 99999
|
||||
|
||||
# These hold data for records which match diameter only
|
||||
set low_len_rec_indx -1
|
||||
set low_len_delta 99999
|
||||
set low_len_ratio 99999
|
||||
set high_len_rec_indx -1
|
||||
set high_len_delta 99999
|
||||
set high_len_ratio 99999
|
||||
|
||||
# These hold data for records which are near the input tool in diameter and length
|
||||
set near_low_rec_indx -1
|
||||
set near_low_delta 99999
|
||||
set near_low_ratio 99999
|
||||
set near_high_rec_indx -1
|
||||
set near_high_delta 99999
|
||||
set near_high_ratio 99999
|
||||
|
||||
# These hold data for records which match diameter only
|
||||
set low_len_rec_indx -1
|
||||
set low_len_delta 99999
|
||||
set low_len_ratio 99999
|
||||
set high_len_rec_indx -1
|
||||
set high_len_delta 99999
|
||||
set high_len_ratio 99999
|
||||
|
||||
# These hold data for records which nearly match diameter only
|
||||
set near_diam_low_rec_indx -1
|
||||
set near_diam_low_ratio_delta 99999
|
||||
set near_diam_low_ratio 99999
|
||||
set near_diam_high_rec_indx -1
|
||||
set near_diam_high_ratio_delta 99999
|
||||
set near_diam_high_ratio 99999
|
||||
|
||||
# These hold data for records which match length only
|
||||
set low_diam_rec_indx -1
|
||||
set low_diam_delta 99999
|
||||
set low_diam_ratio 99999
|
||||
set high_diam_rec_indx -1
|
||||
set high_diam_delta 99999
|
||||
set high_diam_ratio 99999
|
||||
|
||||
# These hold data for records which nearly match length only
|
||||
set near_length_low_rec_indx -1
|
||||
set near_length_low_ratio_delta 99999
|
||||
set near_length_low_ratio 99999
|
||||
set near_length_high_rec_indx -1
|
||||
set near_length_high_ratio_delta 99999
|
||||
set near_length_high_ratio 99999
|
||||
|
||||
# tracking exact match on diameter
|
||||
set diameter_match_rec_index -1
|
||||
set diameter_match_count 0
|
||||
|
||||
# Nearness band for input tool diameter and length
|
||||
set nearness 0.10
|
||||
|
||||
set initialize_flag 1
|
||||
set asc_data_file_name $asc_file_name
|
||||
set asc_next_line ""
|
||||
|
||||
if { $dbc_part_units == "english" } \
|
||||
{
|
||||
set file_unit $asc_units(inch)
|
||||
} else \
|
||||
{
|
||||
set file_unit $asc_units(mm)
|
||||
}
|
||||
|
||||
## Changed function to improve performance
|
||||
|
||||
# set ret_code [catch {open $asc_data_file_name "r"} fp]
|
||||
# if { $ret_code } \
|
||||
# {
|
||||
# return 1
|
||||
# }
|
||||
|
||||
# ASC_init_database
|
||||
|
||||
set dbc_tool_length [ASC_get_tool_projection_length]
|
||||
|
||||
# compute the D4/L3 ratio for the input tool
|
||||
if { $dbc_tool_diameter > 0 } \
|
||||
{
|
||||
set input_ratio [expr pow($dbc_tool_length,3) / pow($dbc_tool_diameter,4)]
|
||||
# set input_ratio [expr pow($dbc_tool_diameter,4) / pow($dbc_tool_length,3)]
|
||||
} else \
|
||||
{
|
||||
set input_ratio 0
|
||||
}
|
||||
|
||||
# compute nearness band around input tool diameter and length
|
||||
set high_diam [expr (1 + $nearness) * $dbc_tool_diameter]
|
||||
set low_diam [expr (1 - $nearness) * $dbc_tool_diameter]
|
||||
set high_length [expr (1 + $nearness) * $dbc_tool_length]
|
||||
set low_length [expr (1 - $nearness) * $dbc_tool_length]
|
||||
|
||||
#
|
||||
# Loop over all the DATA records
|
||||
#
|
||||
# The db_row variable has to be initialized (see also ASC_translate_att_alias)
|
||||
|
||||
set db_row 0
|
||||
while { $db_row < $asc_database_count } \
|
||||
{
|
||||
set ascii_cutmethd_libref [ ASC_ask_att_val OPERTYPE \
|
||||
$db_row "" 0 flag]
|
||||
|
||||
set ascii_part_material_libref [ASC_ask_att_val PARTMAT $db_row \
|
||||
"" 0 flag]
|
||||
|
||||
set ascii_tool_material_libref [ASC_ask_att_val TOOLMAT $db_row \
|
||||
"" 0 flag]
|
||||
|
||||
# See if row matches primary selection criteria
|
||||
if { $dbc_cutmthd_libref == $ascii_cutmethd_libref && \
|
||||
$dbc_part_material_libref == $ascii_part_material_libref && \
|
||||
$dbc_tool_material_libref == $ascii_tool_material_libref } \
|
||||
{
|
||||
# It does. Get tool size and check for match
|
||||
ASC_get_tool_size db_row local_tool_diameter local_tool_length
|
||||
if { $dbc_tool_diameter == $local_tool_diameter && \
|
||||
$dbc_tool_length == $local_tool_length } \
|
||||
{
|
||||
# Got a matching record, get remaining data and return
|
||||
ASC_get_machining_data db_row dbc_depth_of_cut dbc_stepover \
|
||||
dbc_feed_per_tooth dbc_surface_speed
|
||||
|
||||
ASC_get_feedrate_percentages db_row dbc_approach_percent \
|
||||
dbc_engage_percent dbc_first_cut_percent dbc_stepover_percent \
|
||||
dbc_retract_percent dbc_return_percent dbc_departure_percent
|
||||
|
||||
ASC_set_engage_retract_to_rapid
|
||||
|
||||
return 0
|
||||
|
||||
} elseif { $dbc_support_exact_match == 0 } \
|
||||
{
|
||||
## Exact match not found check D4/L3 ratio for possible interpolation consideration
|
||||
if {$local_tool_diameter > 0} \
|
||||
{
|
||||
set local_ratio [expr pow($local_tool_length,3) / pow($local_tool_diameter,4)]
|
||||
} else \
|
||||
{
|
||||
set local_ratio 99999
|
||||
}
|
||||
ASC_check_ratio_closeness db_row input_ratio local_ratio \
|
||||
low_record_indx low_ratio_delta low_ratio \
|
||||
high_record_indx high_ratio_delta high_ratio
|
||||
|
||||
# Now start checking for special cases.
|
||||
|
||||
# First, record diameter and length within nearness band of input tool
|
||||
if { $local_tool_diameter >= $low_diam && \
|
||||
$local_tool_diameter <= $high_diam && \
|
||||
$local_tool_length >= $low_length && \
|
||||
$local_tool_length <= $high_length } \
|
||||
{
|
||||
ASC_check_ratio_closeness db_row input_ratio local_ratio \
|
||||
near_low_rec_indx near_low_delta near_low_ratio \
|
||||
near_high_rec_indx near_high_delta near_high_ratio
|
||||
}
|
||||
if { $dbc_tool_diameter == $local_tool_diameter } \
|
||||
{
|
||||
# Exactly matching diameters
|
||||
ASC_check_closeness db_row dbc_tool_length local_tool_length \
|
||||
local_ratio low_len_rec_indx low_len_delta low_len_ratio \
|
||||
high_len_rec_indx high_len_delta high_len_ratio
|
||||
set diameter_match_rec_index $db_row
|
||||
incr diameter_match_count
|
||||
}
|
||||
if { $local_tool_diameter >= $low_diam && \
|
||||
$local_tool_diameter <= $high_diam } \
|
||||
{
|
||||
# Diameter only within nearness band
|
||||
ASC_check_ratio_closeness db_row input_ratio local_ratio \
|
||||
near_diam_low_rec_indx near_diam_low_ratio_delta near_diam_low_ratio \
|
||||
near_diam_high_rec_indx near_diam_high_ratio_delta near_diam_high_ratio
|
||||
}
|
||||
if { $dbc_tool_length == $local_tool_length } \
|
||||
{
|
||||
# Exactly matching lengths
|
||||
ASC_check_closeness db_row dbc_tool_diameter local_tool_diameter \
|
||||
local_ratio low_diam_rec_indx low_diam_delta low_diam_ratio \
|
||||
high_diam_rec_indx high_diam_delta high_diam_ratio
|
||||
}
|
||||
if { $local_tool_length >= $low_length && \
|
||||
$local_tool_length <= $high_length } \
|
||||
{
|
||||
# Length only within nearness band
|
||||
ASC_check_ratio_closeness db_row input_ratio local_ratio \
|
||||
near_length_low_rec_indx near_length_low_ratio_delta near_length_low_ratio \
|
||||
near_length_high_rec_indx near_length_high_ratio_delta near_length_high_ratio
|
||||
}
|
||||
}
|
||||
}
|
||||
incr db_row
|
||||
}
|
||||
|
||||
# If we get here, we did not find an exact match on tool diameter and length,
|
||||
# so check alternatives
|
||||
if { $dbc_support_exact_match == 0 } \
|
||||
{
|
||||
# first a single record with matching diameter
|
||||
if { $diameter_match_rec_index > -1 && $diameter_match_count == 1 } \
|
||||
{
|
||||
ASC_get_machining_data diameter_match_rec_index dbc_depth_of_cut dbc_stepover \
|
||||
dbc_feed_per_tooth dbc_surface_speed
|
||||
|
||||
ASC_get_feedrate_percentages diameter_match_rec_index dbc_approach_percent \
|
||||
dbc_engage_percent dbc_first_cut_percent dbc_stepover_percent \
|
||||
dbc_retract_percent dbc_return_percent dbc_departure_percent
|
||||
|
||||
ASC_set_engage_retract_to_rapid
|
||||
|
||||
# next records near in both diameter and length
|
||||
} elseif { $near_low_rec_indx > -1 && $near_high_rec_indx > -1 } \
|
||||
{
|
||||
ASC_interpolate_data near_low_rec_indx near_low_ratio near_high_rec_indx \
|
||||
near_high_ratio input_ratio
|
||||
# Exact match found on diameter only
|
||||
} elseif { $low_len_rec_indx > -1 && $high_len_rec_indx > -1} \
|
||||
{
|
||||
ASC_interpolate_data low_len_rec_indx low_len_ratio high_len_rec_indx \
|
||||
high_len_ratio input_ratio
|
||||
# Near records on diameter only
|
||||
} elseif { $near_diam_low_rec_indx > -1 && $near_diam_high_rec_indx > -1} \
|
||||
{
|
||||
ASC_interpolate_data near_diam_low_rec_indx near_diam_low_ratio near_diam_high_rec_indx \
|
||||
near_diam_high_ratio input_ratio
|
||||
# Exact match found on length only
|
||||
} elseif { $low_diam_rec_indx > -1 && $high_diam_rec_indx > -1} \
|
||||
{
|
||||
ASC_interpolate_data low_diam_rec_indx low_diam_ratio high_diam_rec_indx \
|
||||
high_diam_ratio input_ratio
|
||||
# Near records on length only
|
||||
} elseif { $near_length_low_rec_indx > -1 && $near_length_high_rec_indx > -1} \
|
||||
{
|
||||
ASC_interpolate_data near_length_low_rec_indx near_length_low_ratio near_length_high_rec_indx \
|
||||
near_length_high_ratio input_ratio
|
||||
# Near ratios on both sides of input tool
|
||||
} elseif { $low_record_indx > -1 && $high_record_indx > -1 } \
|
||||
{
|
||||
ASC_interpolate_data low_record_indx low_ratio high_record_indx \
|
||||
high_ratio input_ratio
|
||||
# have a match on the high end, use it
|
||||
} elseif { $low_record_indx == -1 && $high_record_indx > -1} \
|
||||
{
|
||||
ASC_get_machining_data high_record_indx dbc_depth_of_cut dbc_stepover \
|
||||
dbc_feed_per_tooth dbc_surface_speed
|
||||
|
||||
ASC_get_feedrate_percentages high_record_indx dbc_approach_percent \
|
||||
dbc_engage_percent dbc_first_cut_percent dbc_stepover_percent \
|
||||
dbc_retract_percent dbc_return_percent dbc_departure_percent
|
||||
|
||||
ASC_set_engage_retract_to_rapid
|
||||
|
||||
# have a match on the low end, use it
|
||||
} elseif { $high_record_indx == -1 && $low_record_indx > -1} \
|
||||
{
|
||||
set near_libref [ASC_ask_att_val LIBRF $low_record_indx "%s" "" flag]
|
||||
ASC_get_machining_data low_record_indx dbc_depth_of_cut dbc_stepover \
|
||||
dbc_feed_per_tooth dbc_surface_speed
|
||||
|
||||
ASC_get_feedrate_percentages low_record_indx dbc_approach_percent \
|
||||
dbc_engage_percent dbc_first_cut_percent dbc_stepover_percent \
|
||||
dbc_retract_percent dbc_return_percent dbc_departure_percent
|
||||
|
||||
ASC_set_engage_retract_to_rapid
|
||||
|
||||
# no matches found at all -- return error message
|
||||
} else \
|
||||
{
|
||||
set dbc_event_error "No appropriate machining data found"
|
||||
}
|
||||
} else \
|
||||
{
|
||||
set dbc_event_error "No appropriate machining data found"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
proc DBC_write { } {
|
||||
#------------------------------------------------------------------------
|
||||
global asc_database_name
|
||||
|
||||
set asc_database_name "machining_data.dat"
|
||||
ASC_write
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
proc ASC_output_header { fileid } {
|
||||
#------------------------------------------------------------------------
|
||||
global dbc_attr_count
|
||||
global dbc_attr_aliases
|
||||
global dbc_attr_id
|
||||
global dbc_logname
|
||||
|
||||
|
||||
set daytime [clock seconds]
|
||||
set out_daytime [clock format $daytime -format "%a %b %d %Y %I:%M %p"]
|
||||
|
||||
set headerMessage "# MACHINING_DATA.DAT
|
||||
##########################################################################
|
||||
#
|
||||
# PURPOSE:
|
||||
#
|
||||
# This is the database file used for defining Machining Data in
|
||||
# an operation.
|
||||
#
|
||||
#
|
||||
# REVISED:
|
||||
# $dbc_logname $out_daytime
|
||||
#
|
||||
##########################################################################
|
||||
# The data is organized in the format separated by |
|
||||
# The fields in the database are in the following order:
|
||||
#
|
||||
# LIBRF - Unique record identifier
|
||||
# (Library Reference)
|
||||
# OPERTYPE - cutmthd_libref Cut Method Library Reference
|
||||
# PARTMAT - part_material_libref Part Part Material Library Reference
|
||||
# TOOLMAT - tool_material_libref Tool Material Library Reference
|
||||
# DIAM_IN - cutter diameter - inch
|
||||
# DIAM_MM - cutter diameter - mm
|
||||
# LENGTH_IN - cutter length - inch
|
||||
# LENGTH_MM - cutter length - mm
|
||||
# DPT_CUT_IN - dpth_of_cut Depth_of_cut(inch)
|
||||
# DPT_CUT_MM - dpth_of_cut Depth_of_cut(mm)
|
||||
# STEPOVER_IN - stepover distance (inch)
|
||||
# STEPOVER_MM - stepover distance (mm)
|
||||
# SURF_SPEED_FPM - surface_speed Suface Speed(FPM)
|
||||
# SURF_SPEED_MPM - surface_speed Suface Speed(MPM)
|
||||
# FEED_IPT - feed_per_tooth Feed per Tooth(IPT)
|
||||
# FEED_MMPT - feed_per_tooth Feed per Tooth(MMPT)
|
||||
# APPROACH_PCT - approach feedrate percentage of cut feedrate
|
||||
# ENGAGE_PCT - engage feedrate percentage of cut feedrate
|
||||
# FRSTCUT_PCT - first cut feedrate percentage of cut feedrate
|
||||
# STEPOVER_PCT - stepover feedrate percentage of cut feedrate
|
||||
# RETRACT_PCT - retract feedrate percentage of cut feedrate
|
||||
# RETURN_PCT - return feedrate percentage of cut feedrate
|
||||
# DEPART_PCT - departure feedrate percentage of cut feedrate
|
||||
#--------------------------------------------------------------------------------"
|
||||
|
||||
puts $fileid "$headerMessage"
|
||||
|
||||
# load the database structure
|
||||
DBC_load_rset_data
|
||||
|
||||
|
||||
# output FORMAT line
|
||||
set format_line "FORMAT"
|
||||
for {set i 0} {$i < $dbc_attr_count} {incr i} \
|
||||
{
|
||||
DBC_ask_attr_id $dbc_attr_aliases($i)
|
||||
set format_line "$format_line $dbc_attr_id"
|
||||
}
|
||||
puts $fileid $format_line
|
||||
puts $fileid "#--------------------------------------------------------------------------------"
|
||||
}
|
||||
|
||||
proc ASC_check_closeness { DB_ROW BASE_VALUE TEST_VALUE TEST_RATIO LOW_REC_INDX LOW_REC_DELTA \
|
||||
LOW_REC_RATIO HIGH_REC_INDX HIGH_REC_DELTA HIGH_REC_RATIO } {
|
||||
|
||||
upvar $DB_ROW db_row
|
||||
upvar $BASE_VALUE base_value
|
||||
upvar $TEST_VALUE test_value
|
||||
upvar $TEST_RATIO test_ratio
|
||||
upvar $LOW_REC_INDX low_record_indx
|
||||
upvar $LOW_REC_RATIO low_ratio
|
||||
upvar $LOW_REC_DELTA low_delta
|
||||
upvar $HIGH_REC_DELTA high_delta
|
||||
upvar $HIGH_REC_INDX high_record_indx
|
||||
upvar $HIGH_REC_RATIO high_ratio
|
||||
|
||||
if { $base_value > $test_value } \
|
||||
{
|
||||
set test_delta [expr ($base_value - $test_value)]
|
||||
if { $test_delta < $low_delta } \
|
||||
{
|
||||
set low_delta $test_delta
|
||||
set low_record_indx $db_row
|
||||
set low_ratio $test_ratio
|
||||
}
|
||||
} elseif { $base_value < $test_value } \
|
||||
{
|
||||
set test_delta [expr ($test_value - $base_value)]
|
||||
if { $test_delta < $high_delta } \
|
||||
{
|
||||
set high_delta $test_delta
|
||||
set high_record_indx $db_row
|
||||
set high_ratio $test_ratio
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc ASC_check_ratio_closeness { DB_ROW BASE_VALUE TEST_VALUE LOW_REC_INDX LOW_REC_DELTA \
|
||||
LOW_REC_RATIO HIGH_REC_INDX HIGH_REC_DELTA HIGH_REC_RATIO } {
|
||||
|
||||
upvar $DB_ROW db_row
|
||||
upvar $BASE_VALUE base_value
|
||||
upvar $TEST_VALUE test_value
|
||||
upvar $LOW_REC_INDX low_record_indx
|
||||
upvar $LOW_REC_RATIO low_ratio
|
||||
upvar $LOW_REC_DELTA low_delta
|
||||
upvar $HIGH_REC_DELTA high_delta
|
||||
upvar $HIGH_REC_INDX high_record_indx
|
||||
upvar $HIGH_REC_RATIO high_ratio
|
||||
|
||||
if { $base_value > $test_value } \
|
||||
{
|
||||
set test_delta [expr ($base_value - $test_value)]
|
||||
if { $test_delta < $low_delta } \
|
||||
{
|
||||
set low_delta $test_delta
|
||||
set low_record_indx $db_row
|
||||
set low_ratio $test_value
|
||||
}
|
||||
} elseif { $base_value < $test_value } \
|
||||
{
|
||||
set test_delta [expr ($test_value - $base_value)]
|
||||
if { $test_delta < $high_delta } \
|
||||
{
|
||||
set high_delta $test_delta
|
||||
set high_record_indx $db_row
|
||||
set high_ratio $test_value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc ASC_interpolate_data { LOW_REC_INDX LOW_RATIO HIGH_REC_INDX HIGH_RATIO INPUT_RATIO } {
|
||||
|
||||
upvar $LOW_REC_INDX low_record_indx
|
||||
upvar $LOW_RATIO low_ratio
|
||||
upvar $HIGH_REC_INDX high_record_indx
|
||||
upvar $HIGH_RATIO high_ratio
|
||||
upvar $INPUT_RATIO input_ratio
|
||||
|
||||
global dbc_surface_speed
|
||||
global dbc_feed_per_tooth
|
||||
global dbc_depth_of_cut
|
||||
global dbc_stepover
|
||||
|
||||
global dbc_approach_percent
|
||||
global dbc_engage_percent
|
||||
global dbc_first_cut_percent
|
||||
global dbc_stepover_percent
|
||||
global dbc_retract_percent
|
||||
global dbc_return_percent
|
||||
global dbc_departure_percent
|
||||
|
||||
|
||||
ASC_get_machining_data low_record_indx low_depth_of_cut low_stepover \
|
||||
low_feed_per_tooth low_surface_speed
|
||||
|
||||
ASC_get_feedrate_percentages low_record_indx low_approach_percent \
|
||||
low_engage_percent low_first_cut_percent low_stepover_percent \
|
||||
low_retract_percent low_return_percent low_departure_percent
|
||||
|
||||
ASC_get_machining_data high_record_indx high_depth_of_cut high_stepover \
|
||||
high_feed_per_tooth high_surface_speed
|
||||
|
||||
ASC_get_feedrate_percentages high_record_indx high_approach_percent \
|
||||
high_engage_percent high_first_cut_percent high_stepover_percent \
|
||||
high_retract_percent high_return_percent high_departure_percent
|
||||
|
||||
set step [expr ($input_ratio - $low_ratio) / ($high_ratio - $low_ratio)]
|
||||
|
||||
set dbc_depth_of_cut [expr $low_depth_of_cut + $step * ($high_depth_of_cut - $low_depth_of_cut)]
|
||||
set dbc_stepover [expr $low_stepover+ $step * ($high_stepover - $low_stepover)]
|
||||
set dbc_feed_per_tooth [expr $low_feed_per_tooth + $step * ($high_feed_per_tooth - $low_feed_per_tooth)]
|
||||
set dbc_surface_speed [expr $low_surface_speed + $step * ($high_surface_speed - $low_surface_speed)]
|
||||
set dbc_approach_percent [expr int ([expr $low_approach_percent + \
|
||||
$step * ($high_approach_percent - $low_approach_percent)])]
|
||||
set dbc_engage_percent [expr int ([expr $low_engage_percent + \
|
||||
$step * ($high_engage_percent - $low_engage_percent)])]
|
||||
set dbc_first_cut_percent [expr int ([expr $low_first_cut_percent + \
|
||||
$step * ($high_first_cut_percent - $low_first_cut_percent)])]
|
||||
set dbc_stepover_percent [expr int ([expr $low_stepover_percent + \
|
||||
$step * ($high_stepover_percent - $low_stepover_percent)])]
|
||||
set dbc_retract_percent [expr int ([expr $low_retract_percent + \
|
||||
$step * ($high_retract_percent - $low_retract_percent)])]
|
||||
set dbc_return_percent [expr int ([expr $low_return_percent + \
|
||||
$step * ($high_return_percent - $low_return_percent)])]
|
||||
set dbc_departure_percent [expr int ([expr $low_departure_percent + \
|
||||
$step * ($high_departure_percent - $low_departure_percent)])]
|
||||
|
||||
ASC_set_engage_retract_to_rapid
|
||||
}
|
||||
|
||||
proc ASC_get_tool_projection_length {} {
|
||||
global dbc_tool_length
|
||||
global dbc_tool_diameter
|
||||
global dbc_tool_holder_offset
|
||||
global dbc_tool_tapered_shank_length
|
||||
global dbc_tool_tapered_shank_diameter
|
||||
|
||||
# In general the projected tool length is calculated from the tip of the tool to the first holder segment
|
||||
# Except when shank diameter is greater than tool diameter, the projected tool length is from the tool tip to the start of the shank
|
||||
if {[info exists dbc_tool_tapered_shank_length] && $dbc_tool_tapered_shank_length > 0.0} {
|
||||
if {$dbc_tool_tapered_shank_diameter > $dbc_tool_diameter} {
|
||||
return $dbc_tool_length
|
||||
} else {
|
||||
if {[info exists dbc_tool_holder_offset]} {
|
||||
return [expr $dbc_tool_length + $dbc_tool_tapered_shank_length - $dbc_tool_holder_offset]
|
||||
} else {
|
||||
return [expr $dbc_tool_length + $dbc_tool_tapered_shank_length]
|
||||
}
|
||||
}
|
||||
} elseif {[info exists dbc_tool_holder_offset]} {
|
||||
return [expr $dbc_tool_length - $dbc_tool_holder_offset]
|
||||
} else {
|
||||
return $dbc_tool_length
|
||||
}
|
||||
}
|
||||
|
||||
# To enable the new customization mechanism.
|
||||
# This should ALWAYS be the last line in the file.
|
||||
MOM_extend_for_customization UGII_CAM_CUSTOM_LIBRARY_FEEDS_SPEEDS_ASCII_DIR dbc_custom_ascii_machining_data.tcl
|
||||
Reference in New Issue
Block a user