Initial commit
This commit is contained in:
373
feeds_speeds/ascii/tool_materials.tcl
Normal file
373
feeds_speeds/ascii/tool_materials.tcl
Normal file
@@ -0,0 +1,373 @@
|
||||
#############################################################################
|
||||
# REVISIONS
|
||||
# Date Who Reason
|
||||
# 03/24/99 Murthy Mandaleeka Initial
|
||||
# 05/19/99 Murthy Mandaleeka New Environment Variable
|
||||
# 07/21/99 Subhash Included dbc_general_ascii.tcl file
|
||||
# 07/21/99 Subhash Used general functions for
|
||||
# opening and reading dat files.
|
||||
# 08/06/99 Subhash Removed some unwanted comments
|
||||
# 11/11/2003 rlm Add ASC_output_header
|
||||
# 01/30/2004 rlm Move ASC_write to dbc_ascii_general
|
||||
# 02/12/2004 rlm Add library revision information
|
||||
# 07/01/2004 rlm 1339644 Add proc DBC_ask_library_values
|
||||
# 12/06/2004 rlm 1369488 Fix DBC_execute_query_for_count and
|
||||
# DBC_translate_att_alias
|
||||
# 01/06/2005 gbs Added a comment to the line
|
||||
# before
|
||||
##############################################################################
|
||||
#
|
||||
# The format of each line in the text file is:
|
||||
#
|
||||
# material_code
|
||||
# material_name
|
||||
# material_description
|
||||
#
|
||||
# The DB_ID of a DB_ALIAS is its field number in the line (0-based)
|
||||
###############################################################################
|
||||
|
||||
|
||||
#---------------------------------------------
|
||||
# Non DBC Global Variables
|
||||
#---------------------------------------------
|
||||
#MOM_set_debug_mode ON
|
||||
#set dbFileName "[MOM_ask_env_var UGII_CAM_LIBRARY_FEEDS_SPEEDS_DATA_DIR]tool_materials.dat"
|
||||
set DEBUG 0
|
||||
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 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 lastRowNumber
|
||||
global dbFileName
|
||||
global fPointer
|
||||
global asc_file_name
|
||||
|
||||
set asc_part_units ""
|
||||
|
||||
set data_unit 0
|
||||
set mode 0
|
||||
|
||||
#
|
||||
# Set the filename for ASCII Data File
|
||||
#
|
||||
ASC_set_data_file_name
|
||||
|
||||
#
|
||||
# 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" "tool_materials.dat"]
|
||||
set asc_part_units $dbc_part_units
|
||||
|
||||
}
|
||||
|
||||
#---------------------------------------------
|
||||
proc DBC_translate_att_alias {} {
|
||||
#---------------------------------------------
|
||||
global DEBUG
|
||||
global dbc_alias
|
||||
global dbc_id
|
||||
|
||||
ASC_translate_att_alias
|
||||
}
|
||||
|
||||
#------------------------------------------------------------
|
||||
proc DBC_create_criterion { } {
|
||||
#------------------------------------------------------------
|
||||
global DEBUG
|
||||
global dbc_lhs_exp
|
||||
global dbc_rhs_exp
|
||||
global dbc_relop
|
||||
global dbc_query
|
||||
|
||||
### set dbc_query "\[$dbc_lhs_exp\] $dbc_relop \[$dbc_rhs_exp\]"
|
||||
|
||||
ASC_create_criterion
|
||||
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
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 DBC_execute_query_for_count {} {
|
||||
#---------------------------------------------
|
||||
|
||||
ASC_execute_query_for_count
|
||||
|
||||
}
|
||||
#---------------------------------------------
|
||||
proc DBC_retrieve { } {
|
||||
#---------------------------------------------
|
||||
global DEBUG
|
||||
global dbc_libref
|
||||
global dbc_retrieve_var_list
|
||||
global dataBase
|
||||
|
||||
global dbc_material_code
|
||||
global dbc_material_name
|
||||
global dbc_material_description
|
||||
|
||||
global dbFileName
|
||||
global fPointer
|
||||
|
||||
global asc_debug
|
||||
global asc_file_name
|
||||
global asc_database_count
|
||||
|
||||
if { $asc_debug == "1" } \
|
||||
{
|
||||
puts " =========================================="
|
||||
puts " procedure DBC_retrieve for Tool Material"
|
||||
puts " libref -> $dbc_libref"
|
||||
}
|
||||
|
||||
#
|
||||
# Look for the desired libref
|
||||
#
|
||||
|
||||
for {set db_row 0} {$db_row < $asc_database_count} {incr db_row 1} \
|
||||
{
|
||||
# Find the row for the desired LibRef
|
||||
set toolmaterial_libref [ASC_ask_att_val LIBRF $db_row \
|
||||
"" 0 flag]
|
||||
|
||||
if { $dbc_libref == $toolmaterial_libref } \
|
||||
{
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if { $db_row >= $asc_database_count } \
|
||||
{
|
||||
set message "Error retrieving Tool Material from external library."
|
||||
set message "$message \n Tool Material with the library reference $dbc_libref"
|
||||
set message "$message \n does not exist in the"
|
||||
set message "$message \n ASCII Data File: $asc_file_name"
|
||||
MOM_abort "\n $message"
|
||||
}
|
||||
|
||||
#
|
||||
# Get the Material No.
|
||||
#
|
||||
set dbc_material_code [ASC_ask_att_val LIBRF $db_row "%s" "" flag]
|
||||
|
||||
#
|
||||
# Get the Material Name
|
||||
#
|
||||
set dbc_material_name [ASC_ask_att_val MATNAM $db_row "%s" "" flag]
|
||||
|
||||
#
|
||||
# Get the Material description
|
||||
#
|
||||
set dbc_material_description [ASC_ask_att_val MATDESC $db_row "%s" "" flag]
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
proc DBC_write { } {
|
||||
#------------------------------------------------------------------------
|
||||
global asc_database_name
|
||||
|
||||
set asc_database_name "tool_materials.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 "# TOOL_MATERIALS.DAT
|
||||
##########################################################################
|
||||
#
|
||||
# PURPOSE:
|
||||
#
|
||||
# This is the database file used for defining Tool Material.
|
||||
#
|
||||
# REVISED:
|
||||
# $dbc_logname $out_daytime
|
||||
#
|
||||
##########################################################################
|
||||
##########################################################################
|
||||
##
|
||||
## The following key words for Attribute ids are defined
|
||||
##
|
||||
## LIBREF material_code - Unique record identifier
|
||||
## (Library Reference)
|
||||
## MATNAM material_name - Material Name (appears on the label)
|
||||
## MATDESC material_description - Material Description
|
||||
#########################################################################
|
||||
#----------------+-------------------------------+-------------"
|
||||
|
||||
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 DBC_ask_library_values {} \
|
||||
{
|
||||
#
|
||||
# global input
|
||||
global dbc_libref
|
||||
global dbc_db_ids_count
|
||||
global dbc_db_ids
|
||||
global dbc_event_error
|
||||
global asc_database_count
|
||||
|
||||
#
|
||||
# global output
|
||||
global dbc_return_status
|
||||
global dbc_db_ids_value
|
||||
|
||||
# Do not change this string
|
||||
set NO_MATCH "No matching record found for $dbc_libref"
|
||||
|
||||
set dbc_return_status 0
|
||||
|
||||
#
|
||||
# Look for the desired libref
|
||||
#
|
||||
for {set db_row 0} {$db_row < $asc_database_count} {incr db_row 1} \
|
||||
{
|
||||
set toolmaterial_libref [ASC_ask_att_val LIBRF $db_row \
|
||||
"" 0 flag]
|
||||
if { $dbc_libref == $toolmaterial_libref } \
|
||||
{
|
||||
break
|
||||
}
|
||||
}
|
||||
#
|
||||
# and set the desired values
|
||||
#
|
||||
if { $db_row < $asc_database_count } \
|
||||
{
|
||||
for { set inx 0 } { $inx < $dbc_db_ids_count } { incr inx } \
|
||||
{
|
||||
set dbc_db_ids_value($dbc_db_ids($inx)) \
|
||||
[ASC_ask_att_val $dbc_db_ids($inx) $db_row "" "" flag]
|
||||
}
|
||||
} else \
|
||||
{
|
||||
set dbc_event_error $NO_MATCH
|
||||
set dbc_return_status 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user