Don't report non-numeric values on Ltof hdb nodes.

This also eliminates logging type violation errors caused by polling of the hdb nodes when the guides are misaligned.
Make sure that aprrest_list is empty when N = 8
Improved argument checking and optimisations.

Also allow for setting an offset to the aperture positions on initialisation.
This was found to be necessary after the encoders were replace and ap2 upperlimit
was found to be lower than the ap2 topmost position for an aperture.
This commit is contained in:
Ferdi Franceschini
2014-07-18 00:16:27 +10:00
parent 17c212ee2e
commit b5b8b32788

View File

@@ -9,10 +9,36 @@ add_tank tank aqadapter mc8
# Eg, mot fixed 1 # Eg, mot fixed 1
# Define "proc motor_set_sobj_attributes {}" if we need to define extra sicslist attributes for some motors. # 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} {
lappend ap1_positions [expr $pos + 0]
}
foreach pos {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} {
lappend ap3_positions [expr $pos + 0]
}
foreach pos {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} {
lappend ap5_positions [expr $pos + 0]
}
foreach pos {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} {
lappend ap7_positions [expr $pos + 0]
}
foreach pos {40.830688 55.821533 70.966187 85.792236 107.880249} {
lappend ap8_positions [expr $pos + 0]
}
for {set n 1} {$n <= 8} {incr n} { for {set n 1} {$n <= 8} {incr n} {
make_coll_motor_1 c$n c$n pc$n count make_coll_motor_1 c$n c$n pc$n count
pc$n position_names guide apertures pc$n position_names guide apertures
make_coll_motor_1 a$n a$n ap$n count 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 D10 D20 D40 S40 R100
} }
@@ -35,7 +61,29 @@ sapmot position_names D2.5 D5 D7.5 D10 D12.5 D15 D17.5 D20 D30 D40
make_vmot sap sapmot count make_vmot sap sapmot count
sapmot precision 0.001 sapmot precision 0.001
## Time of flight calculation ################################################################################
##################### Time of flight calculations ##############################
proc Nan_list {args} {
set msg_list ""
foreach n $args {
upvar $n $n
lappend name_val_list $n [ subst {[set $n]} ]
}
foreach {n v} $name_val_list {
if { ![ string is double $v] } {
lappend msg_list $n = $v
}
}
return $msg_list
}
proc return_non_numeric {val} {
if [string is double $val] {
return $val
} else {
return -9999
}
}
# Length of a guide # Length of a guide
::utility::mkVar lenguide float user lenguide true instrument true true ::utility::mkVar lenguide float user lenguide true instrument true true
# Space between guides # Space between guides
@@ -54,7 +102,7 @@ sapmot precision 0.001
# \param sel_ap_name The position name for the first aperture selected after last guide. # \param sel_ap_name The position name for the first aperture selected after last guide.
# \param aprest_name The position name for the rest of the apertures # \param aprest_name The position name for the rest of the apertures
# \return The number of selected guides or an error message # \return The number of selected guides or an error message
::utility::macro::getset float nguide { {num "REPORTNUM"} {sel_ap_name "NONE"} {aprest_name "NONE"}} { proc nguide { {num "REPORTNUM"} {sel_ap_name "NONE"} {aprest_name "NONE"}} {
set catch_status [ catch { set catch_status [ catch {
set FINDFIRST 1 set FINDFIRST 1
set COUNT 2 set COUNT 2
@@ -72,16 +120,18 @@ sapmot precision 0.001
set tol 0.1 set tol 0.1
set ng 0 set ng 0
set state $FINDFIRST set state $FINDFIRST
set apdrvlist {ap1 1 ap2 1 ap3 1 ap4 1 ap5 1 ap6 1 ap7 1 ap8 1} set apdrvlist {}
set pcdrvlist {} set pcdrvlist {}
if {$num != "REPORTNUM"} { if {$num != "REPORTNUM"} {
if {$num >= 0 && $num < 8} {
if { $sel_ap_name == "NONE" || $aprest_name == "NONE" } { if { $sel_ap_name == "NONE" || $aprest_name == "NONE" } {
error "EMSG(invalidarg): You must provide two aperture arguments" error "EMSG(invalidarg): You must provide two aperture arguments"
} elseif [lsearch -nocase $sel_ap_name] { } elseif { [lsearch -nocase $ap_names $sel_ap_name] == -1 } {
error "EMSG(invalidarg): $sel_ap_name should be one of $ap_names" error "EMSG(invalidarg): $sel_ap_name should be one of $ap_names"
} elseif [lsearch -nocase $aprest_name] { } elseif { [lsearch -nocase $ap_names $aprest_name] == -1 } {
error "EMSG(invalidarg): $aprest_name should be one of $ap_names" error "EMSG(invalidarg): $aprest_name should be one of $ap_names"
} }
}
if {$num >= 0 && $num <= 8} { if {$num >= 0 && $num <= 8} {
set CheckDrive true set CheckDrive true
set last 8 set last 8
@@ -90,6 +140,7 @@ sapmot precision 0.001
set table_guideunit [SplitReply [pc$last posit2unit $guideposit]] set table_guideunit [SplitReply [pc$last posit2unit $guideposit]]
if {[expr {abs($currpos - $table_guideunit)}] > $tol} { if {[expr {abs($currpos - $table_guideunit)}] > $tol} {
lappend pcdrvlist c$last $guideposit lappend pcdrvlist c$last $guideposit
lappend apdrvlist ap$n 1
} }
incr last -1 incr last -1
} }
@@ -100,10 +151,12 @@ sapmot precision 0.001
lappend pcdrvlist c$n $apposit lappend pcdrvlist c$n $apposit
} }
} }
if {[llength $apdrvlist] > 0} { if {[llength $pcdrvlist] > 0 && [llength $apdrvlist] > 0} {
clientput "drive $apdrvlist"
eval "drive $apdrvlist" eval "drive $apdrvlist"
} }
if {[llength $pcdrvlist] > 0} { if {[llength $pcdrvlist] > 0} {
clientput "drive $pcdrvlist"
eval "drive $pcdrvlist" eval "drive $pcdrvlist"
} }
} else { } else {
@@ -122,7 +175,7 @@ sapmot precision 0.001
incr ng incr ng
set state $COUNT set state $COUNT
} else { } else {
error "$EMSG(misaligned)" return "$EMSG(misaligned)"
} }
} }
$COUNT { $COUNT {
@@ -130,7 +183,7 @@ sapmot precision 0.001
incr ng incr ng
} else { } else {
# ERROR There shouldn't be any gaps in the selection # ERROR There shouldn't be any gaps in the selection
error "$EMSG(gaps)" return "$EMSG(gaps)"
} }
} }
}] }]
@@ -138,7 +191,8 @@ sapmot precision 0.001
if {$CheckDrive} { if {$CheckDrive} {
if {$ng != $num} { if {$ng != $num} {
error "$EMSG(drivefailed)" error "$EMSG(drivefailed)"
} else { } elseif {$num >= 0 && $num < 8} {
set aprest_list {}
for {set n [expr $last - 1]} {$n > 0} {incr n -1} { for {set n [expr $last - 1]} {$n > 0} {incr n -1} {
lappend aprest_list ap$n $aprest_name lappend aprest_list ap$n $aprest_name
} }
@@ -149,7 +203,7 @@ sapmot precision 0.001
if { [expr abs($req_sel_ap_pos - $sel_ap_pos)] > $prec } { if { [expr abs($req_sel_ap_pos - $sel_ap_pos)] > $prec } {
error "$EMSG(apfailed): ap$last" error "$EMSG(apfailed): ap$last"
} }
foreach ap_mot ap_name $aprest_list { foreach {ap_mot ap_name} $aprest_list {
set sel_pos [SplitReply [ $ap_mot ]] set sel_pos [SplitReply [ $ap_mot ]]
set req_pos [ SplitReply [ $ap_mot posit2unit $ap_name ] ] set req_pos [ SplitReply [ $ap_mot posit2unit $ap_name ] ]
set prec [ SplitReply [$ap_mot precision] ] set prec [ SplitReply [$ap_mot precision] ]
@@ -163,25 +217,36 @@ sapmot precision 0.001
} message ] } message ]
handle_exception $catch_status $message handle_exception $catch_status $message
} }
sicslist setatt nguide klass instrument publish nguide user
sicslist setatt nguide long_name nguide
::utility::macro::getset float L1 {} { ::utility::macro::getset float gs_nguide { {num "REPORTNUM"} {ap "NONE"} {aprest "NONE"}} {
set catch_status [ catch { return_non_numeric [nguide $num $ap $aprest]
}
sicslist setatt gs_nguide klass instrument
sicslist setatt gs_nguide long_name nguide
proc L1 {} {
set ng [SplitReply [nguide]]
set lg [SplitReply [lenguide]] set lg [SplitReply [lenguide]]
set sg [SplitReply [spaceguide]] set sg [SplitReply [spaceguide]]
set ng [SplitReply [nguide]]
set sy [SplitReply [samy]] set sy [SplitReply [samy]]
set msg_list [Nan_list ng lg sg sy]
if {[llength $msg_list] > 0} {
return "[info level 0]: Non-numeric values: $msg_list"
}
set retval [expr {$lg * (8.0 - $ng) + $sg * ($ng - 1) + 612.5 + $sy}] set retval [expr {$lg * (8.0 - $ng) + $sg * ($ng - 1) + 612.5 + $sy}]
return "[lindex [info level 0] 0] = $retval" return "[lindex [info level 0] 0] = $retval"
} message ]
handle_exception $catch_status $message
} }
sicslist setatt L1 klass instrument publish L1 user
sicslist setatt L1 long_name L1 ::utility::macro::getset float gs_L1 {} {
return_non_numeric [ L1 ]
}
sicslist setatt gs_L1 klass instrument
sicslist setatt gs_L1 long_name L1
proc L2 {det} { proc L2 {det} {
set catch_status [ catch {
set vy [SplitReply [vessel_y]] set vy [SplitReply [vessel_y]]
set sy [SplitReply [samy]] set sy [SplitReply [samy]]
set cd [SplitReply [curtaindet]] set cd [SplitReply [curtaindet]]
@@ -202,68 +267,74 @@ proc L2 {det} {
set detpos [expr {$::curtaind_yoffset + $cd}] set detpos [expr {$::curtaind_yoffset + $cd}]
} }
default { default {
error "Argument should be maindet, curtainl, curtainr, curtainu, or curtaind not $det" return "Argument should be maindet, curtainl, curtainr, curtainu, or curtaind not $det"
} }
} }
set msg_list [Nan_list vy sy cd detpos]
if {[llength $msg_list] > 0} {
return "[info level 0]: Non-numeric values: $msg_list"
}
return [expr {$detpos + $vy - $sy}] return [expr {$detpos + $vy - $sy}]
} message ]
handle_exception $catch_status $message
} }
## L2 ## L2
::utility::macro::getset float L2_det {} { proc L2_det {} {
set catch_status [ catch {
set retval [L2 maindet] set retval [L2 maindet]
return "[lindex [info level 0] 0] = $retval" return "[lindex [info level 0] 0] = $retval"
} message ]
handle_exception $catch_status $message
} }
sicslist setatt L2_det klass instrument publish L2_det user
sicslist setatt L2_det long_name L2_det ::utility::macro::getset float gs_L2_det {} {
return_non_numeric [ L2_det ]
}
sicslist setatt gs_L2_det klass instrument
sicslist setatt gs_L2_det long_name L2_det
::utility::macro::getset float L2_curtainl {} { proc L2_curtainl {} {
set catch_status [ catch {
set retval [L2 curtainl] set retval [L2 curtainl]
return "[lindex [info level 0] 0] = $retval" return "[lindex [info level 0] 0] = $retval"
} message ]
handle_exception $catch_status $message
} }
sicslist setatt L2_curtainl klass instrument publish L2_curtainl user
sicslist setatt L2_curtainl long_name L2_curtainl ::utility::macro::getset float gs_L2_curtainl {} {
return_non_numeric [ L2_curtainl ]
}
sicslist setatt gs_L2_curtainl klass instrument
sicslist setatt gs_L2_curtainl long_name L2_curtainl
::utility::macro::getset float L2_curtainr {} { proc L2_curtainr {} {
set catch_status [ catch {
set retval [L2 curtainr] set retval [L2 curtainr]
return "[lindex [info level 0] 0] = $retval" return "[lindex [info level 0] 0] = $retval"
} message ]
handle_exception $catch_status $message
} }
sicslist setatt L2_curtainr klass instrument publish L2_curtainr user
sicslist setatt L2_curtainr long_name L2_curtainr ::utility::macro::getset float L2_curtainr {} {
return_non_numeric [ L2_curtainr ]
}
sicslist setatt gs_L2_curtainr klass instrument
sicslist setatt gs_L2_curtainr long_name L2_curtainr
::utility::macro::getset float L2_curtainu {} { proc L2_curtainu {} {
set catch_status [ catch {
set retval [L2 curtainu] set retval [L2 curtainu]
return "[lindex [info level 0] 0] = $retval" return "[lindex [info level 0] 0] = $retval"
} message ]
handle_exception $catch_status $message
} }
sicslist setatt L2_curtainu klass instrument publish L2_curtainu user
sicslist setatt L2_curtainu long_name L2_curtainu ::utility::macro::getset float gs_L2_curtainu {} {
return_non_numeric [ L2_curtainu ]
}
sicslist setatt gs_L2_curtainu klass instrument
sicslist setatt gs_L2_curtainu long_name L2_curtainu
::utility::macro::getset float L2_curtaind {} { proc L2_curtaind {} {
set catch_status [ catch {
set retval [L2 curtaind] set retval [L2 curtaind]
return "[lindex [info level 0] 0] = $retval" return "[lindex [info level 0] 0] = $retval"
} message ]
handle_exception $catch_status $message
} }
sicslist setatt L2_curtaind klass instrument publish L2_curtaind user
sicslist setatt L2_curtaind long_name L2_curtaind ::utility::macro::getset float gs_L2_curtaind {} {
return_non_numeric [ L2_curtaind ]
}
sicslist setatt gs_L2_curtaind klass instrument
sicslist setatt gs_L2_curtaind long_name L2_curtaind
## Lt0 ## Lt0
::utility::macro::getset float Lt0 {} { proc Lt0 {} {
set catch_status [ catch {
set t0_id [SplitReply [t0_chopper_id]] set t0_id [SplitReply [t0_chopper_id]]
switch $t0_id { switch $t0_id {
"1" { set retval 0.0} "1" { set retval 0.0}
@@ -272,16 +343,17 @@ sicslist setatt L2_curtaind long_name L2_curtaind
"4" { set retval 7700.0} "4" { set retval 7700.0}
} }
return "[lindex [info level 0] 0] = $retval" return "[lindex [info level 0] 0] = $retval"
} message ]
handle_exception $catch_status $message
} }
sicslist setatt Lt0 klass instrument publish Lt0 user
sicslist setatt Lt0 long_name Lt0 ::utility::macro::getset float gs_Lt0 {} {
return_non_numeric [ Lt0 ]
}
sicslist setatt gs_Lt0 klass instrument
sicslist setatt gs_Lt0 long_name Lt0
## Ltof ## Ltof
proc Ltof {det} { proc Ltof {det} {
set catch_status [ catch {
switch $det { switch $det {
"maindet" - "curtainl" - "curtainr" - "curtainu" - "curtaind" { "maindet" - "curtainl" - "curtainr" - "curtainu" - "curtaind" {
set L2det [SplitReply [L2 $det]] set L2det [SplitReply [L2 $det]]
@@ -296,60 +368,68 @@ proc Ltof {det} {
set sg [SplitReply [spaceguide]] set sg [SplitReply [spaceguide]]
set lch4_pc1 [SplitReply [lch4_pc1]] set lch4_pc1 [SplitReply [lch4_pc1]]
set Lt0 [SplitReply [Lt0]] set Lt0 [SplitReply [Lt0]]
set msg_list [Nan_list L1 lg ng sg lch4_pc1 Lt0]
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}] return [expr {$L2det + $L1 + $lg * $ng + $sg * ($ng -1) + $lch4_pc1 + $Lt0}]
} message ]
handle_exception $catch_status $message
} }
::utility::macro::getset float Ltof_det {} { proc Ltof_det {} {
set catch_status [ catch {
set retval [Ltof maindet] set retval [Ltof maindet]
return "[lindex [info level 0] 0] = $retval" return "[lindex [info level 0] 0] = $retval"
} message ]
handle_exception $catch_status $message
} }
sicslist setatt Ltof_det klass instrument publish Ltof_det user
sicslist setatt Ltof_det long_name Ltof_det ::utility::macro::getset float gs_Ltof_det {} {
return_non_numeric [ Ltof_det ]
}
sicslist setatt gs_Ltof_det klass instrument
sicslist setatt gs_Ltof_det long_name Ltof_det
::utility::macro::getset float Ltof_curtainl {} { proc Ltof_curtainl {} {
set catch_status [ catch {
set retval [Ltof curtainl] set retval [Ltof curtainl]
return "[lindex [info level 0] 0] = $retval" return "[lindex [info level 0] 0] = $retval"
} message ]
handle_exception $catch_status $message
} }
sicslist setatt Ltof_curtainl klass instrument publish Ltof_curtainl user
sicslist setatt Ltof_curtainl long_name Ltof_curtainl ::utility::macro::getset float gs_Ltof_curtainl {} {
return_non_numeric [ Ltof_curtainl ]
}
sicslist setatt gs_Ltof_curtainl klass instrument
sicslist setatt gs_Ltof_curtainl long_name Ltof_curtainl
::utility::macro::getset float Ltof_curtainr {} { proc Ltof_curtainr {} {
set catch_status [ catch {
set retval [Ltof curtainr] set retval [Ltof curtainr]
return "[lindex [info level 0] 0] = $retval" return "[lindex [info level 0] 0] = $retval"
} message ]
handle_exception $catch_status $message
} }
sicslist setatt Ltof_curtainr klass instrument publish Ltof_curtainr user
sicslist setatt Ltof_curtainr long_name Ltof_curtainr ::utility::macro::getset float gs_Ltof_curtainr {} {
return_non_numeric [ Ltof_curtainr ]
}
sicslist setatt gs_Ltof_curtainr klass instrument
sicslist setatt gs_Ltof_curtainr long_name Ltof_curtainr
::utility::macro::getset float Ltof_curtainu {} { proc Ltof_curtainu {} {
set catch_status [ catch {
set retval [Ltof curtainu] set retval [Ltof curtainu]
return "[lindex [info level 0] 0] = $retval" return "[lindex [info level 0] 0] = $retval"
} message ]
handle_exception $catch_status $message
} }
sicslist setatt Ltof_curtainu klass instrument publish Ltof_curtainu user
sicslist setatt Ltof_curtainu long_name Ltof_curtainu ::utility::macro::getset float gs_Ltof_curtainu {} {
return_non_numeric [ Ltof_curtainu ]
}
sicslist setatt gs_Ltof_curtainu klass instrument
sicslist setatt gs_Ltof_curtainu long_name Ltof_curtainu
::utility::macro::getset float Ltof_curtaind {} { proc Ltof_curtaind {} {
set catch_status [ catch {
set retval [Ltof curtaind] set retval [Ltof curtaind]
return "[lindex [info level 0] 0] = $retval" return "[lindex [info level 0] 0] = $retval"
} message ]
handle_exception $catch_status $message
} }
sicslist setatt Ltof_curtaind klass instrument publish Ltof_curtaind user
sicslist setatt Ltof_curtaind long_name Ltof_curtaind ::utility::macro::getset float gs_Ltof_curtaind {} {
return_non_numeric [ Ltof_curtaind ]
}
sicslist setatt gs_Ltof_curtaind klass instrument
sicslist setatt gs_Ltof_curtaind long_name Ltof_curtaind
lenguide 2000 lenguide 2000