CUT_METHODS.DAT

##############################################################################

PURPOSE:

This is the database file used for defining Cut Method in

Machining method. The library reference is used for Feeds and

Speeds Specifications.

REVISED:

$dbc_logname $out_daytime

########################################################################## ##########################################################################

The following key words for Attribute ids are defined

LIBREF cutmthd_libref - Unique record identifier (Library Reference)

MODE machine_mode - Machine mode - 'MILL'

- 'DRILL'

- 'LATHE'

NAME name - Name of Cutting Method

(appears on the label in method view)

#########################################################################

--------+-------------------------------+---------------------

#---------------------------------------------

Non DBC Global Variables

#--------------------------------------------- #MOM_set_debug_mode ON #set dbFileName "[MOM_ask_env_var UGII_CAM_LIBRARY_FEEDS_SPEEDS_DATA_DIR]cut_methods.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_cutmthd_libref "" set dbc_var_list "" set dbc_machine_mode "MILL" 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

Since we are now reading the records one by one, no need to load

the data file. ( Changed on 20-Aug-99 )

}

#--------------------------------------------- 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" "cut_methods.dat"] set asc_part_units $dbc_part_units

}

#--------------------------------------------- proc DBC_translate_att_alias {} { #--------------------------------------------- global DEBUG global dbc_alias global dbc_id

The input dbc_id is the column in the RSET

 set dbc_id "\$dataBase($dbc_id)"

}

#------------------------------------------------------------ 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 ASC_file_execute_query_check_attr { file_name file_unit }
{

Executes query on cut_methods file. This procedure is derived from

ASC_file_execute_query.It is slightly modified so that an attribute

of the record can be checked for some value and then populated to Rset

Input filename - name of the database file, in this case cut_methods.dat

file_unit - Unit of the records, in this case none

Returns 0 -> Succesful Loading

1 -> File open error

global asc_debug

global dbc_class_name global dbc_query global dbc_query_count global dbc_attr_count global dbc_attr_aliases global dbc_attr_id

global asc_database global asc_database_count global dbc_machine_mode

global asc_next_line if { $asc_debug == "1" } { puts "ASC_file_execute_query" puts "dbc_class_name = $dbc_class_name" puts "dbc_query = $dbc_query" }

The following procedure writes to the variables

dbc_attr_count, dbc_attr_aliases

DBC_load_rset_data

Open the file

set ret_code [catch {open $file_name "r"} fp] if { $ret_code }
{ return 1 }

ASC_init_database

Loop over all the DATA records

The db_row variable has to be initialized (see also ASC_translate_att_alias)

set db_row 0 set rset_row 0

set asc_next_line "" while {[ASC_read_next_db_object $fp $file_name $file_unit $db_row] >= 0}
{

  set local_dbc_machine_mode [ASC_ask_att_val MODE $db_row "" 0 flag]

  if {[string compare $dbc_machine_mode $local_dbc_machine_mode] == 0 ||
      [string compare $dbc_machine_mode "ALL"] == 0 } \
  {

  set dum [catch {expr $dbc_query} ret]
  if { $ret == "1" } \
  {
     ASCi_write_to_rset fp $dbc_attr_count dbc_attr_aliases \
                        $rset_row $db_row
     incr rset_row
     incr dbc_query_count
  }

  catch {unset asc_database}
  set asc_database_count 0
  }

}

if { $asc_debug == "1" } { puts "End of ASC_file_execute_query " puts "Count: $dbc_query_count" }

close $fp

return 0

}

#------------------------------------------------------------------------ proc DBC_execute_query { } { #------------------------------------------------------------------------ global asc_units global file_unit global asc_file_name

set file_unit $asc_units(unknown) ASC_file_execute_query_check_attr $asc_file_name $file_unit

} #--------------------------------------------------------------------- proc DBC_retrieve { } { #--------------------------------------------------------------------- global DEBUG global dbc_libref global dbc_retrieve_var_list global dataBase

global dbc_machine_mode global dbc_name global dbc_description global dbFileName global fPointer global asc_debug global asc_database_count global asc_file_name global file_unit

intialize file_unit

if { ![info exists file_unit] } { global dbc_part_units global asc_units

   MOM_ask_part_units  ;# writes to dbc_part_units

   if { $dbc_part_units == "metric" } {
       set file_unit $asc_units(mm)
   } else {
       set file_unit $asc_units(inch)
   }

}

if { $asc_debug == "1" }
{ puts " =========================================="
puts " procedure DBC_retrieve for cut methods" puts " libref -> $dbc_libref" }

Look for the desired libref

set found 2

set found [ASC_file_find_object_by_att $asc_file_name $file_unit
LIBRF $dbc_libref db_row]

if { $found == 2 }
{ set message "Error retrieving Cut Method from external library." set message "$message \n Cut Method 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" }

if { $found == 1 }
{ set message "Error retrieving Cut Method from external library." set message "$message \n ASCII Data File: $asc_file_name" set message "$message \n does not exist." MOM_abort "\n $message" }

Get the Machining Mode

set dbc_machine_mode [ASC_ask_att_val MODE $db_row "" 0 flag]

Get the Cut Method Name

set dbc_name [ASC_ask_att_val NAME $db_row "" 0 flag]

}

#------------------------------------------------------------------------ proc DBC_write { } { #------------------------------------------------------------------------ global asc_database_name

set asc_database_name "cut_methods.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 "# CUT_METHODS.DAT

##########################################################################

PURPOSE:

This is the database file used for defining Cut Method in

Machining method. The library reference is used for Feeds and

Speeds Specifications.

REVISED:

$dbc_logname $out_daytime

########################################################################## ##########################################################################

The following key words for Attribute ids are defined

LIBREF cutmthd_libref - Unique record identifier (Library Reference)

MODE machine_mode - Machine mode - 'MILL'

- 'DRILL'

- 'LATHE'

NAME name - Name of Cutting Method

(appears on the label in method view)

#########################################################################

--------+-------------------------------+---------------------"

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 dbc_libref global dbc_db_ids_count global dbc_db_ids global dbc_event_error global asc_file_name global asc_units global dbc_return_status global dbc_db_ids_value

Do not change this string

set NO_MATCH "No matching record found for $dbc_libref in $asc_file_name"

set dbc_return_status 0

Look for the desired libref from the file directly

set found [ASC_file_find_object_by_att $asc_file_name $asc_units(unknown) \
           LIBRF $dbc_libref db_row]

and set the desired values

if {$found == 1 || $found == 2} {
    set dbc_event_error $NO_MATCH
    set dbc_return_status 1
} else {
    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]
    }
}

}

CUT_METHODS.DAT: Cut Methods Database File

原文地址: https://www.cveoy.top/t/topic/nQNF 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录