Merged 2.4 branch

r2828 | ffr | 2009-11-25 09:56:49 +1100 (Wed, 25 Nov 2009) | 2 lines
This commit is contained in:
Ferdi Franceschini
2009-11-25 09:56:49 +11:00
committed by Douglas Clowes
parent c58ee9fbcb
commit 2ec6505ef8
71 changed files with 2237 additions and 1528 deletions

View File

@@ -16,6 +16,7 @@ namespace eval ::histogram {
int=0:inf preset
float freq
text=[join $::histogram_memory::ic_fsrce_values , ] frame_source
text=safe,fast cmd_mode
}] {
variable parameters
switch $cmd {
@@ -29,21 +30,28 @@ namespace eval ::histogram {
}
"start" {
::histogram::histmem_cmd -set feedback status STARTING
if {$parameters(mode) != $mode} {
if {$cmd_mode == "fast"} {
if {$parameters(mode) != $mode} {
histmem mode $mode
set parameters(mode) $mode
}
if {$parameters(preset) != $preset} {
histmem preset $preset
set parameters(preset) $preset
}
if {$parameters(freq) != $freq} {
histmem freq $freq
set parameters(freq) $freq
}
if {$parameters(frame_source) != $frame_source} {
histmem fsrce $frame_source
set parameters(frame_source) $frame_source
}
} else {
histmem mode $mode
set parameters(mode) $mode
}
if {$parameters(preset) != $preset} {
histmem preset $preset
set parameters(preset) $preset
}
if {$parameters(freq) != $freq} {
histmem freq $freq
set parameters(freq) $freq
}
if {$parameters(frame_source) != $frame_source} {
histmem fsrce $frame_source
set parameters(frame_source) $frame_source
}
histmem start
::histogram::histmem_cmd -set feedback status BUSY
@@ -53,13 +61,15 @@ namespace eval ::histogram {
}
}
}
::histogram::histmem_cmd -set mode [histmem mode]
::histogram::histmem_cmd -set preset [histmem preset]
::histogram::histmem_cmd -set freq [histmem freq]
::histogram::histmem_cmd -set frame_source [histmem fsrce]
::histogram::histmem_cmd -set mode [::histogram_memory::count_method]
::histogram::histmem_cmd -set preset 0
::histogram::histmem_cmd -set freq [::histogram_memory::get_frame_freq ]
::histogram::histmem_cmd -set frame_source [::histogram_memory::get_frame_source ]
::histogram::histmem_cmd -set cmd_mode "safe"
::histogram::histmem_cmd -addfb text status
::histogram::histmem_cmd -set feedback status IDLE
sicslist setatt ::histogram::histmem_cmd long_name histmem
sicslist setatt ::histogram::histmem_cmd id histmem
}
# SCAN COMMANDS
namespace eval ::scan {
@@ -106,6 +116,10 @@ command hdb_bmonscan {
text=save,nosave savetype
text=true,false force
}] {
variable parameters
set parameters(mode) $mode
set parameters(preset) $preset
::scan::runscan $scan_variable $scan_start $scan_stop $numpoints $mode $preset savetype $savetype datatype $datatype force $force
}
::scan::runscan_cmd -addfb float scan_variable_value float scan_step int scanpoint text status

View File

@@ -27,7 +27,7 @@ set instrument_dictionary [subst {
property {data true control true nxsave false klass @none type graphset}
}
instrument {
sobj {@any instrument @any NXvelocity_selector}
sobj {@any instrument @any NXvelocity_selector @any NXaperture @any NXdetector}
privilege spy
datatype @none
property {data true control true nxsave false klass NXinstrument type instrument}
@@ -38,6 +38,11 @@ set instrument_dictionary [subst {
datatype @none
property {data true control true nxsave true klass NXparameter type part}
}
instrument/parameters/parameters_group {
privilege spy
datatype @none
property {data true control false nxsave false klass @none type nxvgroup nxalias parameters_group}
}
instrument/parameters/derived_parameters {
privilege spy
sobj {@any derived_parameter}
@@ -140,12 +145,6 @@ set instrument_dictionary [subst {
datatype @none
property {data true control true nxsave false klass NXsource type part}
}
instrument/velocity_selector {
privilege spy
sobj {@any velocity_selector}
datatype @none
property {data true control true nxsave false klass NXvelocity_selector type part}
}
instrument/detector {
privilege spy
sobj {@any detector}
@@ -176,18 +175,17 @@ set instrument_dictionary [subst {
datatype @none
property {data true control true nxsave false klass NXsample type part}
}
sample/sample_group {
privilege spy
datatype @none
property {data true control false nxsave false klass @none type nxvgroup nxalias sample_group}
}
monitor {
privilege spy
sobj {@any monitor}
datatype @none
property {data true control true nxsave false klass NXmonitor type part}
}
data {
privilege spy
sobj {@any data}
datatype @none
property {data true control false nxsave false klass NXdata type part datatype UNKNOWN currentfiletype UNKNOWN}
}
event_data {
privilege spy
sobj {@any event_data}
@@ -225,74 +223,15 @@ set instrument_dictionary [subst {
datatype @none
property {data false control true nxsave false klass @none type part}
}
data {
privilege spy
sobj {@any data}
datatype @none
property {data true control false nxsave false klass NXdata type part datatype UNKNOWN currentfiletype UNKNOWN}
}
data/data_set {
privilege spy
datatype @none
property {data true control false nxsave false klass @none type nxvgroup nxalias data_set link @none}
}
data/axis_1 {
privilege spy
datatype @none
property {data true control false nxsave false klass @none type nxvgroup nxalias axis_1 link @none}
}
data/axis_2 {
privilege spy
datatype @none
property {data true control false nxsave false klass @none type nxvgroup nxalias axis_2 link @none}
}
data/axis_3 {
privilege spy
datatype @none
property {data true control false nxsave false klass @none type nxvgroup nxalias axis_3 link @none}
}
data/axis_4 {
privilege spy
datatype @none
property {data true control false nxsave false klass @none type nxvgroup nxalias axis_4 link @none}
}
data/aux_data_1 {
privilege spy
datatype @none
property {data true control false nxsave false klass @none type nxvgroup nxalias aux_data_1 link @none}
}
data/aux_data_2 {
privilege spy
datatype @none
property {data true control false nxsave false klass @none type nxvgroup nxalias aux_data_2 link @none}
}
data/aux_data_3 {
privilege spy
datatype @none
property {data true control false nxsave false klass @none type nxvgroup nxalias aux_data_3 link @none}
}
data/aux_data_4 {
privilege spy
datatype @none
property {data true control false nxsave false klass @none type nxvgroup nxalias aux_data_4 link @none}
}
data/aux_data_5 {
privilege spy
datatype @none
property {data true control false nxsave false klass @none type nxvgroup nxalias aux_data_5 link @none}
}
data/aux_data_6 {
privilege spy
datatype @none
property {data true control false nxsave false klass @none type nxvgroup nxalias aux_data_6 link @none}
}
data/aux_data_7 {
privilege spy
datatype @none
property {data true control false nxsave false klass @none type nxvgroup nxalias aux_data_7 link @none}
}
data/aux_data_8 {
privilege spy
datatype @none
property {data true control false nxsave false klass @none type nxvgroup nxalias aux_data_8 link @none}
}
data/aux_data_9 {
privilege spy
datatype @none
property {data true control false nxsave false klass @none type nxvgroup nxalias aux_data_9 link @none}
property {data true control false nxsave false klass @none type nxvgroup nxalias data_set}
}
}]

View File

@@ -205,7 +205,6 @@ proc ::hdb::MakeVelocity_Selector {name paramlist} {
# @param level, (optional,default=1) The location of the template parameters in the callstack.
proc prune_NX {NXklist nx_template {path ""} {node ""} {level 1}} {
upvar $NXklist newtable
# puts "[info level 0]\nCallstack depth = [info level]\nRecursion depth = [expr $level-1]"
if {$path == ""} {
set currpath $node
} else {
@@ -541,10 +540,6 @@ proc ::hdb::add_node {basePath args} {
hsetprop $node_path/$child klass [getatt $node_name klass]
}
}
scobj {
set node_path ${basePath}/$node_name
hfactory $node_path link $node_name
}
script - getset {
# A r/w pair of scripts, node = a node path
set node_path $basePath/[normalgetatt $node_name long_name]
@@ -616,6 +611,7 @@ proc ::hdb::add_command {basePath command} {
hsetprop $cmd_path control $cmd_atts(control)
hsetprop $cmd_path klass $cmd_atts(klass)
hsetprop $cmd_path nxsave $cmd_atts(nxsave)
hsetprop $cmd_path sicsdev $cmd_atts(id)
return $cmd_path
}
@@ -687,7 +683,9 @@ proc ::hdb::sobjadd {hpath sobj args} {
array unset sobjatt
if [ catch {
array set sobjatt [attlist $sobj]
sicslist setatt $sobj id $sobj
if {[sicslist exists $sobj id] == false} {
sicslist setatt $sobj id $sobj
}
switch $sobjatt(type) {
motor - configurablevirtualmotor {
if {[info exists sobjatt(group)]} {
@@ -791,8 +789,11 @@ proc ::hdb::sobjadd {hpath sobj args} {
}
# TODO Can this be replaced with a sct_* glob?
sct_object {
set sobjName [normalgetatt $sobj long_name]
add_node $hpath node $sobjName long_name $sobjName kind scobj
set node_name [normalgetatt $sobj long_name]
set node_path $hpath/$node_name
hfactory $node_path link $sobj
hsetprop $node_path type $sobjatt(type)
sicslist setatt $sobj hdb_path $node_path
}
environment_controller {
todo_msg "$sobjatt(type) case, add $sobj to $hpath"
@@ -849,7 +850,9 @@ proc ::hdb::sobjtypeadd {hpath sobjtype given_klass} {
proc ::hdb::prune {instdict} {
upvar $instdict dict
array set dictarr $dict
set candidates [array names dictarr]
foreach {n v} $dict {
lappend candidates $n
}
# While there are candidates for removal remove the childless ones
# which have an empty sobj list
while {[expr [llength $candidates]] > 0} {
@@ -870,6 +873,13 @@ proc ::hdb::prune {instdict} {
if { [llength [join $sobjects]] == 0 } {
if {[llength [array get dictarr $name/*]] == 0} {
array unset dictarr $name
foreach {n v} $dict {
if {$n != $name} {
lappend tempdict $n
lappend tempdict $v
}
}
set $dict $tempdict
} else {
if {[lsearch $candidates $name/*] >= 0} {
lappend new_candidates $name
@@ -879,7 +889,6 @@ proc ::hdb::prune {instdict} {
}
set candidates $new_candidates
}
set dict [array get dictarr]
return
}
@@ -922,32 +931,34 @@ upvar #0 $instDict dictionary
# @param top This is just here to make the recursion work from the top level, You don't need
# to set this
proc ::hdb::set_save {hpath mode {top true}} {
if {$hpath != "/"} {
set hnode $hpath
} else {
foreach hp [hlist /] {
::hdb::set_save /$hp $mode
}
return
}
if {[::utility::hgetplainprop $hnode data] == "false"} {
return
}
foreach hp [hlist $hnode] {
set_save $hnode/$hp $mode false
}
if {$top == "true"} {
hsetprop $hnode nxsave $mode
if {$mode == "true"} {
set hp ""
foreach ps [lrange [split [string trim $hnode /] /] 0 end-1] {
set hp $hp/$ps
hsetprop $hp nxsave true
}
if [ catch {
if {$hpath != "/"} {
set hnode $hpath
if {[hpropexists $hnode data] && [hgetpropval $hnode data] != "false"} {
foreach hp [hlist $hnode] {
set_save $hnode/$hp $mode false
}
if {$top == "true"} {
hsetprop $hnode nxsave $mode
if {$mode == "true"} {
set hp ""
foreach ps [lrange [split [string trim $hnode /] /] 0 end-1] {
set hp $hp/$ps
hsetprop $hp nxsave true
}
}
} else {
hsetprop $hnode nxsave $mode
}
}
} else {
foreach hp [hlist /] {
::hdb::set_save /$hp $mode
}
}
} else {
hsetprop $hnode nxsave $mode
}
} message ] {
return -code error "([info level 0]) $message"
}
}
namespace import ::hdb::*

View File

@@ -1,49 +1,35 @@
sicsdatafactory new ::histogram_memory::two_theta_array
sicsdatafactory new ::histogram_memory::x_pixel_angular_offset_array
namespace eval histogram_memory {
::utility::mkVar detector_radius_mm Float user radius true detector true true
sicslist setatt detector_radius_mm units mm
##
# @brief Calculate two_theta array from X bin boundaries
# @brief Calculate x_pixel_angular_offset array from X bin boundaries
#
# requires detector_active_width_mm det_radius_mm deg_per_rad
proc two_theta {args} {
proc x_pixel_angular_offset {args} {
variable state
if [ catch {
set opt [lindex $args 0]
set arglist [lrange $args 1 end]
set proc_name [namespace origin [lindex [info level 0] 0]]
set deg_per_radian [SplitReply [deg_per_rad]]
switch -- $opt {
"-centres" - "-boundaries" - "-graph_type" {
return [::histogram_memory::calc_axis $proc_name @none @none @none $opt $args]
}
"-arrayname" {
set max_chan [OAT_TABLE X -getdata MAX_CHAN]
set max_chan [OAT_TABLE X -getdata MAX_CHAN]
set bb_zero_offset [expr -1*($max_chan-1)]
set det_width_mm [SplitReply [detector_active_width_mm]]
set det_radius_mm [SplitReply [detector_radius_mm]]
set scale_factor [expr {$deg_per_radian*($det_width_mm/$det_radius_mm) / $max_chan}]
set offset [::histogram_memory::detector_posn_degrees]
return [::histogram_memory::calc_axis $proc_name $scale_factor $offset [OAT_TABLE X -getdata BOUNDARIES] $opt $arglist]
}
"-units" {
return "degrees"
}
default {
set max_chan [OAT_TABLE X -getdata MAX_CHAN]
set det_width_mm [SplitReply [detector_active_width_mm]]
set det_radius_mm [SplitReply [detector_radius_mm]]
set scale_factor [expr {$deg_per_radian*($det_width_mm/$det_radius_mm) / $max_chan}]
set offset [::histogram_memory::detector_posn_degrees]
return [::histogram_memory::calc_axis $proc_name $scale_factor $offset [OAT_TABLE X -getdata BOUNDARIES] $args]
}
set scale_factor [expr {-1.0*$deg_per_radian*($det_width_mm/$det_radius_mm) / $max_chan}]
# set offset [::histogram_memory::detector_posn_degrees]
set offset 0
::histogram_memory::calc_axis "x_pixel_angular_offset" $scale_factor $offset [OAT_TABLE X -getdata BOUNDARIES] $bb_zero_offset
if {$args == "-get_data_ref"} {
return "::histogram_memory::x_pixel_angular_offset_array"
} else {
return [::histogram_memory::x_pixel_angular_offset_array used]
}
} message ] {
if {$::errorCode=="NONE"} {return $message}
return -code error $message
}
}
set script_name ::histogram_memory::two_theta
set script_name ::histogram_memory::x_pixel_angular_offset
publish $script_name user
sicslist setatt $script_name privilege user
sicslist setatt $script_name kind script
@@ -54,9 +40,9 @@ namespace eval histogram_memory {
sicslist setatt $script_name control false
sicslist setatt $script_name data true
sicslist setatt $script_name nxsave true
sicslist setatt $script_name mutable true
sicslist setatt $script_name long_name two_theta
sicslist setatt $script_name units [::histogram_memory::two_theta -units]
sicslist setatt $script_name mutable false
sicslist setatt $script_name long_name x_pixel_angular_offset
sicslist setatt $script_name units "degrees"
unset script_name
::histogram_memory::two_theta -boundaries
::histogram_memory::set_graphtype "x_pixel_angular_offset" "boundaries"
}

View File

@@ -130,7 +130,7 @@ namespace eval ::scobj::positmotor {
# }
sct oldval $data
sct update $data
if {$data > 0} {
if {$data > 0 && [string is integer $data]} {
if {$calc_instpar == "@none"} {
hset $path/$staticpar $posit_label($motor,$data)
} else {
@@ -155,15 +155,18 @@ namespace eval ::scobj::positmotor {
set val [pos2val [sct target] $motor]
hset $path/status BUSY
run $motor $val
$sct_controller poll $path 1
# $sct_controller poll $path 1
} errmsg ] {
error $errmsg
return idle
return noResponse
} else {
return idle
return noResponse
}
}
proc noResponse {} {
return idle
}
# TODO Check thread 0 and motion control disabled?
proc check_motor {} {
@@ -217,6 +220,7 @@ namespace eval ::scobj::positmotor {
hsetprop $scobjPath/$pindex read ${ns}::rd_index $pindex $motor
hsetprop $scobjPath/$pindex state_reading_index ${ns}::state_reading_index $scobjPath $pindex $motor $staticpar $calc_instpar
hsetprop $scobjPath/$pindex write ${ns}::w_index $sct_controller $scobjPath $pindex $motor
hsetprop $scobjPath/$pindex noResponse ${ns}::noResponse
hsetprop $scobjPath/$pindex check ${ns}::check_motor
hsetprop $scobjPath/$pindex oldval UNKNOWN
@@ -239,7 +243,7 @@ namespace eval ::scobj::positmotor {
proc ${motor}_MOTEND {} [subst -nocommands {
if { [hval $scobjPath/status] == "BUSY"} {
$sct_controller poll $scobjPath/$pindex 5
# $sct_controller poll $scobjPath/$pindex 5
hset $scobjPath/status STOPPING
}
}]
@@ -247,7 +251,7 @@ namespace eval ::scobj::positmotor {
scriptcallback connect $motor MOTEND ${ns}::${motor}_MOTEND
$sct_controller poll $scobjPath/$pindex
$sct_controller poll $scobjPath/$pindex 2
$sct_controller write $scobjPath/$pindex
sicslist setatt $scobjName long_name $scobjName

File diff suppressed because it is too large Load Diff

View File

@@ -376,6 +376,7 @@ namespace eval scan {
variable reset_position
variable force_scan
if [ catch {
set force_scan false
set hm_ft_names [array names ::nexus::histmem_filetype_spec]
@@ -386,13 +387,13 @@ namespace eval scan {
set savetype "save"
set reset_position [SplitReply [::scan::runscan_reset_position]]
if {[is_drivable $scanvar] == 0} {
return -code error "The scan variable <$scanvar> must be drivable"
error "The scan variable <$scanvar> must be drivable"
}
if {[string is integer $numpoints] != 1} {
return -code error "Number of points <$numpoints> must be an integer"
error "Number of points <$numpoints> must be an integer"
}
if { $numpoints < 1 } {
return -code error "Number of points <$numpoints> must not be less than one"
error "Number of points <$numpoints> must not be less than one"
}
::histogram_memory::count_method $mode
::histogram_memory::count_size $preset
@@ -417,11 +418,7 @@ namespace eval scan {
}
}
"datatype" {
if {[lsearch $hm_ft_names $val] == -1} {
error "ERROR: datatype should be one of $hm_ft_names"
} else {
set ic_hmm_datatype $val
}
set ic_hmm_datatype $val
}
"savetype" {
switch $val {
@@ -432,7 +429,7 @@ namespace eval scan {
set save_filetype scratch
}
default {
return -code error "ERROR: $arg $val, valid values for $arg are 'save' or 'nosave'"
error "ERROR: $arg $val, valid values for $arg are 'save' or 'nosave'"
}
}
}
@@ -452,14 +449,14 @@ namespace eval scan {
::scan::runscan_cmd -set feedback scan_step $step
::scan::runscan_cmd -set mode $mode
::scan::runscan_cmd -set preset $preset
set status [catch {hmscan run $numpoints timer 0} msg]
hmscan run $numpoints timer 0
} message ] {
set force_scan false
if {$status == 0} {
return $msg
} else {
return -code error "ERROR [info level 0]\n$msg"
}
return -code error "ERROR [info level 0]\n$message"
} else {
set force_scan false
return $message
}
}
}
namespace import ::scan::runscan