From 7e1e4e2d45566abf6ef26201a5047523bc686300 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Fri, 3 May 2013 00:36:53 +1000 Subject: [PATCH] Don't allow change of direction if the fermimotor speed != 0. Added an "idle" subcommand so the speed can be set to zero without delevitating. Also added alarm reset command. --- .../pelican/config/chopper/fermimot.tcl | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/site_ansto/instrument/pelican/config/chopper/fermimot.tcl b/site_ansto/instrument/pelican/config/chopper/fermimot.tcl index 105c0985..c6acde41 100644 --- a/site_ansto/instrument/pelican/config/chopper/fermimot.tcl +++ b/site_ansto/instrument/pelican/config/chopper/fermimot.tcl @@ -307,9 +307,19 @@ namespace eval ::chopper { variable ch2_gains variable ch3_gains + set currspeed [hval $hpath/$node/rotation_speed] + set currdir [hval $hpath/$node/motdir] if {$target >= 0} { + if {$currdir != $CW && $currspeed != 0} { + clientput "ERROR: Tried to change direction when speed != 0. Set motor to idle first." + return -code error + } set dir $CW } else { + if {$currdir != $CCW && $currspeed != 0} { + clientput "ERROR: Tried to change direction when speed != 0. Set motor to idle first." + return -code error + } set dir $CCW } @@ -341,7 +351,7 @@ namespace eval ::chopper { } } - proc get_setRefDelay {hpath node addr name {target_ ""}} { + proc get_setRefDelay {hpath node addr name {target ""}} { global SCode if {$target == ""} { set delay [hval $hpath/$node/ref_delay] @@ -379,12 +389,15 @@ namespace eval ::chopper { proc imot_SRun {hpath node addr name target} { global SCode - setSpeed $hpath $node $addr $name $target - hset $hpath/$node/control/start 1 - hsetprop $hpath/$node/control timecheck -1 - set readtime [hgetpropval $hpath read_time] - hsetprop $hpath lastupdate $readtime - return $SCode(OKOK) + set catch_status [ catch { + setSpeed $hpath $node $addr $name $target + hset $hpath/$node/control/start 1 + hsetprop $hpath/$node/control timecheck -1 + set readtime [hgetpropval $hpath read_time] + hsetprop $hpath lastupdate $readtime + return $SCode(OKOK) + } message ] + handle_exception $catch_status $message } proc imot_SStatus {hpath node addr name} { @@ -409,7 +422,7 @@ namespace eval ::chopper { set locked $up_to_speed } else { # PHASE mode - set locked [expr $up_to_speed && $phase_locked] + set locked $phase_locked } if {$locked} { if {$timecheck == -1} { @@ -546,6 +559,12 @@ namespace eval ::chopper { return $SCode(OKOK) } + proc reset {hpath node addr name} { + global SCode + hset $hpath/$node/control/reset 1 + return $SCode(OKOK) + } + proc idle {hpath node addr name} { global SCode hset $hpath/$node/control/idle_toggle 1