Save scratch files in data directory.
Refactor to have explicit ::nexus:: prefix on procedures. r2204 | ffr | 2007-10-31 16:44:38 +1100 (Wed, 31 Oct 2007) | 3 lines
This commit is contained in:
committed by
Douglas Clowes
parent
5c66aa29ac
commit
f8c64b55a0
@@ -5,33 +5,14 @@
|
|||||||
|
|
||||||
MakeNXScript
|
MakeNXScript
|
||||||
sicsdatafactory new nxscript_data
|
sicsdatafactory new nxscript_data
|
||||||
|
|
||||||
##
|
|
||||||
# @brief Strips the output of a SICS command leaving only the value\n
|
|
||||||
# TODO Replace $cmd_output with [$cmd_output] so we can just pass the command name
|
|
||||||
#
|
|
||||||
# @param cmd_output The output from a command substitution
|
|
||||||
# @return The unadorned value returned by the SICS command which produced cmd_output
|
|
||||||
proc getVal {cmd_output} {
|
|
||||||
return [string trim [lindex [split $cmd_output =] 1 ] ]
|
|
||||||
}
|
|
||||||
|
|
||||||
##
|
|
||||||
# @brief Generate a filename from sicsdatanumber and sicsdatapath
|
|
||||||
#
|
|
||||||
# @param postfix This is the filename suffix, must be one of: nx.hdf, hdf, h5, nx5, xml
|
|
||||||
proc newFileName {postfix} {
|
|
||||||
array set inst_mnem {quokka QKK wombat WBT echidna ECH kowari KWR koala KOL taipan TPN platypus PLP pelican PLN}
|
|
||||||
set idNum [SplitReply [sicsdatanumber]]
|
|
||||||
set dataPath [SplitReply [sicsdatapath]]
|
|
||||||
# set prefix [SplitReply [sicsdataprefix]]
|
|
||||||
set date_time_arr [split [sicstime] " "]
|
|
||||||
set isodate [lindex $date_time_arr 0]
|
|
||||||
set isotime [string map {: -} [lindex $date_time_arr 1]]
|
|
||||||
return [format "%s/%s%07d.%s" $dataPath $inst_mnem([instname]) $idNum $postfix]
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace eval nexus {
|
namespace eval nexus {
|
||||||
|
set exports [list newfile closefile save data]
|
||||||
|
eval namespace export $exports
|
||||||
|
if 0 {datafilename}
|
||||||
|
|
||||||
|
variable filetypes
|
||||||
|
set filetypes [list BEAM_MONITOR HISTOPERIOD_XYT TOTAL_HISTOGRAM_XY TOTAL_HISTOGRAM_XT TOTAL_HISTOGRAM_YT TOTAL_HISTOGRAM_X TOTAL_HISTOGRAM_Y TOTAL_HISTOGRAM_T ]
|
||||||
|
|
||||||
##
|
##
|
||||||
# @brief This is the nexus dictionary generated by the gen_nxdict function
|
# @brief This is the nexus dictionary generated by the gen_nxdict function
|
||||||
variable nxdictionary
|
variable nxdictionary
|
||||||
@@ -100,6 +81,35 @@ namespace eval nexus {
|
|||||||
save_policy {include @all exclude {hmm_xy hmm_xt hmm_yt hmm_x hmm_y hmm}}
|
save_policy {include @all exclude {hmm_xy hmm_xt hmm_yt hmm_x hmm_y hmm}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# @brief Strips the output of a SICS command leaving only the value\n
|
||||||
|
# TODO Replace $cmd_output with [$cmd_output] so we can just pass the command name
|
||||||
|
#
|
||||||
|
# @param cmd_output The output from a command substitution
|
||||||
|
# @return The unadorned value returned by the SICS command which produced cmd_output
|
||||||
|
proc getVal {cmd_output} {
|
||||||
|
return [string trim [lindex [split $cmd_output =] 1 ] ]
|
||||||
|
}
|
||||||
|
|
||||||
|
proc ::nexus::datapath {} {
|
||||||
|
return [SplitReply [sicsdatapath]]
|
||||||
|
}
|
||||||
|
##
|
||||||
|
# @brief Generate a filename from sicsdatanumber and sicsdatapath
|
||||||
|
#
|
||||||
|
# @param postfix This is the filename suffix, must be one of: nx.hdf, hdf, h5, nx5, xml
|
||||||
|
proc newFileName {postfix} {
|
||||||
|
|
||||||
|
array set inst_mnem {quokka QKK wombat WBT echidna ECH kowari KWR koala KOL taipan TPN platypus PLP pelican PLN}
|
||||||
|
set idNum [SplitReply [sicsdatanumber]]
|
||||||
|
# set prefix [SplitReply [sicsdataprefix]]
|
||||||
|
set date_time_arr [split [sicstime] " "]
|
||||||
|
set isodate [lindex $date_time_arr 0]
|
||||||
|
set isotime [string map {: -} [lindex $date_time_arr 1]]
|
||||||
|
return [format "%s/%s%07d.%s" [::nexus::datapath] $inst_mnem([instname]) $idNum $postfix]
|
||||||
|
}
|
||||||
|
|
||||||
proc ::nexus::process_filetype_policy {filetype filetype_spec} {
|
proc ::nexus::process_filetype_policy {filetype filetype_spec} {
|
||||||
upvar $filetype_spec ft_spec
|
upvar $filetype_spec ft_spec
|
||||||
@@ -115,7 +125,6 @@ namespace eval nexus {
|
|||||||
::nexus::data $policy
|
::nexus::data $policy
|
||||||
}
|
}
|
||||||
"save_policy" {
|
"save_policy" {
|
||||||
clientput "save_policy is $policy"
|
|
||||||
foreach {save_action action_list} $policy {
|
foreach {save_action action_list} $policy {
|
||||||
switch $save_action {
|
switch $save_action {
|
||||||
"include" {
|
"include" {
|
||||||
@@ -155,13 +164,10 @@ namespace eval nexus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set exports [list newfile closefile save data]
|
|
||||||
eval namespace export $exports
|
|
||||||
if 0 {datafilename}
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# @brief Initialise state variables
|
# @brief Initialise state variables
|
||||||
proc init {} {
|
proc ::nexus::init {} {
|
||||||
variable state
|
variable state
|
||||||
variable nexusdic
|
variable nexusdic
|
||||||
array set state {file,new "true" file,open "false" file,namestyle "data"\
|
array set state {file,new "true" file,open "false" file,namestyle "data"\
|
||||||
@@ -173,7 +179,7 @@ namespace eval nexus {
|
|||||||
# @brief Create a nexus file
|
# @brief Create a nexus file
|
||||||
# This first generates a nexus dictionary file from the hdb tree and then creates a new
|
# This first generates a nexus dictionary file from the hdb tree and then creates a new
|
||||||
# nexus file based on that dictionary.
|
# nexus file based on that dictionary.
|
||||||
proc createfile {} {
|
proc ::nexus::createfile {} {
|
||||||
global cfPath
|
global cfPath
|
||||||
variable nexusdic
|
variable nexusdic
|
||||||
variable state
|
variable state
|
||||||
@@ -187,7 +193,7 @@ namespace eval nexus {
|
|||||||
array set nxmode [list nx.hdf create5 hdf create5 h5 create5 nx5 create5 xml createxml]
|
array set nxmode [list nx.hdf create5 hdf create5 h5 create5 nx5 create5 xml createxml]
|
||||||
set nxdict_path [::nexus::gen_nxdict $nexusdic]
|
set nxdict_path [::nexus::gen_nxdict $nexusdic]
|
||||||
if {$state(file,namestyle) == "scratch"} {
|
if {$state(file,namestyle) == "scratch"} {
|
||||||
dataFileName [format "scratch.%s" $file_format]
|
dataFileName [format "%s/scratch.%s" [::nexus::datapath] $file_format]
|
||||||
} else {
|
} else {
|
||||||
sicsdatanumber incr
|
sicsdatanumber incr
|
||||||
dataFileName [newFileName $file_format]
|
dataFileName [newFileName $file_format]
|
||||||
@@ -198,13 +204,11 @@ namespace eval nexus {
|
|||||||
set state(file,new) false
|
set state(file,new) false
|
||||||
}
|
}
|
||||||
|
|
||||||
variable filetypes
|
|
||||||
set filetypes [list BEAM_MONITOR HISTOPERIOD_XYT TOTAL_HISTOGRAM_XY TOTAL_HISTOGRAM_XT TOTAL_HISTOGRAM_YT TOTAL_HISTOGRAM_X TOTAL_HISTOGRAM_Y TOTAL_HISTOGRAM_T ]
|
|
||||||
##
|
##
|
||||||
# @brief Checks if the given file type is defined.
|
# @brief Checks if the given file type is defined.
|
||||||
#
|
#
|
||||||
# @return 1 on success, 0 on failure
|
# @return 1 on success, 0 on failure
|
||||||
proc isValidFileType {type} {
|
proc ::nexus::isValidFileType {type} {
|
||||||
variable filetypes
|
variable filetypes
|
||||||
if {[lsearch $filetypes $type] == -1} {
|
if {[lsearch $filetypes $type] == -1} {
|
||||||
return 0
|
return 0
|
||||||
@@ -224,7 +228,7 @@ proc isValidFileType {type} {
|
|||||||
# postconditions:
|
# postconditions:
|
||||||
# state(file,open) true state(file,new) false
|
# state(file,open) true state(file,new) false
|
||||||
# /data/currentfiletype == UNKNOWN
|
# /data/currentfiletype == UNKNOWN
|
||||||
proc newfile {type {namestyle data}} {
|
proc ::nexus::newfile {type {namestyle data}} {
|
||||||
variable filetype_spec
|
variable filetype_spec
|
||||||
variable state
|
variable state
|
||||||
|
|
||||||
@@ -250,7 +254,7 @@ proc newfile {type {namestyle data}} {
|
|||||||
# function
|
# function
|
||||||
#
|
#
|
||||||
# @see ::nexus::savetree
|
# @see ::nexus::savetree
|
||||||
proc save_data {point} {
|
proc ::nexus::save_data {point} {
|
||||||
debug_msg "save point $point in [dataFileName]"
|
debug_msg "save point $point in [dataFileName]"
|
||||||
::nexus::nxreopenfile
|
::nexus::nxreopenfile
|
||||||
foreach child [hlist /] {
|
foreach child [hlist /] {
|
||||||
@@ -269,7 +273,7 @@ proc newfile {type {namestyle data}} {
|
|||||||
#
|
#
|
||||||
# A new file will be created if the new file state has been set to true, or
|
# A new file will be created if the new file state has been set to true, or
|
||||||
# if the current data type doesn't match the current file type.
|
# if the current data type doesn't match the current file type.
|
||||||
proc save {{point 0}} {
|
proc ::nexus::save {{point 0}} {
|
||||||
variable state
|
variable state
|
||||||
|
|
||||||
if {[string is integer $point] == 0} {
|
if {[string is integer $point] == 0} {
|
||||||
@@ -304,7 +308,7 @@ proc newfile {type {namestyle data}} {
|
|||||||
# @brief Reopen the current file, close it with nxclosefile
|
# @brief Reopen the current file, close it with nxclosefile
|
||||||
#
|
#
|
||||||
# @see nxclosefile
|
# @see nxclosefile
|
||||||
proc nxreopenfile {} {
|
proc ::nexus::nxreopenfile {} {
|
||||||
global cfPath
|
global cfPath
|
||||||
variable state
|
variable state
|
||||||
variable nexusdic
|
variable nexusdic
|
||||||
@@ -318,7 +322,7 @@ proc newfile {type {namestyle data}} {
|
|||||||
# @brief Close the current file. You can reopen it with nxreopenfile
|
# @brief Close the current file. You can reopen it with nxreopenfile
|
||||||
#
|
#
|
||||||
# @see nxreopenfile
|
# @see nxreopenfile
|
||||||
proc nxclosefile {} {
|
proc ::nexus::nxclosefile {} {
|
||||||
variable state
|
variable state
|
||||||
if {$state(file,open) == "true"} {
|
if {$state(file,open) == "true"} {
|
||||||
nxscript close
|
nxscript close
|
||||||
@@ -427,7 +431,7 @@ proc newfile {type {namestyle data}} {
|
|||||||
#
|
#
|
||||||
# Sets the "signal" and "axes" attributes on the plottable data
|
# Sets the "signal" and "axes" attributes on the plottable data
|
||||||
# Also sets the "axis" attribute for each of the axes.
|
# Also sets the "axis" attribute for each of the axes.
|
||||||
proc linkdata {} {
|
proc ::nexus::linkdata {} {
|
||||||
array unset axes
|
array unset axes
|
||||||
set hpath /data
|
set hpath /data
|
||||||
::nexus::nxreopenfile
|
::nexus::nxreopenfile
|
||||||
@@ -469,7 +473,7 @@ proc newfile {type {namestyle data}} {
|
|||||||
#
|
#
|
||||||
# @param hpath path of subtree to save, must not be "/"
|
# @param hpath path of subtree to save, must not be "/"
|
||||||
# @param pt Current array index for mutable data (optional default=0)
|
# @param pt Current array index for mutable data (optional default=0)
|
||||||
proc savetree {hpath {pt 0}} {
|
proc ::nexus::savetree {hpath {pt 0}} {
|
||||||
foreach child [hlist /$hpath] {
|
foreach child [hlist /$hpath] {
|
||||||
array unset p_arr
|
array unset p_arr
|
||||||
array set p_arr [::utility::hlistplainprop /$hpath/$child]
|
array set p_arr [::utility::hlistplainprop /$hpath/$child]
|
||||||
@@ -504,7 +508,7 @@ proc newfile {type {namestyle data}} {
|
|||||||
# hdb path
|
# hdb path
|
||||||
#
|
#
|
||||||
# @see gen_nxdict
|
# @see gen_nxdict
|
||||||
proc _gen_nxdict {hpath dictPath name nxc} {
|
proc ::nexus::_gen_nxdict {hpath dictPath name nxc} {
|
||||||
variable nxdictionary
|
variable nxdictionary
|
||||||
if {[::utility::hgetplainprop /$hpath data] == "false"} {
|
if {[::utility::hgetplainprop /$hpath data] == "false"} {
|
||||||
debug_msg "$hpath doesn't have a data property"
|
debug_msg "$hpath doesn't have a data property"
|
||||||
@@ -544,7 +548,7 @@ proc newfile {type {namestyle data}} {
|
|||||||
#
|
#
|
||||||
# @param nexusdic Name of the nexus dictionary that will be created.
|
# @param nexusdic Name of the nexus dictionary that will be created.
|
||||||
# @return Full path to the nexus dictionary.
|
# @return Full path to the nexus dictionary.
|
||||||
proc gen_nxdict {nexusdic} {
|
proc ::nexus::gen_nxdict {nexusdic} {
|
||||||
global cfPath
|
global cfPath
|
||||||
variable nxdictionary
|
variable nxdictionary
|
||||||
set nxdict_path $cfPath(nexus)/$nexusdic
|
set nxdict_path $cfPath(nexus)/$nexusdic
|
||||||
@@ -569,7 +573,7 @@ proc newfile {type {namestyle data}} {
|
|||||||
|
|
||||||
##
|
##
|
||||||
# @brief Set SICS object attributes which are required for creating nexus data files.
|
# @brief Set SICS object attributes which are required for creating nexus data files.
|
||||||
proc set_sobj_attributes {} {
|
proc ::nexus::set_sobj_attributes {} {
|
||||||
# SICS commands
|
# SICS commands
|
||||||
sicslist setatt nxscript privilege internal
|
sicslist setatt nxscript privilege internal
|
||||||
# SICS data objects
|
# SICS data objects
|
||||||
@@ -604,7 +608,6 @@ proc newfile {type {namestyle data}} {
|
|||||||
sicslist setatt $sobj sdsinfo ::nexus::script::sdsinfo
|
sicslist setatt $sobj sdsinfo ::nexus::script::sdsinfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
namespace eval ::nexus::histmem {}
|
namespace eval ::nexus::histmem {}
|
||||||
namespace eval ::nexus::motor {}
|
namespace eval ::nexus::motor {}
|
||||||
@@ -613,12 +616,6 @@ namespace eval ::nexus::sicsvariable {}
|
|||||||
namespace eval ::nexus::singlecounter {}
|
namespace eval ::nexus::singlecounter {}
|
||||||
namespace eval ::nexus::script {}
|
namespace eval ::nexus::script {}
|
||||||
|
|
||||||
namespace import ::nexus::*
|
|
||||||
foreach expt $::nexus::exports {
|
|
||||||
publish $expt user
|
|
||||||
sicslist setatt $expt privilege internal
|
|
||||||
}
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# @brief Convert the given hdb type to Nexus data type
|
# @brief Convert the given hdb type to Nexus data type
|
||||||
#
|
#
|
||||||
@@ -659,6 +656,7 @@ proc ::nexus::histmem::save {hm nxalias data_type args} {
|
|||||||
}
|
}
|
||||||
set data_start 0
|
set data_start 0
|
||||||
set bank 0
|
set bank 0
|
||||||
|
$hm init
|
||||||
nxscript putslab $nxalias $indStartList $indLenList $hm $data_start $datalen $bank
|
nxscript putslab $nxalias $indStartList $indLenList $hm $data_start $datalen $bank
|
||||||
}] {
|
}] {
|
||||||
return -code error $::errorInfo
|
return -code error $::errorInfo
|
||||||
@@ -812,6 +810,12 @@ proc ::nexus::script::sdsinfo {script data_type args} {
|
|||||||
return " -type $dtype -rank 1 -dim {$size}"
|
return " -type $dtype -rank 1 -dim {$size}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace import ::nexus::*
|
||||||
|
foreach expt $::nexus::exports {
|
||||||
|
publish $expt user
|
||||||
|
sicslist setatt $expt privilege internal
|
||||||
|
}
|
||||||
|
|
||||||
# TODO Return filename from nxcreatefile and call nxreopen nxclose etc
|
# TODO Return filename from nxcreatefile and call nxreopen nxclose etc
|
||||||
# TODO Make an nxscript namespace for all this.
|
# TODO Make an nxscript namespace for all this.
|
||||||
|
|
||||||
@@ -823,7 +827,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.32 $}]
|
set tmpstr [string map {"$" ""} {$Revision: 1.33 $}]
|
||||||
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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user