SICS-821: You can now use the "whenall" keyword to forbid a move based on the positions of a set of motors.

This commit is contained in:
Ferdi Franceschini
2014-11-05 12:52:32 +11:00
parent 4dbaa0f73d
commit a375c6ce20

View File

@ -93,6 +93,7 @@ proc ::anticollider::genveto {veto_rules} {
lappend condlist $mot $range lappend condlist $mot $range
} }
lappend veto_region($vp(for)) [list $vp(forbid) @and $condlist] lappend veto_region($vp(for)) [list $vp(forbid) @and $condlist]
unset condlist
} elseif [info exists vp(when)] { } elseif [info exists vp(when)] {
lappend veto_region($vp(for)) [list $vp(forbid) $vp(when) $vp(in)] lappend veto_region($vp(for)) [list $vp(forbid) $vp(when) $vp(in)]
} else { } else {
@ -132,12 +133,12 @@ proc ::anticollider::veto_region_acscript {args} {
foreach row $veto_region($regmot) { foreach row $veto_region($regmot) {
if { [lindex $row 1] == "@and"} { if { [lindex $row 1] == "@and"} {
set forbid [lindex $row 0] set forbid [lindex $row 0]
set veto 0 set veto 1
foreach {mot range} [lindex $row 2] { foreach {mot range} [lindex $row 2] {
set pos [SplitReply [$mot]] set pos [SplitReply [$mot]]
foreach {lower upper} [join $range] { foreach {lower upper} [join $range] {
if {$pos >= $lower && $pos <= $upper} { if {$pos < $lower || $pos > $upper} {
set veto 1 set veto 0
break break
} }
} }
@ -147,7 +148,10 @@ proc ::anticollider::veto_region_acscript {args} {
} else { } else {
foreach {min max} $forbid {} foreach {min max} $forbid {}
if {$min <= $target && $target <= $max} { if {$min <= $target && $target <= $max} {
error "ERROR:The range ($forbid) is forbidden for $regmot when [lindex $row 2]" foreach {mot range} [lindex $row 2] {
lappend msg [list $mot in $range]
}
error "ERROR:The range ($forbid) is forbidden for $regmot when [join $msg { and }]"
} }
} }
} else { } else {
@ -212,15 +216,13 @@ proc ::anticollider::init {} {
lappend ::anticollider::scripts ::anticollider::veto_region_acscript lappend ::anticollider::scripts ::anticollider::veto_region_acscript
proc ::anticollider::acscript {args} { proc ::anticollider::acscript {args} {
set catch_status [ catch { set catch_status [ catch {
if {[::anticollider::enable $args] == "false"} { foreach {regmot target} $args {
return anticollision add 0 $regmot $target
} else {
foreach {regmot target} $args {
anticollision add 0 $regmot $target
}
} }
foreach script $::anticollider::scripts { if {[::anticollider::enable $args] == "true"} {
$script {*}$args foreach script $::anticollider::scripts {
$script {*}$args
}
} }
} message ] } message ]
handle_acscript_exception $catch_status $message handle_acscript_exception $catch_status $message