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.
This commit is contained in:
Ferdi Franceschini
2013-05-03 00:36:53 +10:00
parent 90d05682e2
commit 7e1e4e2d45

View File

@@ -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
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