Add an OUT position to apertures. Copy bug fixes and improvements from ics1-bilby.
Also provide a motor object to read the second encoder on the velocity selector translation stage for diagnostic purposes.
This commit is contained in:
@ -11,28 +11,28 @@ namespace import ::scobj::shutters::selrs
|
||||
# Eg, mot fixed 1
|
||||
# Define "proc motor_set_sobj_attributes {}" if we need to define extra sicslist attributes for some motors.
|
||||
|
||||
foreach pos {33.662109 48.691406 63.621826 78.695068 100.678711} {
|
||||
foreach pos {1.0 33.662109 48.691406 63.621826 78.695068 100.678711} {
|
||||
lappend ap1_positions [expr $pos + 0]
|
||||
}
|
||||
foreach pos {40.924072 55.986328 71.015625 86.088867 108.061523} {
|
||||
foreach pos {2.0 40.924072 55.986328 71.015625 86.088867 108.061523} {
|
||||
lappend ap2_positions [expr $pos - 1.0]
|
||||
}
|
||||
foreach pos {31.651611 46.724854 61.622314 76.596680 98.712158} {
|
||||
foreach pos {1.0 31.651611 46.724854 61.622314 76.596680 98.712158} {
|
||||
lappend ap3_positions [expr $pos + 0]
|
||||
}
|
||||
foreach pos {36.947021 51.943359 66.939697 81.914062 103.930664} {
|
||||
foreach pos {1.0 36.947021 51.943359 66.939697 81.914062 103.930664} {
|
||||
lappend ap4_positions [expr $pos + 0]
|
||||
}
|
||||
foreach pos {33.651123 48.691406 63.676758 78.695068 100.678711} {
|
||||
foreach pos {1.0 33.651123 48.691406 63.676758 78.695068 100.678711} {
|
||||
lappend ap5_positions [expr $pos + 0]
|
||||
}
|
||||
foreach pos {38.402710 53.481445 68.378906 83.232422 105.424805} {
|
||||
foreach pos {1.0 38.402710 53.481445 68.378906 83.232422 105.424805} {
|
||||
lappend ap6_positions [expr $pos + 0]
|
||||
}
|
||||
foreach pos {31.942749 46.966553 61.995850 77.025146 99.074707} {
|
||||
foreach pos {1.0 31.942749 46.966553 61.995850 77.025146 99.074707} {
|
||||
lappend ap7_positions [expr $pos + 0]
|
||||
}
|
||||
foreach pos {40.830688 55.821533 70.966187 85.792236 107.880249} {
|
||||
foreach pos {1.0 40.830688 55.821533 70.966187 85.792236 107.880249} {
|
||||
lappend ap8_positions [expr $pos + 0]
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ for {set n 1} {$n <= 8} {incr n} {
|
||||
pc$n position_names guide apertures
|
||||
make_coll_motor_1 a$n a$n ap$n count
|
||||
ap$n positions {*}[set ap${n}_positions]
|
||||
ap$n position_names D10 D20 D40 S40 R100
|
||||
ap$n position_names OUT D10 D20 D40 S40 R100
|
||||
}
|
||||
|
||||
# Make a position-motor for the attenuator
|
||||
@ -220,12 +220,10 @@ proc nguide { {num "REPORTNUM"} {sel_ap_name "NONE"} {aprest_name "NONE"}} {
|
||||
set catch_status [ catch {
|
||||
set CheckDrive false
|
||||
set ap_names { D10 D20 D40 S40 R100 }
|
||||
array set EMSG {
|
||||
invalidarg "Invalid arguments"
|
||||
gaps "There are gaps in the sequence of selected guides"
|
||||
drivefailed "Drive failed."
|
||||
misaligned "Misalignment. At least one guide is not in the aperture or guide position"
|
||||
apfailed "Failed to set apertures"
|
||||
array set ETYPE_LIST {
|
||||
gaps "(gaps between guides)"
|
||||
misaligned "(one or more guides not in the aperture or guide position)"
|
||||
apfailed "(failed to set apertures)"
|
||||
}
|
||||
set GUIDEPOSIT 1
|
||||
set APPOSIT 2
|
||||
@ -233,21 +231,22 @@ proc nguide { {num "REPORTNUM"} {sel_ap_name "NONE"} {aprest_name "NONE"}} {
|
||||
set apdrvlist {}
|
||||
set pcdrvlist {}
|
||||
set ap_target_list {}
|
||||
set ETYPE ""
|
||||
if {$num != "REPORTNUM"} {
|
||||
if {$num >= 0 && $num < 7} {
|
||||
if { $sel_ap_name == "NONE" || $aprest_name == "NONE" } {
|
||||
error "$EMSG(invalidarg): You must provide two aperture arguments"
|
||||
error "You must provide two aperture arguments"
|
||||
} elseif { [lsearch -nocase $ap_names $sel_ap_name] == -1 } {
|
||||
error "$EMSG(invalidarg): $sel_ap_name should be one of $ap_names"
|
||||
error "$sel_ap_name should be one of $ap_names"
|
||||
} elseif { [lsearch -nocase $ap_names $aprest_name] == -1 } {
|
||||
error "$EMSG(invalidarg): $aprest_name should be one of $ap_names"
|
||||
error "$aprest_name should be one of $ap_names"
|
||||
}
|
||||
}
|
||||
if {$num == 7} {
|
||||
if { $sel_ap_name == "NONE"} {
|
||||
error "$EMSG(invalidarg): You must provide one aperture argument"
|
||||
error "You must provide one aperture argument"
|
||||
} elseif { [lsearch -nocase $ap_names $sel_ap_name] == -1 } {
|
||||
error "$EMSG(invalidarg): $sel_ap_name should be one of $ap_names"
|
||||
error "$sel_ap_name should be one of $ap_names"
|
||||
}
|
||||
}
|
||||
if {$num >= 0 && $num <= 8} {
|
||||
@ -278,7 +277,7 @@ proc nguide { {num "REPORTNUM"} {sel_ap_name "NONE"} {aprest_name "NONE"}} {
|
||||
drive {*}$pcdrvlist
|
||||
}
|
||||
} else {
|
||||
error "$EMSG(invalidarg)"
|
||||
error "Invalid arguments"
|
||||
}
|
||||
# Select Apertures
|
||||
if {$num >= 0 && $num < 8} {
|
||||
@ -308,47 +307,54 @@ proc nguide { {num "REPORTNUM"} {sel_ap_name "NONE"} {aprest_name "NONE"}} {
|
||||
set ap_posname_list {}
|
||||
set table_posname_list {}
|
||||
set ng 0
|
||||
set last_guide 0
|
||||
# COUNT number of tables in guide position
|
||||
for {set n 1} {$n <= 8} {incr n} {
|
||||
set currpos [SplitReply [pc$n]]
|
||||
set table_guideunit [SplitReply [pc$n posit2unit $GUIDEPOSIT]]
|
||||
set table_appunit [SplitReply [pc$n posit2unit $APPOSIT]]
|
||||
set tol [SplitReply [pc$n precision]]
|
||||
if {[expr {abs($currpos - $table_guideunit)}] <= $tol} {
|
||||
set pctol [SplitReply [pc$n precision]]
|
||||
set aptol [SplitReply [ap$n precision]]
|
||||
# Tables should be in one of the allowed operating positions.
|
||||
if {[expr {abs($currpos - $table_guideunit)}] <= $pctol} {
|
||||
incr ng
|
||||
} elseif {[expr {abs($currpos - $table_appunit)}] <= $tol} {
|
||||
# Table in aperture position
|
||||
break
|
||||
set last_guide $n
|
||||
} elseif {[expr {abs($currpos - $table_appunit)}] <= $aptol} {
|
||||
continue
|
||||
} else {
|
||||
set ng -9999
|
||||
set ETYPE $ETYPE_LIST(misaligned)
|
||||
set MISCONFIGURED true
|
||||
break
|
||||
}
|
||||
}
|
||||
if {$ng < 8} {
|
||||
if { !$MISCONFIGURED && ($last_guide != $ng) } {
|
||||
# There are gaps in the guide selection
|
||||
set ng -9999
|
||||
set ETYPE $ETYPE_LIST(gaps)
|
||||
set MISCONFIGURED true
|
||||
}
|
||||
if {$ng >= 0 && $ng < 8} {
|
||||
# Check first aperture selected after guides
|
||||
set n [ expr $ng + 1]
|
||||
set currpos [SplitReply [pc$n]]
|
||||
set table_appunit [SplitReply [pc$n posit2unit $APPOSIT]]
|
||||
set tol [SplitReply [pc$n precision]]
|
||||
if {[expr {abs($currpos - $table_appunit)}] <= $tol} {
|
||||
if {[inpos ap$n] == "false"} {
|
||||
set MISCONFIGURED true
|
||||
}
|
||||
} else {
|
||||
if {[inpos ap$n] == "false"} {
|
||||
set ETYPE $ETYPE_LIST(apfailed)
|
||||
set MISCONFIGURED true
|
||||
}
|
||||
if {$ng < 7} {
|
||||
if {$ng >= 0 && $ng < 7} {
|
||||
# Check that the rest of the apertures are all the same
|
||||
set apn "ap[expr $ng + 2]"
|
||||
if [inpos $apn] {
|
||||
set pname [SplitReply [posname $apn]]
|
||||
for {set n [expr $ng + 3]} {$n <= 8} {incr n} {
|
||||
if { $pname != [SplitReply [posname ap$n]] } {
|
||||
set ETYPE $ETYPE_LIST(apfailed)
|
||||
set MISCONFIGURED true
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
set ETYPE $ETYPE_LIST(apfailed)
|
||||
set MISCONFIGURED true
|
||||
}
|
||||
}
|
||||
@ -359,21 +365,21 @@ proc nguide { {num "REPORTNUM"} {sel_ap_name "NONE"} {aprest_name "NONE"}} {
|
||||
lappend ap_posname_list [posname ap$n]
|
||||
}
|
||||
if {$MISCONFIGURED} {
|
||||
return "nguide = MISCONFIGURED: $ng guides $table_posname_list apertures $ap_posname_list"
|
||||
return "nguide = $ng guides, MISCONFIGURED $ETYPE: guides $table_posname_list apertures $ap_posname_list"
|
||||
}
|
||||
|
||||
if {$CheckDrive} {
|
||||
set drive_ok true
|
||||
if {$ng != $num} {
|
||||
set drive_ok false
|
||||
clientput "$EMSG(drivefailed): Failed to select guides"
|
||||
clientput "Drive failed: Failed to select guides"
|
||||
}
|
||||
foreach {ap_mot target} $ap_target_list {
|
||||
set pos [SplitReply [$ap_mot]]
|
||||
set tol [SplitReply [$ap_mot precision]]
|
||||
if {[expr {abs($pos - $target)}] > $tol} {
|
||||
set aptol [SplitReply [$ap_mot precision]]
|
||||
if {[expr {abs($pos - $target)}] > $aptol} {
|
||||
set drive_ok false
|
||||
clientput "$EMSG(drivefailed): Apertures off target"
|
||||
clientput "Drive failed: Apertures off target"
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -383,7 +389,7 @@ proc nguide { {num "REPORTNUM"} {sel_ap_name "NONE"} {aprest_name "NONE"}} {
|
||||
clientput "nguide finished with errors"
|
||||
}
|
||||
}
|
||||
return "[lindex [info level 0] 0] = $ng [lrange $ap_posname_list $ng 8]"
|
||||
return "[lindex [info level 0] 0] = $ng guides [lrange $table_posname_list 0 $ng-1] apertures [lrange $ap_posname_list $ng 8]"
|
||||
} message ]
|
||||
handle_exception $catch_status $message
|
||||
}
|
||||
@ -391,13 +397,13 @@ publish nguide user
|
||||
|
||||
::utility::macro::getset float gs_nguide { {num "REPORTNUM"} {ap "NONE"} {aprest "NONE"}} {
|
||||
# Just return number of selected guides from HDB node
|
||||
filter_non_numeric [lrange [nguide $num $ap $aprest] 0 2]
|
||||
return "[lindex [info level 0] 0] = [lindex [nguide] 2]"
|
||||
}
|
||||
sicslist setatt gs_nguide klass instrument
|
||||
sicslist setatt gs_nguide long_name nguide
|
||||
|
||||
proc L1 {} {
|
||||
set ng [lrange [nguide] 2 2]
|
||||
set ng [lindex [nguide] 2]
|
||||
set lg [SplitReply [lenguide]]
|
||||
set sg [SplitReply [spaceguide]]
|
||||
set sy [SplitReply [samy]]
|
||||
@ -407,7 +413,11 @@ proc L1 {} {
|
||||
return "[info level 0]: Non-numeric values: $msg_list"
|
||||
}
|
||||
|
||||
set retval [expr {$lg * (8.0 - $ng) + $sg * ($ng - 1) + 612.5 + $sy}]
|
||||
if {$ng < 0} {
|
||||
set retval -9999
|
||||
} else {
|
||||
set retval [expr {$lg * (8.0 - $ng) + $sg * ($ng - 1) + 612.5 + $sy}]
|
||||
}
|
||||
return "[lindex [info level 0] 0] = $retval"
|
||||
}
|
||||
publish L1 user
|
||||
@ -535,7 +545,7 @@ proc Ltof {det} {
|
||||
}
|
||||
set L1 [SplitReply [L1]]
|
||||
set lg [SplitReply [lenguide]]
|
||||
set ng [lrange [nguide] 2 2]
|
||||
set ng [lindex [nguide] 2]
|
||||
set sg [SplitReply [spaceguide]]
|
||||
set lch4_pc1 [SplitReply [lch4_pc1]]
|
||||
set Lt0 [SplitReply [Lt0]]
|
||||
@ -544,7 +554,11 @@ proc Ltof {det} {
|
||||
if {[llength $msg_list] > 0} {
|
||||
return "[info level 0]: Non-numeric values: $msg_list"
|
||||
}
|
||||
return [expr {$L2det + $L1 + $lg * $ng + $sg * ($ng -1) + $lch4_pc1 + $Lt0}]
|
||||
if {$ng < 0} {
|
||||
return -9999
|
||||
} else {
|
||||
return [expr {$L2det + $L1 + $lg * $ng + $sg * ($ng -1) + $lch4_pc1 + $Lt0}]
|
||||
}
|
||||
}
|
||||
|
||||
proc Ltof_det {} {
|
||||
@ -606,3 +620,32 @@ sicslist setatt gs_Ltof_curtaind long_name Ltof_curtaind
|
||||
lenguide 2000
|
||||
spaceguide 2
|
||||
lch4_pc1 1107
|
||||
|
||||
# Velocity Selector Trans second encoder
|
||||
# This is only for diagnostics
|
||||
# Axis number 29
|
||||
Motor vs_enc2 $motor_driver_type [params\
|
||||
asyncqueue mc4\
|
||||
axis E\
|
||||
units $vs_units\
|
||||
hardlowerlim $vs_rev_lim\
|
||||
hardupperlim $vs_fwd_lim\
|
||||
maxSpeed 0\
|
||||
maxAccel 0\
|
||||
maxDecel 0\
|
||||
stepsPerX 0\
|
||||
posit_count 1\
|
||||
absEnc 1\
|
||||
absEncHome 1625431\
|
||||
cntsPerX $vs_cnts_per_x\
|
||||
nopowersave 1]
|
||||
vs_enc2 softlowerlim $vs_rev_lim
|
||||
vs_enc2 softupperlim $vs_fwd_lim
|
||||
vs_enc2 home 248.050049
|
||||
vs_enc2 part $vs_part
|
||||
vs_enc2 long_name vs_enc2
|
||||
vs_enc2 speed 0
|
||||
vs_enc2 accel 0
|
||||
vs_enc2 decel 0
|
||||
vs_enc2 fixed 1
|
||||
|
||||
|
Reference in New Issue
Block a user