############################################################################### # dbc_device_ascii.tcl - DBC Event Handler for device database stored as ascii file ############################################################################### ############################################################################## # REVISIONS # Date Who Reason # 10-Mar-2005 JM Initial # 15-Apr-2005 JM Account for holding system ############################################################################## # proc ASC_m_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_m_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" } ### source /cam/v160/jm_mct/dbc_ascii_general.tcl } proc MOM__halt {} \ { } #--------------------------------------------- proc DBC_init_db {} \ { global asc_debug global asc_file_name global dbc_part_units global asc_units # # Global variables set by DBC for Input/Output # global dbc_lhs_exp global dbc_rhs_exp global dbc_relop global dbc_query global dbc_subqry1 global dbc_subqry2 global dbc_boolop global dbc_class_name global dbc_attr_count global dbc_attr_id global dbc_query_count global dbc_libref global dbc_var_list global dbc_rididity 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_rigidity 1.0 set asc_debug 0 # Create the filename for the machine_database.dat set env_var UGII_CAM_LIBRARY_DEVICE_DATA_DIR set asc_file_name [ASC_m_create_filename "$env_var" "device_database.dat"] # And load the file into memory set ret_val \ [ASC_load_data_file $asc_file_name $asc_units(unknown) 0] if { $ret_val == "1" } \ { set message "Open error for UG/Library ASCII Data File: $asc_file_name" set message "$message \n $asc_file_name" MOM_abort "\n $message" } } #--------------------------------------------- proc DBC_retrieve {} { #--------------------------------------------- # # global input # ------------ global asc_debug global dbc_libref global dbc_retrieve_var_list # # global output # ------------- global dbc_holding_system # # manufacturer and description global dbc_device_description set dbc_device_description mct_unknown # # partfile name for machine graphics # global dbc_device_part_name set dbc_device_part_name "" append dbc_device_part_name $dbc_libref ".prt" # # Look for the desired libref # set found [ASC_array_search_machine $dbc_libref db_row] # # Ask the necessary attribute values # set dbc_device_description \ [ASC_ask_att_val DESCR $db_row "" unknown flag] # # Holding system # set dbc_holding_system [ASC_ask_att_val HLD $db_row "" 4711 flag] } proc ASC_array_search_machine { libref db_row_ref } \ { upvar $db_row_ref db_row global asc_file_name set found [ASC_array_find_object_by_att LIBRF $libref db_row ] if { $found == 2 } \ { set message "Error retrieving machine data from external library." set message "$message \n Machine with the library reference $libref" set message "$message \n does not exist in the" set message "$message \n ASCII Data File(s):" set message "$message \n $asc_file_name" MOM_log_message "\n $message" } return $found } proc DBC_ask_library_values {} \ { # # global input global dbc_libref global dbc_db_ids_count global dbc_db_ids # # global output global dbc_db_ids_value # # Look for the desired libref # ASC_array_search_machine $dbc_libref db_row # # and set the desired values # 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] } } #--------------------------------------------- proc DBC_translate_att_alias {} { #--------------------------------------------- ASC_translate_att_alias } #--------------------------------------------- proc DBC_create_criterion {} { #--------------------------------------------- ASC_create_criterion } #--------------------------------------------- proc DBC_create_query {} { #--------------------------------------------- ASC_create_query } #--------------------------------------------- proc DBC_execute_query {} { #--------------------------------------------- ASC_execute_query } #--------------------------------------------- proc DBC_execute_query_for_count {} { #--------------------------------------------- ASC_execute_query_for_count } #------------------------------------------------------------------------ proc DBC_write { } { #------------------------------------------------------------------------ global asc_database_name set asc_database_name "machine_database.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 "############################################################################### # machine_database.dat - database file for machine database stored as ascii file ############################################################################### ############################################################################# ## Data file for the Machine tool ## ## ## REVISED: ## $dbc_logname $out_daytime ## ## The following key words for Attribute ids are defined ## ## LIBRF - unique record identifier ## T - Machine type - 1-Mill machines ## - 2-Lathe machines ## - 3-Wedm machines ## - 4-MillTurn machines ## - 9-Mixed machines ## ## MNF - Manufacturer ## DESCR - Short description ( for example 3 Axis Mill) ## CNTR - indicating the controller of the machine ## ## POST - the configuration file name with the list of ## postprocessors for this machine ## (The path will be found from the search path environment variable) ## RIGID - Rigidity factor to apply to data from the machining data library ## This will normally be a number less than or equal to 1.0 ##############################################################################" 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 "#--------------------------------------------------------------------------------" }