Added "STARTING" message to the histmem command status.
Can now make multiple script context positional motors
Added table and table entry IDs for posit motor lookup tables.
Fixed the runsics script so that the stop command sends an EndServer interrupt via the UDP port instead of killing SICS, this ensures that status is saved.

Platypus
Added chopper speed, phase and phase offsets for all choppers on hdb tree and in datafile

Quokka
Replace the sample/select command with the changer_position script context positional motor interface.
Fixed upper limit on apx motor
Added full sample changer and auto aperture positional motors

r2727 | ffr | 2008-10-31 15:37:32 +1100 (Fri, 31 Oct 2008) | 14 lines
This commit is contained in:
Ferdi Franceschini
2008-10-31 15:37:32 +11:00
committed by Douglas Clowes
parent b9e1b19252
commit 04e2e75d80
11 changed files with 233 additions and 86 deletions

View File

@ -25,6 +25,7 @@ namespace eval ::histogram {
::histogram::histmem_cmd -set feedback status PAUSED ::histogram::histmem_cmd -set feedback status PAUSED
} }
"start" { "start" {
::histogram::histmem_cmd -set feedback status STARTING
histmem mode $mode histmem mode $mode
histmem preset $preset histmem preset $preset
histmem freq $freq histmem freq $freq

View File

@ -3,27 +3,42 @@ namespace eval ::sobj::positmotor {
variable posit_indices variable posit_indices
# TODO Add a script to edit the posit_table and attach it to indexed nodes with read and write actions. # TODO Add a script to edit the posit_table and attach it to indexed nodes with read and write actions.
proc abort_on_invalid_posindex {pos} { proc abort_on_invalid_posindex {pos motor} {
variable posit_indices variable posit_indices
set pos0 [lindex $posit_indices 0] set pos0 [lindex $posit_indices($motor) 0]
set posend [lindex $posit_indices end] set posend [lindex $posit_indices($motor) end]
if {$pos < $pos0 || $pos > $posend} { if {$pos < $pos0 || $pos > $posend} {
return -code error "ERROR: Indexed position must be between $pos0 and $posend" return -code error "ERROR: Indexed position must be between $pos0 and $posend"
} }
} }
proc isbetween {val l1 l2} {
if {($l1 <= $val && $val <= $l2) || ($l2 <= $val && $val <= $l1)} {
return true
} else {
return false
}
}
proc iswithin {val pos prec} {
if {[expr $pos - $prec] <= $val && $val <= [expr $pos + $prec]} {
return true
} else {
return false
}
}
## ##
# @brief Convert an indexed position to a physical motor position # @brief Convert an indexed position to a physical motor position
proc pos2val {pos} { proc pos2val {pos motor} {
variable posit_table variable posit_table
if [ catch { if [ catch {
abort_on_invalid_posindex $pos abort_on_invalid_posindex $pos $motor
set bot [expr int(floor($pos))] set bot [expr int(floor($pos))]
set top [expr int(ceil($pos))] set top [expr int(ceil($pos))]
set fract [expr fmod($pos,1)] set fract [expr fmod($pos,1)]
set val [expr $fract * ($posit_table($top) - $posit_table($bot)) + $posit_table($bot)] set val [expr $fract * ($posit_table($motor,$top) - $posit_table($motor,$bot)) + $posit_table($motor,$bot)]
} message ] { } message ] {
return -code error $message return -code error $message
} else { } else {
@ -33,31 +48,47 @@ namespace eval ::sobj::positmotor {
## ##
# @brief Convert a physical motor position to and indexed position # @brief Convert a physical motor position to and indexed position
proc val2pos {val precision} { proc val2pos {val precision motor} {
variable posit_table variable posit_table
variable posit_indices variable posit_indices
set val [expr double($val)] set val [expr double($val)]
set pos0 [lindex $posit_indices 0] set pos0 [lindex $posit_indices($motor) 0]
set posend [lindex $posit_indices end] set posend [lindex $posit_indices($motor) end]
if {$val < [expr $posit_table($pos0) - $precision]} {return -$pos0}
if {$val > [expr $posit_table($posend) + $precision]} {return -$posend} if {$posit_table($motor,$pos0) < $posit_table($motor,$posend)} {
set fwd_table true
if {$val < [expr $posit_table($motor,$pos0) - $precision]} {return -$pos0}
if {$val > [expr $posit_table($motor,$posend) + $precision]} {return -$posend}
} else {
set fwd_table false
if {$val < [expr $posit_table($motor,$posend) - $precision]} {return -$posend}
if {$val > [expr $posit_table($motor,$pos0) + $precision]} {return -$pos0}
}
if [catch { if [catch {
set ibot $pos0 set ibot $pos0
set itop [lindex $posit_indices 1] set itop [lindex $posit_indices($motor) 1]
while {$val > [expr $posit_table($itop) + $precision]} { if {$fwd_table} {
incr ibot while {$val > [expr $posit_table($motor,$itop) + $precision]} {
incr itop incr ibot
incr itop
}
} else {
while {$val < [expr $posit_table($motor,$itop) - $precision]} {
incr ibot
incr itop
}
} }
set bot [expr $posit_table($ibot)] set bot [expr $posit_table($motor,$ibot)]
set top [expr $posit_table($itop)] set top [expr $posit_table($motor,$itop)]
if {[expr $bot - $precision] <= $val && $val <= [expr $bot + $precision]} { if [iswithin $val $bot $precision] {
set pos $ibot set pos $ibot
} elseif {[expr $top - $precision] <= $val && $val <= [expr $top + $precision]} { } elseif [iswithin $val $top $precision] {
set pos $itop set pos $itop
} else { } else {
# set pos [format "%.3f" [expr int(($val -$bot)/$precision)*$precision/($top - $bot) + $ibot]] # set pos [format "%.3f" [expr int(($val -$bot)/$precision)*$precision/($top - $bot) + $ibot]]
set pos [expr int(($val -$bot)/$precision)*$precision/($top - $bot) + $ibot] set pos [expr abs(int(($val -$bot)/$precision)*$precision/($top - $bot)) + $ibot]
} }
} errmsg] { } errmsg] {
return -code error $errmsg return -code error $errmsg
@ -71,23 +102,23 @@ namespace eval ::sobj::positmotor {
return state_reading_index return state_reading_index
} }
proc state_reading_index {path par} { proc state_reading_index {path par motor} {
variable posit_table variable posit_table
sct writestatus replyreceived sct writestatus replyreceived
set rply [val2pos [sct result] [hval $path/motprecision]] set rply [val2pos [sct result] [hval $path/motprecision] $motor]
set data $rply set data $rply
# broadcast state_reading_index update parameter $par $data # broadcast state_reading_index update parameter $par $data
if {$data != [sct oldval] || [sct force_update] } { if {$data != [sct oldval] || [sct force_update] } {
# if {[status] == "status = Driving" && [hval $path/state] == "idle"} { # if {[status] == "status = Driving" && [hval $path/status] == "IDLE"} {
# hset $path/state busy # hset $path/status BUSY
# } # }
sct oldval $data sct oldval $data
sct update $data sct update $data
sct force_update False sct force_update False
sct utime readtime sct utime readtime
} }
if {[hval $path/state] == "stopping"} { if {[hval $path/status] == "STOPPING"} {
hset $path/state idle hset $path/status IDLE
} }
return idle return idle
} }
@ -98,8 +129,8 @@ namespace eval ::sobj::positmotor {
# broadcast w_index # broadcast w_index
if [ catch { if [ catch {
set val [pos2val [sct target] ] set val [pos2val [sct target] $motor]
hset $path/state busy hset $path/status BUSY
run $motor $val run $motor $val
$sct_controller poll $path 1 $sct_controller poll $path 1
} errmsg ] { } errmsg ] {
@ -118,30 +149,37 @@ namespace eval ::sobj::positmotor {
return OK return OK
} }
proc setposindex {posindex val} { proc setposindex {posindex val motor} {
variable posit_table variable posit_table
set posit_table($posindex) $val set posit_table($motor,$posindex) $val
} }
proc mk_sct_positmotor {sct_controller motname param axis posit_list} { proc mk_sct_positmotor {sct_controller motor param table_ID posit_list} {
variable posit_table variable posit_table
variable posit_indices variable posit_indices
array set posit_table $posit_list set index 1
set posit_indices [lsort [array names posit_table]] foreach {label position} $posit_list {
lappend posit_indices($motor) $index
set posit_table($motor,$index) $position
set posit_label($index) $label
incr index
}
# set posit_indices [lsort -integer [array names posit_table]]
if [ catch { if [ catch {
set ns ::sobj::positmotor set ns ::sobj::positmotor
set parnode ${motname}_motor set parnode ${motor}_motor
MakeSICSObj $parnode SCT_MOTOR MakeSICSObj $parnode SCT_MOTOR
# Make setable position parameter and poll it. # Make setable position parameter and poll it.
set posindex_node /sics/${parnode}/${param} set posindex_node /sics/${parnode}/${param}
hfactory $posindex_node plain spy float hfactory $posindex_node plain spy float
hsetprop $posindex_node read ${ns}::rd_index $param $motname hsetprop $posindex_node read ${ns}::rd_index $param $motor
hsetprop $posindex_node state_reading_index ${ns}::state_reading_index $posindex_node $param hsetprop $posindex_node state_reading_index ${ns}::state_reading_index $posindex_node $param $motor
hsetprop $posindex_node write ${ns}::w_index $sct_controller $posindex_node $param $motname hsetprop $posindex_node write ${ns}::w_index $sct_controller $posindex_node $param $motor
hsetprop $posindex_node check ${ns}::check_motor hsetprop $posindex_node check ${ns}::check_motor
hsetprop $posindex_node oldval UNKNOWN hsetprop $posindex_node oldval UNKNOWN
@ -150,23 +188,25 @@ namespace eval ::sobj::positmotor {
hfactory $posindex_node/motprecision script "getmotpar samx precision" "samx precision " float 1 hfactory $posindex_node/motprecision script "getmotpar samx precision" "samx precision " float 1
hfactory $posindex_node/lookup_table plain spy none hfactory $posindex_node/lookup_table plain spy none
hsetprop $posindex_node/lookup_table numpos [llength $posit_indices] hsetprop $posindex_node/lookup_table ID $table_ID
foreach posindex $posit_indices { hsetprop $posindex_node/lookup_table numpos [llength $posit_indices($motor)]
hfactory $posindex_node/lookup_table/$posindex script "${ns}::pos2val $posindex" "${ns}::setposindex $posindex " float 1 foreach posindex $posit_indices($motor) {
hfactory $posindex_node/lookup_table/$posindex script "${ns}::pos2val $posindex $motor" "${ns}::setposindex $posindex $motor " float 1
hsetprop $posindex_node/lookup_table/$posindex ID $posit_label($posindex)
} }
hfactory $posindex_node/state plain spy text hfactory $posindex_node/status plain spy text
hset $posindex_node/state idle hset $posindex_node/status IDLE
proc ${motname}_MOTEND {} [subst -nocommands { proc ${motor}_MOTEND {} [subst -nocommands {
if { [hval $posindex_node/state] == "busy"} { if { [hval $posindex_node/status] == "BUSY"} {
$sct_controller poll $posindex_node 5 $sct_controller poll $posindex_node 5
hset $posindex_node/state stopping hset $posindex_node/status STOPPING
} }
}] }]
publish ${ns}::${motname}_MOTEND user publish ${ns}::${motor}_MOTEND user
scriptcallback connect $motname MOTEND ${ns}::${motname}_MOTEND scriptcallback connect $motor MOTEND ${ns}::${motor}_MOTEND
$sct_controller poll $posindex_node $sct_controller poll $posindex_node
$sct_controller write $posindex_node $sct_controller write $posindex_node
@ -185,6 +225,5 @@ namespace import ::sobj::positmotor::*
# #
# makesctcontroller /controllers/sct_mc1 std localhost:62034 # makesctcontroller /controllers/sct_mc1 std localhost:62034
# #
# mk_sct_positmotor sct_mc1 phi phi_posindex A # mk_sct_positmotor sct_mc1 chi index { 1 0 2 15 3 20 }
# mk_sct_positmotor sct_mc1 chi B { 1 0 2 15 3 20 }

View File

@ -12,4 +12,5 @@ config/hmm/anstohm_linked.xml
config/scan/scan_common_1.hdd config/scan/scan_common_1.hdd
config/scan/scan_common_1.tcl config/scan/scan_common_1.tcl
config/nexus/nxscripts_common_1.tcl config/nexus/nxscripts_common_1.tcl
config/commands/commands_common.tcl
config/motors/sct_positmotor_common.tcl config/motors/sct_positmotor_common.tcl

View File

@ -4,7 +4,12 @@ set CH1_MAXSPEED 1800
namespace eval ::chopper {} namespace eval ::chopper {}
if {$sim_mode == "true"} { if {$sim_mode == "true"} {
MakeChopper chopperController sim MakeChopper chopperController sim
ChopperAdapter chspeed chopperController speed 0 $CH1_MAXSPEED ChopperAdapter ch1speed chopperController speed 0 $CH1_MAXSPEED
ChopperAdapter ch2speed chopperController speed 0 $CH1_MAXSPEED
ChopperAdapter ch3speed chopperController speed 0 $CH1_MAXSPEED
ChopperAdapter ch4speed chopperController speed 0 $CH1_MAXSPEED
ChopperAdapter ch1phase chopperController phase 0 180
ChopperAdapter ch2phase chopperController phase 0 180 ChopperAdapter ch2phase chopperController phase 0 180
ChopperAdapter ch3phase chopperController phase 0 180 ChopperAdapter ch3phase chopperController phase 0 180
ChopperAdapter ch4phase chopperController phase 0 180 ChopperAdapter ch4phase chopperController phase 0 180
@ -33,7 +38,11 @@ if {$sim_mode == "true"} {
user $chopper_controller(user) \ user $chopper_controller(user) \
password $chopper_controller(password) \ password $chopper_controller(password) \
] ]
ChopperAdapter chspeed chopperController speed_1 0 $CH1_MAXSPEED ChopperAdapter ch1speed chopperController speed_1 0 $CH1_MAXSPEED
ChopperAdapter ch2speed chopperController speed_2 0 $CH1_MAXSPEED
ChopperAdapter ch3speed chopperController speed_3 0 $CH1_MAXSPEED
ChopperAdapter ch4speed chopperController speed_4 0 $CH1_MAXSPEED
ChopperAdapter ch1phase chopperController phase_1 0 180
ChopperAdapter ch2phase chopperController phase_2 0 180 ChopperAdapter ch2phase chopperController phase_2 0 180
ChopperAdapter ch3phase chopperController phase_3 0 180 ChopperAdapter ch3phase chopperController phase_3 0 180
ChopperAdapter ch4phase chopperController phase_4 0 180 ChopperAdapter ch4phase chopperController phase_4 0 180
@ -63,7 +72,11 @@ if {$sim_mode == "true"} {
} }
} }
sicslist setatt chspeed units "rpm" sicslist setatt ch1speed units "rpm"
sicslist setatt ch2speed units "rpm"
sicslist setatt ch3speed units "rpm"
sicslist setatt ch4speed units "rpm"
sicslist setatt ch1phase units "degrees"
sicslist setatt ch2phase units "degrees" sicslist setatt ch2phase units "degrees"
sicslist setatt ch3phase units "degrees" sicslist setatt ch3phase units "degrees"
sicslist setatt ch4phase units "degrees" sicslist setatt ch4phase units "degrees"

View File

@ -25,6 +25,10 @@ foreach vn {
chopper2_base chopper2_base
chopper1_distance chopper1_distance
chopper1_base chopper1_base
chopper1_phase_offset
chopper2_phase_offset
chopper3_phase_offset
chopper4_phase_offset
slit1_distance slit1_distance
slit1_base slit1_base
omega omega

View File

@ -5,11 +5,11 @@ namespace eval motor {
variable is_homing_list "" variable is_homing_list ""
} }
namespace eval sample { #namespace eval sample {
command select {int=0:8 sampid} { # command select {int=0:8 sampid} {
SampleNum $sampid # SampleNum $sampid
} # }
} #}
namespace eval optics { namespace eval optics {
VarMake ::optics::select::section text user VarMake ::optics::select::section text user

View File

@ -1,5 +1,5 @@
# $Revision: 1.24 $ # $Revision: 1.25 $
# $Date: 2008-08-19 05:11:55 $ # $Date: 2008-10-31 04:37:31 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au) # Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by: $Author: ffr $ # Last revision by: $Author: ffr $
@ -753,7 +753,7 @@ Motor apx $motor_driver_type [params \
axis E\ axis E\
units mm\ units mm\
hardlowerlim -10\ hardlowerlim -10\
hardupperlim 10\ hardupperlim 360\
maxSpeed 1\ maxSpeed 1\
maxAccel 1\ maxAccel 1\
maxDecel 1\ maxDecel 1\

View File

@ -1,12 +1,70 @@
source $cfPath(motors)/sct_positmotor_common.tcl source $cfPath(motors)/sct_positmotor_common.tcl
set port [::utility::get_portnum pmc1-quokka] set port1 [::utility::get_portnum pmc1-quokka]
makesctcontroller sct_mc1 std localhost:$port set port2 [::utility::get_portnum pmc2-quokka]
set port3 [::utility::get_portnum pmc3-quokka]
set port4 [::utility::get_portnum pmc4-quokka]
makesctcontroller sct_mc1 std mc1:$port1
makesctcontroller sct_mc2 std mc2:$port2
makesctcontroller sct_mc3 std mc3:$port3
makesctcontroller sct_mc4 std mc4:$port4
mk_sct_positmotor sct_mc1 samx samplenum C { # label pos
1 0 set 20sample_table {
2 15 1 453.7
3 20 2 411.7
3 369.7
4 327.7
5 285.7
6 203.7
7 161.7
8 119.7
9 77.7
10 35.7
11 -46.3
12 -88.3
13 -130.3
14 -172.3
15 -214.3
16 -296.3
17 -338.3
18 -380.3
19 -422.3
20 -464.3
} }
mk_sct_positmotor sct_mc1 samx samplenum 20SAMPLES $20sample_table
set auto_ap_table {
2.5 0
5.0 23
7.5 47
10.0 72
12.5 98
15.0 125
17.5 153
20.0 183
25.0 215
30.0 250
}
mk_sct_positmotor sct_mc3 apx aperture auto_ap $auto_ap_table

View File

@ -41,7 +41,7 @@ foreach {var lname nxname units klass} {
} }
} }
::utility::mkVar SampleNum int readonly changer_position true parameter true true # ::utility::mkVar SampleNum int readonly changer_position true parameter true true
## ##
# @brief Parameter SicsVariables # @brief Parameter SicsVariables

View File

@ -1,5 +1,5 @@
# $Revision: 1.15 $ # $Revision: 1.16 $
# $Date: 2008-10-27 04:55:47 $ # $Date: 2008-10-31 04:37:31 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au) # Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by: $Author: ffr $ # Last revision by: $Author: ffr $
@ -55,3 +55,10 @@ server_init
hsetprop /instrument/parameters/derived_parameters/$pname/feedback/status data false hsetprop /instrument/parameters/derived_parameters/$pname/feedback/status data false
hsetprop /instrument/parameters/derived_parameters/$pname/feedback/status nxsave false hsetprop /instrument/parameters/derived_parameters/$pname/feedback/status nxsave false
} }
hsetprop /sct_mc1 control false
hsetprop /sct_mc2 control false
hsetprop /sct_mc3 control false
hsetprop /sct_mc4 control false
hfactory /instrument/parameters/changer_position link samx_motor
hfactory /instrument/parameters/autoSampleAp link apx_motor

View File

@ -1,17 +1,24 @@
#!/bin/sh #!/bin/sh
ulimit -c unlimited
# We should really have an init script calling this or something like it. # We should really have an init script calling this or something like it.
INSTRUMENT=${HOSTNAME#ics1-} INSTRUMENT=${HOSTNAME#ics1-}
intserverport=60002
serverport=60003
intvalport=60012
valport=60013
# Start SICS # Start SICS
startsics() { startsics() {
if netstat -ltp 2> /dev/null|grep -q "server-${INSTRUMENT}.*SICServer"; then if netstat -nltp 2> /dev/null|grep -q "${serverport}.*SICServer"; then
echo SICS is already running echo SICS is already running
return 1 return 1
fi fi
echo Starting SICS echo Starting SICS
cd /usr/local/sics/server cd /usr/local/sics/server
nohup $PWD/SICServer ${INSTRUMENT}_configuration.tcl nohup $PWD/SICServer ${INSTRUMENT}_configuration.tcl
if netstat -ltp 2> /dev/null|grep -q "server-${INSTRUMENT}.*SICServer"; then if netstat -nltp 2> /dev/null|grep -q "${serverport}.*SICServer"; then
echo SUCCESS echo SUCCESS
return 1 return 1
else else
@ -22,7 +29,7 @@ startsics() {
# Start script validator # Start script validator
startscriptvalidator() { startscriptvalidator() {
if netstat -ltp 2> /dev/null|grep -q "server-val-${INSTRUMENT}.*SICServer"; then if netstat -nltp 2> /dev/null|grep -q "${valport}.*SICServer"; then
echo SICS script validator is already running echo SICS script validator is already running
return 1 return 1
fi fi
@ -30,7 +37,7 @@ startscriptvalidator() {
cd /usr/local/sics/server/ cd /usr/local/sics/server/
SICS_SIMULATION=script_validator nohup $PWD/SICServer ${INSTRUMENT}_configuration.tcl SICS_SIMULATION=script_validator nohup $PWD/SICServer ${INSTRUMENT}_configuration.tcl
if netstat -ltp 2> /dev/null|grep -q "server-val-${INSTRUMENT}.*SICServer"; then if netstat -nltp 2> /dev/null|grep -q "${valport}.*SICServer"; then
echo SUCCESS echo SUCCESS
return 1 return 1
else else
@ -39,6 +46,28 @@ startscriptvalidator() {
fi fi
} }
stopsics() {
if netstat -nltp 2> /dev/null|grep -q "${serverport}.*SICServer"; then
echo "SICSINT 6" |socat STDIN UDP4:localhost:${intserverport},crlf
fi
if netstat -nltp 2> /dev/null|grep -q "${serverport}.*SICServer"; then
echo FAILED to stop SICServer
else
echo SICServer stopped
fi
}
stopscriptvalidator() {
if netstat -nltp 2> /dev/null|grep -q "${valport}.*SICServer"; then
echo "SICSINT 6" |socat STDIN UDP4:localhost:${intvalport},crlf
fi
if netstat -nltp 2> /dev/null|grep -q "${valport}.*SICServer"; then
echo FAILED to stop SICS script validator
else
echo SICS script validator stopped
fi
}
usage() { usage() {
progname=`basename $0` progname=`basename $0`
echo Usage: $progname start echo Usage: $progname start
@ -63,29 +92,24 @@ then
echo echo
elif [ $1 = "stop" ] elif [ $1 = "stop" ]
then then
if killall SICServer; then if netstat -nltp 2> /dev/null|grep -q "${serverport}.*SICServer"; then
echo Terminating all SICS servers stopsics
else else
echo No SICS servers are running echo SICServer NOT running
fi fi
if netstat -ltp 2> /dev/null|grep -q "server-${INSTRUMENT}.*SICServer"; then if netstat -nltp 2> /dev/null|grep -q "${valport}.*SICServer"; then
echo FAILED to stop SICServer stopscriptvalidator
else else
echo SICServer stopped echo SICS script validator NOT running
fi
if netstat -ltp 2> /dev/null|grep -q "server-val-${INSTRUMENT}.*SICServer"; then
echo FAILED to stop SICS script validator
else
echo SICS script validator stopped
fi fi
elif [ $1 = "status" ] elif [ $1 = "status" ]
then then
if netstat -ltp 2> /dev/null|grep -q "server-${INSTRUMENT}.*SICServer"; then if netstat -nltp 2> /dev/null|grep -q "${serverport}.*SICServer"; then
echo SICServer running echo SICServer running
else else
echo SICServer NOT running echo SICServer NOT running
fi fi
if netstat -ltp 2> /dev/null|grep -q "server-val-${INSTRUMENT}.*SICServer"; then if netstat -nltp 2> /dev/null|grep -q "${valport}.*SICServer"; then
echo SICS script validator running echo SICS script validator running
else else
echo SICS script validator NOT running echo SICS script validator NOT running