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 ch2_gains
variable ch3_gains variable ch3_gains
set currspeed [hval $hpath/$node/rotation_speed]
set currdir [hval $hpath/$node/motdir]
if {$target >= 0} { 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 set dir $CW
} else { } 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 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 global SCode
if {$target == ""} { if {$target == ""} {
set delay [hval $hpath/$node/ref_delay] set delay [hval $hpath/$node/ref_delay]
@@ -379,12 +389,15 @@ namespace eval ::chopper {
proc imot_SRun {hpath node addr name target} { proc imot_SRun {hpath node addr name target} {
global SCode global SCode
setSpeed $hpath $node $addr $name $target set catch_status [ catch {
hset $hpath/$node/control/start 1 setSpeed $hpath $node $addr $name $target
hsetprop $hpath/$node/control timecheck -1 hset $hpath/$node/control/start 1
set readtime [hgetpropval $hpath read_time] hsetprop $hpath/$node/control timecheck -1
hsetprop $hpath lastupdate $readtime set readtime [hgetpropval $hpath read_time]
return $SCode(OKOK) hsetprop $hpath lastupdate $readtime
return $SCode(OKOK)
} message ]
handle_exception $catch_status $message
} }
proc imot_SStatus {hpath node addr name} { proc imot_SStatus {hpath node addr name} {
@@ -409,7 +422,7 @@ namespace eval ::chopper {
set locked $up_to_speed set locked $up_to_speed
} else { } else {
# PHASE mode # PHASE mode
set locked [expr $up_to_speed && $phase_locked] set locked $phase_locked
} }
if {$locked} { if {$locked} {
if {$timecheck == -1} { if {$timecheck == -1} {
@@ -546,6 +559,12 @@ namespace eval ::chopper {
return $SCode(OKOK) 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} { proc idle {hpath node addr name} {
global SCode global SCode
hset $hpath/$node/control/idle_toggle 1 hset $hpath/$node/control/idle_toggle 1