hipadaba_configuration_common.tcl

Check all kinds of hdb nodes for units.

nxscripts_common_1.tcl
Make units optional when saving data.
Catch histogram memory savecmd errors.

r2188 | ffr | 2007-10-23 12:32:41 +1000 (Tue, 23 Oct 2007) | 7 lines
This commit is contained in:
Ferdi Franceschini
2007-10-23 12:32:41 +10:00
committed by Douglas Clowes
parent 9c307402cc
commit 8e6d4e4da6
2 changed files with 36 additions and 20 deletions

View File

@@ -116,6 +116,7 @@ proc ::hdb::add_node {basePath args} {
} }
if {[lsearch [hlist $basePath] $node_name] == -1} { if {[lsearch [hlist $basePath] $node_name] == -1} {
#TODO allow hdb nodes of type drivable countable environment #TODO allow hdb nodes of type drivable countable environment
array set attribute [attlist $node_name]
switch $arg_array(kind) { switch $arg_array(kind) {
command { command {
# A command is a macro, node=macro name # A command is a macro, node=macro name
@@ -156,7 +157,6 @@ proc ::hdb::add_node {basePath args} {
script { script {
# A r/w pair of scripts, node = a node path # A r/w pair of scripts, node = a node path
set node_path $basePath/[getatt $node_name long_name] set node_path $basePath/[getatt $node_name long_name]
array set attribute [attlist $node_name]
set data_type [getatt $node_name dtype] set data_type [getatt $node_name dtype]
set data_length [getatt $node_name dlen] set data_length [getatt $node_name dlen]
if {[getatt $node_name access] == "read_only"} { if {[getatt $node_name access] == "read_only"} {
@@ -171,12 +171,12 @@ proc ::hdb::add_node {basePath args} {
hsetprop $node_path klass [getatt $node_name klass] hsetprop $node_path klass [getatt $node_name klass]
hsetprop $node_path sdsinfo [getatt $node_name sdsinfo] hsetprop $node_path sdsinfo [getatt $node_name sdsinfo]
hsetprop $node_path savecmd [getatt $node_name savecmd] hsetprop $node_path savecmd [getatt $node_name savecmd]
if {[info exists attribute(units)]} {
hsetprop $node_path units $attribute(units)
}
#hmakescript $node_path $arg_array(rscript) $arg_array(wscript) $arg_array(dtype) $arg_array(dlen) #hmakescript $node_path $arg_array(rscript) $arg_array(wscript) $arg_array(dtype) $arg_array(dlen)
} }
} }
if {[info exists attribute(units)]} {
hsetprop $node_path units $attribute(units)
}
if {[info exists arg_array(prop_list)]} { if {[info exists arg_array(prop_list)]} {
foreach {prop pval} $arg_array(prop_list) { foreach {prop pval} $arg_array(prop_list) {
hsetprop $node_path $prop $pval hsetprop $node_path $prop $pval

View File

@@ -333,7 +333,7 @@ proc newfile {type {namestyle data}} {
# #
# NOTE: If a link has already been recorded then it does nothing. This allows you to # NOTE: If a link has already been recorded then it does nothing. This allows you to
# override default links set by a command. eg A "count" command may link axis_1 to # override default links set by a command. eg A "count" command may link axis_1 to
# the run number but a "scan" command which uses the count command can link axis_1 to # the run number but a "scan" command, which uses the count command, can link axis_1 to
# a scan variable. # a scan variable.
# #
# Usage: # Usage:
@@ -644,6 +644,7 @@ proc ::nexus::hdb2nx_type {dtype} {
# #
# @see set_sobj_attributes # @see set_sobj_attributes
proc ::nexus::histmem::save {hm nxalias data_type args} { proc ::nexus::histmem::save {hm nxalias data_type args} {
if [catch {
set rank [SplitReply [$hm configure rank]] set rank [SplitReply [$hm configure rank]]
set datalen 1 set datalen 1
@@ -659,6 +660,9 @@ proc ::nexus::histmem::save {hm nxalias data_type args} {
set data_start 0 set data_start 0
set bank 0 set bank 0
nxscript putslab $nxalias $indStartList $indLenList $hm $data_start $datalen $bank nxscript putslab $nxalias $indStartList $indLenList $hm $data_start $datalen $bank
}] {
return -code error $::errorInfo
}
} }
# TODO Get rank from /data # TODO Get rank from /data
@@ -695,12 +699,18 @@ proc ::nexus::motor::save {motor nxalias data_type args} {
} }
proc ::nexus::motor::sdsinfo {motor data_type args} { proc ::nexus::motor::sdsinfo {motor data_type args} {
array set param $args array set param $args
array set mot_prop [attlist $motor] array set attribute [attlist $motor]
set dtype [::nexus::hdb2nx_type $data_type] set dtype [::nexus::hdb2nx_type $data_type]
if {$param(mutable) == true} { if {[info exists attribute(units)]} {
return " -type $dtype -rank 1 -dim {-1} -attr {units,$mot_prop(units)} -attr {long_name,$mot_prop(long_name)}" set units_att " -attr {units,$attribute(units)} "
} else { } else {
return " -type $dtype -attr {units,$mot_prop(units)} -attr {long_name,$mot_prop(long_name)}" set units_att " "
}
set name_att " -attr {long_name,$attribute(long_name)} "
if {$param(mutable) == true} {
return " -type $dtype -rank 1 -dim {-1} $units_att $name_att"
} else {
return " -type $dtype $units_att $name_att"
} }
} }
@@ -716,12 +726,18 @@ proc ::nexus::environment_controller::save {evc nxalias data_type args} {
} }
proc ::nexus::environment_controller::sdsinfo {evc data_type args} { proc ::nexus::environment_controller::sdsinfo {evc data_type args} {
array set param $args array set param $args
array set evc_prop [attlist $evc] array set attribute [attlist $evc]
set dtype [::nexus::hdb2nx_type $data_type] set dtype [::nexus::hdb2nx_type $data_type]
if {$param(mutable) == true} { if {[info exists attribute(units)]} {
return " -type $dtype -rank 1 -dim {-1} -attr {units,$evc_prop(units)} -attr {long_name,$evc_prop(long_name)}" set units_att " -attr {units,$attribute(units)} "
} else { } else {
return " -type $dtype -attr {units,$evc_prop(units)} -attr {long_name,$evc_prop(long_name)}" set units_att " "
}
set name_att " -attr {long_name,$attribute(long_name)} "
if {$param(mutable) == true} {
return " -type $dtype -rank 1 -dim {-1} $units_att $name_att"
} else {
return " -type $dtype $units_att $name_att"
} }
} }
@@ -807,7 +823,7 @@ proc ::nexus::script::sdsinfo {script data_type args} {
set tmpstr [string map {"$" ""} {$Name: not supported by cvs2svn $}] set tmpstr [string map {"$" ""} {$Name: not supported by cvs2svn $}]
set nx_content_release_tag [lindex $tmpstr [expr [llength $tmpstr] - 1]] set nx_content_release_tag [lindex $tmpstr [expr [llength $tmpstr] - 1]]
set tmpstr [string map {"$" ""} {$Revision: 1.31 $}] set tmpstr [string map {"$" ""} {$Revision: 1.32 $}]
set nx_content_revision_num [lindex $tmpstr [expr [llength $tmpstr] - 1]] set nx_content_revision_num [lindex $tmpstr [expr [llength $tmpstr] - 1]]
namespace eval data { namespace eval data {