1
0

Initial commit

This commit is contained in:
2026-02-22 14:16:24 +01:00
commit 1692d191fa
3684 changed files with 10817616 additions and 0 deletions

View File

@@ -0,0 +1,484 @@
###############################################################################
# dbc_fixture_ascii.tcl - DBC Event Handler for fixture database stored as ascii file
###############################################################################
##############################################################################
# REVISIONS
# Date Who Reason
# 09-Jul-2024 Dieter Krach MFEC-56430: Initial
# 07-Oct-2024 Dieter Krach MFEC-56432: Support export of fixtures
##############################################################################
#
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"
}
#
# fixture export procedures
#
set filename \
[ASC_m_create_filename "UGII_CAM_LIBRARY_FIXTURE_ASCII_DIR" "dbc_fixture_ascii_export.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 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
# Set the unit for fixture search to the part unit
ASC_set_part_unit
# Create the filename for the fixture_database.dat
set asc_mm_file_name [ASC_get_data_file_name $asc_units(mm)]
set asc_inch_file_name [ASC_get_data_file_name $asc_units(inch)]
if { $asc_mm_file_name == "" && $asc_inch_file_name == "" } \
{
set message "Error looking for a fixture_database.dat file."
set message "$message \n Neither of the environment variables"
set message "$message \n UGII_CAM_LIBRARY_FIXTURE_METRIC_DIR,"
set message "$message \n UGII_CAM_LIBRARY_FIXTURE_ENGLISH_DIR"
set message "$message \n is defined."
MOM_abort "\n $message"
}
# Ask the file sizes
set size_mm 0
set ret_val_mm 1
if { $asc_mm_file_name != "" } \
{
set ret_val_mm [catch {file size $asc_mm_file_name} size_mm]
}
set size_inch 0
set ret_val_inch 1
if { $asc_inch_file_name != "" } \
{
set ret_val_inch [catch {file size $asc_inch_file_name} size_inch]
}
if { $ret_val_mm == "1" && $ret_val_inch == "1" } \
{
set message "Error, can't read a fixture_database.dat file."
set message "$message \n Neither of the files"
set message "$message \n $asc_mm_file_name"
set message "$message \n $asc_inch_file_name"
set message "$message \n can be read."
MOM_abort "\n $message"
}
# And load the file into memory
set append 0
if { $ret_val_mm == 0 } \
{
set ret_val [ASC_load_data_file $asc_mm_file_name $asc_units(mm) $append]
if { $ret_val == "1" } \
{
set message "Open error for UG/Library ASCII Data File: $asc_mm_file_name"
set message "$message \n $asc_mm_file_name"
MOM_abort "\n $message"
}
set append 1
}
if { $ret_val_inch == 0 } \
{
set ret_val [ASC_load_data_file $asc_inch_file_name $asc_units(inch) $append]
if { $ret_val == "1" } \
{
set message "Open error for UG/Library ASCII Data File: $asc_inch_file_name"
set message "$message \n $asc_inch_file_name"
MOM_abort "\n $message"
}
}
}
proc ASC_get_data_file_name { unit } \
{
#
# Returns the filename for ASCII Data File depending on the
# specified unit.
#
global asc_units
if {$unit == $asc_units(mm)} \
{
set env_var_name UGII_CAM_LIBRARY_FIXTURE_METRIC_DIR
} \
else \
{
set env_var_name UGII_CAM_LIBRARY_FIXTURE_ENGLISH_DIR
}
set env_var [MOM_ask_env_var $env_var_name]
if { $env_var == "" } \
{
return ""
}
set fname ""
set fname [append fname $env_var "fixture_database.dat"]
return $fname
}
proc ASC_set_part_unit {} \
{
global dbc_part_units
global dbc_search_units
global asc_units
MOM_ask_part_units ;# writes to dbc_part_units
if {$dbc_part_units == "metric"} \
{
set dbc_search_units $asc_units(mm)
} \
else \
{
set dbc_search_units $asc_units(inch)
}
}
#---------------------------------------------
proc DBC_retrieve {} {
#---------------------------------------------
#
# global input
# ------------
global asc_debug
global asc_units
global dbc_libref
global dbc_retrieve_var_list
#
# global output
# -------------
# global dbc_holding_system
#
# Look for the desired libref
#
set found [ASC_array_search_fixture $dbc_libref db_row]
# fixture units
set units [ASC_ask_att_val _unitt $db_row "" $asc_units(mm) flag]
if { "$units" == "$asc_units(mm)" } \
{
set dbc_fixture_units 0
} \
else \
{
set dbc_fixture_units 1
}
#
# fixture description
global dbc_fixture_description
set dbc_fixture_description ""
#
# partfile name for fixture assembly
#
global dbc_fixture_part_name
set dbc_fixture_part_name ""
append dbc_fixture_part_name $dbc_libref ".prt"
#
# Ask the necessary attribute values
#
set dbc_fixture_description \
[ASC_ask_att_val DESCR $db_row "" unknown flag]
}
proc ASC_array_search_fixture { 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 fixture data from external library."
set message "$message \n Fixture 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_fixture $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_append_unit_to_query
ASC_execute_query
}
#---------------------------------------------
proc DBC_execute_query_for_count {} {
#---------------------------------------------
ASC_append_unit_to_query
ASC_execute_query_for_count
}
#---------------------------------------------
proc DBC_insert {} {
#---------------------------------------------
ASC_insert
}
proc ASC_append_unit_to_query {} {
global dbc_search_units
global dbc_query
global asc_units
global asc_debug
set lhs "\$asc_database(\$db_row,_unitt)"
set subquery1 "($lhs == \"$asc_units(unknown)\")"
set subquery2 "($lhs == \"$dbc_search_units\")"
set subquery "($subquery1 || $subquery2)"
if { $asc_debug == 1 } \
{
puts $subquery
}
set dbc_query "$dbc_query && $subquery"
}
#------------------------------------------------------------------------
proc DBC_write { } {
#------------------------------------------------------------------------
global asc_database_name
set asc_database_name "fixture_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 "###############################################################################
# fixture_database.dat - database file for fixture database stored as ascii file
###############################################################################
#############################################################################
## Data file for the Machine fixtures
##
##
## REVISED:
## $dbc_logname $out_daytime
##
## The following key words for Attribute ids are defined
##
## LIBRF - unique record identifier
## T - fixture type - 1-Vice
## 2-Chuck
## DESCR - Short description ( Manufacturer, Product ID, etc.)
## MAXWIDTH - max clamping width for vices
## MINDIA - min clamping diameter for chucks
## MAXDIA - max clamping diameter for chucks
##
##############################################################################"
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 "#--------------------------------------------------------------------------------"
}