From 4a134cf2d09fcdcafada3cb765f8a7045848a707 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Thu, 30 Jan 2014 12:47:18 +1100 Subject: [PATCH] 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. --- ...otion_control_commissioning_checklist.csv} | 23 +++- .../motors/generated_motor_configuration.tcl | 122 +++++++++--------- site_ansto/instrument/util/genmotconf.tcl | 101 ++++++++++----- .../instrument/util/genmotconf_procs.tcl | 8 +- 4 files changed, 152 insertions(+), 102 deletions(-) rename site_ansto/instrument/bilby/config/motors/{COLLIMATOR_POSITIONS_D.csv => Bilby_motion_control_commissioning_checklist.csv} (80%) diff --git a/site_ansto/instrument/bilby/config/motors/COLLIMATOR_POSITIONS_D.csv b/site_ansto/instrument/bilby/config/motors/Bilby_motion_control_commissioning_checklist.csv similarity index 80% rename from site_ansto/instrument/bilby/config/motors/COLLIMATOR_POSITIONS_D.csv rename to site_ansto/instrument/bilby/config/motors/Bilby_motion_control_commissioning_checklist.csv index 0cf2f5ad..d17f687d 100755 --- a/site_ansto/instrument/bilby/config/motors/COLLIMATOR_POSITIONS_D.csv +++ b/site_ansto/instrument/bilby/config/motors/Bilby_motion_control_commissioning_checklist.csv @@ -70,6 +70,15 @@ ap8_D40,32629 ap8_fwd_enc_lim,47285 ap8_mc,mc2 ap8_rev_enc_lim,7189 +att_axis,att +att_fwd_enc_lim,33394989 +att_mc,mc4 +att_pos1,33373433 +att_pos2,33291514 +att_pos3,33209595 +att_pos4,33127674 +att_pos5,33045750 +att_rev_enc_lim,33021197 col1_aperture,541261 col1_axis,A col1_fwd_enc_lim,556961 @@ -118,6 +127,14 @@ col8_fwd_enc_lim,563017 col8_guide,273474 col8_mc,mc1 col8_rev_enc_lim,12085 -vs_100X40,741128 -vs_axis,A -vs_mc,mc3 +sdh_5a_in,1535698 +sdh_5b_in,3747542 +sdh_axis,D +sdh_fwd_enc_lim,1114132 +sdh_mc,mc4 +sdh_rev_enc_lim,4208665 +vs_axis,B +vs_fwd_enc_lim,1303768 +vs_glass_in,741128 +vs_mc,mc4 +vs_rev_enc_lim,4663634 diff --git a/site_ansto/instrument/bilby/config/motors/generated_motor_configuration.tcl b/site_ansto/instrument/bilby/config/motors/generated_motor_configuration.tcl index d68c978c..01a08900 100644 --- a/site_ansto/instrument/bilby/config/motors/generated_motor_configuration.tcl +++ b/site_ansto/instrument/bilby/config/motors/generated_motor_configuration.tcl @@ -1,16 +1,16 @@ #### SICS motor driver configuration #### -# Generated by: ../../../util/genmotconf.tcl Bilby_Motion_control_axes.csv COLLIMATOR_POSITIONS_D.csv sicsmot_attlist.csv hdb_info.csv -# Date: 2014-01-15T15:36:43 +# Generated by: ../../../util/genmotconf.tcl Bilby_Motion_control_axes.csv Bilby_motion_control_commissioning_checklist.csv sicsmot_attlist.csv hdb_info.csv +# Date: 2014-01-24T15:37:28 # Generated from the following files, # file1: Bilby_Motion_control_axes.csv -# file2: COLLIMATOR_POSITIONS_D.csv +# file2: Bilby_motion_control_commissioning_checklist.csv # file3: sicsmot_attlist.csv # file4: hdb_info.csv # Load motor driver configuration parameters set flist [list\ {Bilby_Motion_control_axes.csv}\ - {COLLIMATOR_POSITIONS_D.csv}\ + {Bilby_motion_control_commissioning_checklist.csv}\ {sicsmot_attlist.csv}\ {hdb_info.csv}\ ] @@ -38,9 +38,9 @@ if {$sim_mode == true} { } if {$sim_mode == false} { + MakeAsyncQueue mc4 DMC2280 [dict get $::MOTOR_HOSTPORT MC4 HOST] [dict get $::MOTOR_HOSTPORT MC4 PORT] MakeAsyncQueue mc1 DMC2280 [dict get $::MOTOR_HOSTPORT MC1 HOST] [dict get $::MOTOR_HOSTPORT MC1 PORT] MakeAsyncQueue mc2 DMC2280 [dict get $::MOTOR_HOSTPORT MC2 HOST] [dict get $::MOTOR_HOSTPORT MC2 PORT] - MakeAsyncQueue mc3 DMC2280 [dict get $::MOTOR_HOSTPORT MC3 HOST] [dict get $::MOTOR_HOSTPORT MC3 PORT] } # ap1 configuration @@ -55,11 +55,11 @@ Motor ap1 $motor_driver_type [params\ maxDecel $ap1_maxdecel\ stepsPerX $ap1_steps_per_x\ posit_count 5\ - posit_1 $ap1_100X100\ - posit_2 $ap1_40X40\ - posit_3 $ap1_D10\ - posit_4 $ap1_D20\ - posit_5 $ap1_D40\ + posit_1 $ap1_D10\ + posit_2 $ap1_D20\ + posit_3 $ap1_D40\ + posit_4 $ap1_40X40\ + posit_5 $ap1_100X100\ absEnc 1\ absEncHome $ap1_absenchome\ cntsPerX $ap1_cnts_per_x] @@ -81,11 +81,11 @@ Motor ap2 $motor_driver_type [params\ maxDecel $ap2_maxdecel\ stepsPerX $ap2_steps_per_x\ posit_count 5\ - posit_1 $ap2_100X100\ - posit_2 $ap2_40X40\ - posit_3 $ap2_D10\ - posit_4 $ap2_D20\ - posit_5 $ap2_D40\ + posit_1 $ap2_D10\ + posit_2 $ap2_D20\ + posit_3 $ap2_D40\ + posit_4 $ap2_40X40\ + posit_5 $ap2_100X100\ absEnc 1\ absEncHome $ap2_absenchome\ cntsPerX $ap2_cnts_per_x] @@ -107,11 +107,11 @@ Motor ap3 $motor_driver_type [params\ maxDecel $ap3_maxdecel\ stepsPerX $ap3_steps_per_x\ posit_count 5\ - posit_1 $ap3_100X100\ - posit_2 $ap3_40X40\ - posit_3 $ap3_D10\ - posit_4 $ap3_D20\ - posit_5 $ap3_D40\ + posit_1 $ap3_D10\ + posit_2 $ap3_D20\ + posit_3 $ap3_D40\ + posit_4 $ap3_40X40\ + posit_5 $ap3_100X100\ absEnc 1\ absEncHome $ap3_absenchome\ cntsPerX $ap3_cnts_per_x] @@ -133,11 +133,11 @@ Motor ap4 $motor_driver_type [params\ maxDecel $ap4_maxdecel\ stepsPerX $ap4_steps_per_x\ posit_count 5\ - posit_1 $ap4_100X100\ - posit_2 $ap4_40X40\ - posit_3 $ap4_D10\ - posit_4 $ap4_D20\ - posit_5 $ap4_D40\ + posit_1 $ap4_D10\ + posit_2 $ap4_D20\ + posit_3 $ap4_D40\ + posit_4 $ap4_40X40\ + posit_5 $ap4_100X100\ absEnc 1\ absEncHome $ap4_absenchome\ cntsPerX $ap4_cnts_per_x] @@ -159,11 +159,11 @@ Motor ap5 $motor_driver_type [params\ maxDecel $ap5_maxdecel\ stepsPerX $ap5_steps_per_x\ posit_count 5\ - posit_1 $ap5_100X100\ - posit_2 $ap5_40X40\ - posit_3 $ap5_D10\ - posit_4 $ap5_D20\ - posit_5 $ap5_D40\ + posit_1 $ap5_D10\ + posit_2 $ap5_D20\ + posit_3 $ap5_D40\ + posit_4 $ap5_40X40\ + posit_5 $ap5_100X100\ absEnc 1\ absEncHome $ap5_absenchome\ cntsPerX $ap5_cnts_per_x] @@ -185,11 +185,11 @@ Motor ap6 $motor_driver_type [params\ maxDecel $ap6_maxdecel\ stepsPerX $ap6_steps_per_x\ posit_count 5\ - posit_1 $ap6_100X100\ - posit_2 $ap6_40X40\ - posit_3 $ap6_D10\ - posit_4 $ap6_D20\ - posit_5 $ap6_D40\ + posit_1 $ap6_D10\ + posit_2 $ap6_D20\ + posit_3 $ap6_D40\ + posit_4 $ap6_40X40\ + posit_5 $ap6_100X100\ absEnc 1\ absEncHome $ap6_absenchome\ cntsPerX $ap6_cnts_per_x] @@ -211,11 +211,11 @@ Motor ap7 $motor_driver_type [params\ maxDecel $ap7_maxdecel\ stepsPerX $ap7_steps_per_x\ posit_count 5\ - posit_1 $ap7_100X100\ - posit_2 $ap7_40X40\ - posit_3 $ap7_D10\ - posit_4 $ap7_D20\ - posit_5 $ap7_D40\ + posit_1 $ap7_D10\ + posit_2 $ap7_D20\ + posit_3 $ap7_D40\ + posit_4 $ap7_40X40\ + posit_5 $ap7_100X100\ absEnc 1\ absEncHome $ap7_absenchome\ cntsPerX $ap7_cnts_per_x] @@ -237,11 +237,11 @@ Motor ap8 $motor_driver_type [params\ maxDecel $ap8_maxdecel\ stepsPerX $ap8_steps_per_x\ posit_count 5\ - posit_1 $ap8_100X100\ - posit_2 $ap8_40X40\ - posit_3 $ap8_D10\ - posit_4 $ap8_D20\ - posit_5 $ap8_D40\ + posit_1 $ap8_D10\ + posit_2 $ap8_D20\ + posit_3 $ap8_D40\ + posit_4 $ap8_40X40\ + posit_5 $ap8_100X100\ absEnc 1\ absEncHome $ap8_absenchome\ cntsPerX $ap8_cnts_per_x] @@ -263,8 +263,8 @@ Motor col1 $motor_driver_type [params\ maxDecel $col1_maxdecel\ stepsPerX $col1_steps_per_x\ posit_count 2\ - posit_1 $col1_aperture\ - posit_2 $col1_guide\ + posit_1 $col1_guide\ + posit_2 $col1_aperture\ absEnc 1\ absEncHome $col1_absenchome\ cntsPerX $col1_cnts_per_x] @@ -286,8 +286,8 @@ Motor col2 $motor_driver_type [params\ maxDecel $col2_maxdecel\ stepsPerX $col2_steps_per_x\ posit_count 2\ - posit_1 $col2_aperture\ - posit_2 $col2_guide\ + posit_1 $col2_guide\ + posit_2 $col2_aperture\ absEnc 1\ absEncHome $col2_absenchome\ cntsPerX $col2_cnts_per_x] @@ -309,8 +309,8 @@ Motor col3 $motor_driver_type [params\ maxDecel $col3_maxdecel\ stepsPerX $col3_steps_per_x\ posit_count 2\ - posit_1 $col3_aperture\ - posit_2 $col3_guide\ + posit_1 $col3_guide\ + posit_2 $col3_aperture\ absEnc 1\ absEncHome $col3_absenchome\ cntsPerX $col3_cnts_per_x] @@ -332,8 +332,8 @@ Motor col4 $motor_driver_type [params\ maxDecel $col4_maxdecel\ stepsPerX $col4_steps_per_x\ posit_count 2\ - posit_1 $col4_aperture\ - posit_2 $col4_guide\ + posit_1 $col4_guide\ + posit_2 $col4_aperture\ absEnc 1\ absEncHome $col4_absenchome\ cntsPerX $col4_cnts_per_x] @@ -355,8 +355,8 @@ Motor col5 $motor_driver_type [params\ maxDecel $col5_maxdecel\ stepsPerX $col5_steps_per_x\ posit_count 2\ - posit_1 $col5_aperture\ - posit_2 $col5_guide\ + posit_1 $col5_guide\ + posit_2 $col5_aperture\ absEnc 1\ absEncHome $col5_absenchome\ cntsPerX $col5_cnts_per_x] @@ -378,8 +378,8 @@ Motor col6 $motor_driver_type [params\ maxDecel $col6_maxdecel\ stepsPerX $col6_steps_per_x\ posit_count 2\ - posit_1 $col6_aperture\ - posit_2 $col6_guide\ + posit_1 $col6_guide\ + posit_2 $col6_aperture\ absEnc 1\ absEncHome $col6_absenchome\ cntsPerX $col6_cnts_per_x] @@ -401,8 +401,8 @@ Motor col7 $motor_driver_type [params\ maxDecel $col7_maxdecel\ stepsPerX $col7_steps_per_x\ posit_count 2\ - posit_1 $col7_aperture\ - posit_2 $col7_guide\ + posit_1 $col7_guide\ + posit_2 $col7_aperture\ absEnc 1\ absEncHome $col7_absenchome\ cntsPerX $col7_cnts_per_x] @@ -424,8 +424,8 @@ Motor col8 $motor_driver_type [params\ maxDecel $col8_maxdecel\ stepsPerX $col8_steps_per_x\ posit_count 2\ - posit_1 $col8_aperture\ - posit_2 $col8_guide\ + posit_1 $col8_guide\ + posit_2 $col8_aperture\ absEnc 1\ absEncHome $col8_absenchome\ cntsPerX $col8_cnts_per_x] diff --git a/site_ansto/instrument/util/genmotconf.tcl b/site_ansto/instrument/util/genmotconf.tcl index f48cfeb8..59dd373a 100755 --- a/site_ansto/instrument/util/genmotconf.tcl +++ b/site_ansto/instrument/util/genmotconf.tcl @@ -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 diff --git a/site_ansto/instrument/util/genmotconf_procs.tcl b/site_ansto/instrument/util/genmotconf_procs.tcl index 478a9ad2..0544d2d1 100755 --- a/site_ansto/instrument/util/genmotconf_procs.tcl +++ b/site_ansto/instrument/util/genmotconf_procs.tcl @@ -23,8 +23,8 @@ proc parse_file {fname fhr fhe} { puts $fhr "Add ::${mn}_encatts($matt) = $val" set ::${mn}_encatts($matt) $val } else { - puts $fhr "Add ::${mn}($matt) = $val" - set ::${mn}($matt) $val + puts $fhr "Add ::${mn}_attarr($matt) = $val" + set ::${mn}_attarr($matt) $val } incr ::motor_attcnt($mn) if { $matt == "mc" } { @@ -106,8 +106,8 @@ puts $fhmc \} # @param posnum Number of discrete positions # @param posit_list Name of global list of name value pairs, "posit_n pos". Can be empty. proc mk_motconf {mot fh absEnc posnum posit_list} { - set mc [set ::${mot}(mc)] - set axis [set ::${mot}(axis)] + set mc [set ::${mot}_attarr(mc)] + set axis [set ::${mot}_attarr(axis)] set units ${mot}_units set hardlowerlim ${mot}_rev_lim set hardupperlim ${mot}_fwd_lim