genmotconf.tcl now sorts the posit_n parameters by value.
Sort is ascending if cntsperx is positive, descending if negative. Improve error and report logs generated by genmotconf.tcl It is not an error if a missing attributed can be initialised with a default value by genmotconf.tcl. Replace the COLLIMATOR_POSITIONS.csv with Bilby_motion_control_commissioning_checklist.csv Generate new "generated_motor_configuration.tcl" file.
This commit is contained in:
committed by
Ferdi Franceschini
parent
f6ae3c62f7
commit
4a134cf2d0
@@ -22,26 +22,30 @@ source [file dirname $argv0]/genmotconf_procs.tcl
|
||||
|
||||
set ERRCNT 0
|
||||
set MOTCFG_CNT 0
|
||||
set CANCFG_CNT 0
|
||||
set FAILED_MOTCFG_CNT 0
|
||||
# MOT_ATTLIST: Attributes required to configure an axis without an encoder
|
||||
# ENC_ATTLIST: Attributes required to describe an encoder.
|
||||
# NOTE Encoder readings for the limit switch positions are required.
|
||||
# If the encoder "home" reading is not supplied it is set equal to rev_enc_lim
|
||||
# If the encoder "absenchome" reading is not supplied it is set equal to rev_enc_lim
|
||||
# ENCMOT_ATTLIST: Attributes which describe an axis which has both a motor and encoder.
|
||||
# REQ_ATTLIST: List of attributes required to generate a configuration for a motor object.
|
||||
# SICS_CFG_ATTLIST: Extra attributes required to configure a motor object in SICS.
|
||||
# SICS_CFG_MOTATTLIST: Extra attributes required to configure a motor object in SICS.
|
||||
# SICS_CFG_ENCMOTATTLIST: Extra attributes required to configure a motor object with an encoder in SICS.
|
||||
# ALL_ATTRIBUTES: List of all attributes recognised by this program.
|
||||
#
|
||||
# Attributes which are not in these lists are assumed to define the encoder
|
||||
# readings for each position on an axis which has a set of meaningful positions
|
||||
# such as apertures or multi-sample tables.
|
||||
set MOT_ATTLIST [lsort {axis mc steps_per_x}]
|
||||
set ENC_ATTLIST [lsort {absenchome cnts_per_x fwd_enc_lim rev_enc_lim}]
|
||||
set ENCMOT_ATTLIST [lsort [concat $MOT_ATTLIST ENCMOT_ATTLIST]]
|
||||
set SICS_CFG_ATTLIST [lsort {home fwd_lim rev_lim maxspeed maxaccel maxdecel part units}]
|
||||
set REQ_ATTLIST [lsort [concat $MOT_ATTLIST $SICS_CFG_ATTLIST]]
|
||||
set ALL_ATTRIBUTES [lsort [concat $ENCMOT_ATTLIST $SICS_CFG_ATTLIST]]
|
||||
set ENC_ATTLIST [lsort {cnts_per_x fwd_enc_lim rev_enc_lim}]
|
||||
set ENCMOT_ATTLIST [lsort [concat $MOT_ATTLIST $ENC_ATTLIST]]
|
||||
set SICS_CFG_MOTATTLIST [lsort {home fwd_lim rev_lim maxspeed maxaccel maxdecel part units}]
|
||||
set SICS_CFG_ENCMOTATTLIST [lsort [concat absenchome $SICS_CFG_MOTATTLIST]]
|
||||
set REQ_ATTLIST [lsort [concat $MOT_ATTLIST $SICS_CFG_MOTATTLIST]]
|
||||
set ALL_ATTRIBUTES [lsort [concat $ENCMOT_ATTLIST $SICS_CFG_ENCMOTATTLIST]]
|
||||
|
||||
array set autogen_attarr {}
|
||||
set scriptname [file tail [file rootname $argv0]]
|
||||
set file_list $argv
|
||||
|
||||
@@ -107,28 +111,23 @@ set fhmc [open "generated_motor_configuration.tcl" "w"]
|
||||
# Write configuration file header and make asyncqueues
|
||||
mk_cfg_header $fhmc
|
||||
puts $fhmc ""
|
||||
|
||||
foreach mn [lsort [array names motor_attcnt]] {
|
||||
set mot_attlist [lsort [array names $mn]]
|
||||
set mot_encattlist [lsort [array names ${mn}_encatts]]
|
||||
set num_encatts [llength $mot_encattlist]
|
||||
set missing_enc_atts [setdiff $ENC_ATTLIST $mot_encattlist]
|
||||
set num_missing_encatts [llength $missing_enc_atts]
|
||||
set encmot_attlist [lsort [array names ${mn}_encatts]]
|
||||
set mot_attlist [lsort [concat [array names ${mn}_attarr] [array names ${mn}_encatts]]]
|
||||
set num_encatts_defined [llength $encmot_attlist]
|
||||
set posnum 0
|
||||
|
||||
# Decide if a motor configuration should be generated.
|
||||
if [subset $REQ_ATTLIST $mot_attlist] {
|
||||
if [subset $ALL_ATTRIBUTES $mot_attlist] {
|
||||
set mk_config 1
|
||||
} elseif [subset $REQ_ATTLIST $mot_attlist] {
|
||||
set mk_config 1
|
||||
} else {
|
||||
if {$num_missing_encatts == 0} {
|
||||
set mk_config 1
|
||||
} else {
|
||||
set mk_config 0
|
||||
}
|
||||
}
|
||||
set mk_config 0
|
||||
}
|
||||
|
||||
# Does this motor have an absolute encoder?
|
||||
if {$num_missing_encatts == 0} {
|
||||
if {$num_encatts_defined > 0} {
|
||||
set absenc 1
|
||||
} else {
|
||||
set absenc 0
|
||||
@@ -143,12 +142,28 @@ foreach mn [lsort [array names motor_attcnt]] {
|
||||
set mk_missing_atts 0
|
||||
}
|
||||
|
||||
if [info exists ${mn}_encatts(cnts_per_x)] {
|
||||
# Assume that the values of any attributes we don't recognise are encoder
|
||||
# readings for a "posit" motor.
|
||||
set posit_list {}
|
||||
foreach att [setdiff $mot_attlist $ALL_ATTRIBUTES] {
|
||||
incr posnum
|
||||
lappend posit_list "posit_${posnum} \$${mn}_$att"
|
||||
set posit_list {}
|
||||
#TODO Sort posits by value can we take into acount if cnts_per_x is -ve or +ve?
|
||||
set posit_nameval_list {}
|
||||
foreach att [setdiff $mot_attlist $ALL_ATTRIBUTES] {
|
||||
lappend posit_nameval_list "$att [set ${mn}_attarr($att)]"
|
||||
}
|
||||
if {[llength $posit_nameval_list] > 0} {
|
||||
set posnum 0
|
||||
if { [set ${mn}_encatts(cnts_per_x)] > 0} {
|
||||
set sorted_nv_list [join [lsort -integer -increasing -index 1 $posit_nameval_list]]
|
||||
} else {
|
||||
set sorted_nv_list [join [lsort -integer -decreasing -index 1 $posit_nameval_list]]
|
||||
}
|
||||
foreach {att v} $sorted_nv_list {
|
||||
incr posnum
|
||||
lappend posit_list "posit_${posnum} \$${mn}_$att"
|
||||
puts "posit_${posnum} \$${mn}_$att = $v"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Generate a motor configuration and/or a list of missing attributes.
|
||||
@@ -157,30 +172,48 @@ foreach mn [lsort [array names motor_attcnt]] {
|
||||
puts $fhr "Configured $mn"
|
||||
incr MOTCFG_CNT
|
||||
} else {
|
||||
set missing_atts [lsort [concat $missing_enc_atts [setdiff $::REQ_ATTLIST [array names $mn]]]]
|
||||
puts $fhe "$mn attributes missing: $missing_atts"
|
||||
set missing_motatts [setdiff $MOT_ATTLIST $mot_attlist]
|
||||
set missing_encatts [setdiff $ENC_ATTLIST $encmot_attlist]
|
||||
set num_missing_motatts [llength $missing_motatts]
|
||||
set num_missing_encatts [llength $missing_encatts]
|
||||
if { $num_missing_encatts > 0 && $absenc} {
|
||||
puts $fhe "$mn: found partial config for an axis with an absolute encoder,"
|
||||
puts $fhe " need: ([concat $missing_motatts $missing_encatts]) to configure the $mn motor with an encoder"
|
||||
} elseif { $num_missing_motatts > 0 } {
|
||||
puts $fhe "$mn: found partial config for an axis,"
|
||||
puts $fhe " need: ($missing_motatts) to configure $mn motor"
|
||||
puts $fhe " also need: ($missing_encatts) if $mn has an encoder"
|
||||
}
|
||||
incr FAILED_MOTCFG_CNT
|
||||
incr ERRCNT
|
||||
if {$mk_missing_atts} {
|
||||
set undef_atts [setdiff [lsort "absenchome $SICS_CFG_ATTLIST"] $mot_attlist]
|
||||
set undef_atts [setdiff [lsort "absenchome $SICS_CFG_MOTATTLIST"] $mot_attlist]
|
||||
foreach att $undef_atts {
|
||||
set attval [gen_attval $mn $att]
|
||||
if {$attval != "NOATT"} {
|
||||
lappend missing_attlist "${mn}_$att,$attval"
|
||||
lappend autogen_attarr($mn) "${mn}_$att,$attval"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# If there are any missing attributes then write them to a file.
|
||||
if [info exists missing_attlist] {
|
||||
# If there are any autogenerated attributes then write them to a file.
|
||||
if {[array size autogen_attarr] > 0} {
|
||||
set fh [open "missing_attlist.csv" "w"]
|
||||
foreach attval [lsort $missing_attlist] {
|
||||
puts $fh $attval
|
||||
puts "The attributes with default values needed to complete the configuration of the following motors has been written to missing_attlist.csv,"
|
||||
foreach n [lsort [array names autogen_attarr]] {
|
||||
puts -nonewline "$n "
|
||||
foreach attval [lsort $autogen_attarr($n)] {
|
||||
puts $fh $attval
|
||||
}
|
||||
}
|
||||
close $fh
|
||||
puts "Generated list of missing attributes in missing_attlist.csv. You should rename this if you want to keep it."
|
||||
puts ""
|
||||
puts "Rename missing_attlist.csv and redo to generate a configuration file which also includes the motors listed above."
|
||||
puts "Eg,"
|
||||
puts "mv missing_attlist.csv sicsmot_attlist.csv"
|
||||
puts "$argv0 $argv sicsmot_attlist.csv"
|
||||
}
|
||||
|
||||
# The SICS init code calls motor_set_sobj_attributes. It can be redefined in
|
||||
|
||||
Reference in New Issue
Block a user