diff --git a/site_ansto/instrument/config/anticollider/anticollider_common.tcl b/site_ansto/instrument/config/anticollider/anticollider_common.tcl index 76d27224..121005b0 100644 --- a/site_ansto/instrument/config/anticollider/anticollider_common.tcl +++ b/site_ansto/instrument/config/anticollider/anticollider_common.tcl @@ -3,8 +3,6 @@ # TODO Handle sequencing when simultaneously moving multiple axes # TODO Handle functional dependencies (just write your own tcl script) # or get the generic acscript to call a user proc -# FIXME The anticollider module does not report the error messages from the -# anticollision script, we currently get around this by using broadcast. AntiCollisionInstall namespace eval anticollider { @@ -88,16 +86,14 @@ proc ::anticollider::enable {args} { # # The ::anticollider::veto_region is a hash indexed by the names of the motors # which have been registered with the anticollision module. -proc ::anticollider::acscript {args} { +proc ::anticollider::veto_region_acscript {args} { variable veto_region - if {[::anticollider::enable $args] == "false"} { - foreach {regmot target} $args { - anticollision add 0 $regmot $target - } - return - } + set catch_status [ catch { foreach {regmot target} $args { + if { ! [info exists veto_region($regmot)] } { + continue + } foreach row $veto_region($regmot) { if { [lindex $row 1] == "@and"} { set forbid [lindex $row 0] @@ -116,7 +112,6 @@ proc ::anticollider::acscript {args} { } else { foreach {min max} $forbid {} if {$min <= $target && $target <= $max} { - broadcast "ERROR:The range ($forbid) is forbidden for $regmot when [lindex $row 2]" error "ERROR:The range ($forbid) is forbidden for $regmot when [lindex $row 2]" } } @@ -126,17 +121,14 @@ proc ::anticollider::acscript {args} { if {$obstrange == "@all"} { foreach {min max} [join $forbidden_range] { if {$min <= $target && $target <= $max} { - broadcast "ERROR: $regmot target ($target) is in the forbidden region ($forbidden_range)" error "ERROR: $regmot target ($target) is in the forbidden region ($forbidden_range)" } } } else { - broadcast "ERROR: veto table must use @all with @any" error "ERROR: veto table must use @all with @any" } } else { if {$obstrange == "@all"} { - broadcast "ERROR: veto table must use @any with @all" error "ERROR: veto table must use @any with @all" } else { foreach {lower upper} [join $obstrange] { @@ -144,7 +136,6 @@ proc ::anticollider::acscript {args} { if {$lower <= $pos && $pos <= $upper} { foreach {min max} [join $forbidden_range] { if {$min <= $target && $target <= $max} { - broadcast "ERROR:The range $min to $max is forbidden for $regmot when $obstmot is in this region ($obstrange)" error "ERROR:The range $min to $max is forbidden for $regmot when $obstmot is in this region ($obstrange)" } @@ -158,6 +149,8 @@ proc ::anticollider::acscript {args} { } anticollision add 0 $regmot $target } + } message ] + handle_exception $catch_status $message } ## @@ -178,5 +171,18 @@ proc ::anticollider::init {} { } } +proc ::anticollider::acscript {args} { + set catch_status [ catch { + if {[::anticollider::enable $args] == "false"} { + foreach {regmot target} $args { + anticollision add 0 $regmot $target + } + return + } + ::anticollider::veto_region_acscript {*}$args + } message ] + handle_exception $catch_status $message +} + publish ::anticollider::acscript user anticollision script ::anticollider::acscript