Made sure that we run "hmm init" in a catch block to catch any attempt to modify an hmm parameter when it's not allowed.
The histmem command now returns clean error messages. Stack traces are displayed for errors which are triggered from the second call level with the histmem command. Made sure that catch blocks don't enclose a 'return' because this triggers the catch to report the contents of errorInfo. Removed obsolete setup procedure. Made sure that uploading of configuration files to the histogram server is only enabled for the 'hmm' object in the ::histogram_memory::upload_config procedure. Uploading config files is disabled for all other histmem objects at all times. r2282 | ffr | 2008-01-15 14:53:47 +1100 (Tue, 15 Jan 2008) | 7 lines
This commit is contained in:
committed by
Douglas Clowes
parent
b8c0f9ac5b
commit
1732ecdb99
@@ -1,5 +1,5 @@
|
||||
# $Revision: 1.27 $
|
||||
# $Date: 2007-11-09 06:09:36 $
|
||||
# $Revision: 1.28 $
|
||||
# $Date: 2008-01-15 03:53:47 $
|
||||
# Author: Ferdi Franceschini
|
||||
# Based on the examples in the hs_test.tcl sample configuration by Mark Lesha.
|
||||
# http://gumtree.ansto.gov.au:9080/nbicms/bragg-systems/histogram-server/hs_test.tcl/view
|
||||
@@ -87,58 +87,17 @@ namespace eval histogram_memory {
|
||||
|
||||
# Procedure to read a single config (or any) file, return content as a string.
|
||||
proc returnconfigfile {filename} {
|
||||
set ::errorInfo ""
|
||||
set fh [open $filename]
|
||||
set xml [read $fh]
|
||||
debug_msg $xml value
|
||||
close $fh
|
||||
return [subst $xml]
|
||||
}
|
||||
|
||||
# Initialize the histogram server.
|
||||
# This call to hmm init (with init 1 configured) causes the histogram server
|
||||
# to be loaded with the specified configuration files. Subsequent inits (with init 0 configured)
|
||||
# only cause specific histogram server FAT settings to be updated.
|
||||
# If the histogram server's default configfiles are adequate, the init 1 stage can be skipped.
|
||||
# Before configuring, make sure the server is stopped, since configuration
|
||||
# during DAQ is not allowed. This requires init of the hmm object to level 0.
|
||||
#
|
||||
# Making sure the histogram server is stopped, so we can load configuration.
|
||||
proc setup {} {
|
||||
set configuration "::histogram_memory::returnconfigfile config/hmm/anstohm_linked.xml"
|
||||
debug_msg $configuration
|
||||
|
||||
hmm configure statuscheck true
|
||||
hmm configure histmode transparent
|
||||
hmm stop
|
||||
hmm configure statuscheck false
|
||||
hmm configure hmDataPath ../HMData
|
||||
hmm configure hmconfigscript $configuration
|
||||
|
||||
hmm configure init 0
|
||||
hmm init
|
||||
hmm configure statuscheck true
|
||||
hmm stop
|
||||
hmm configure statuscheck false
|
||||
# Load the configuration to the histogram server.
|
||||
hmm configure init 1
|
||||
hmm init
|
||||
# Restore the init level to 0, subesquent inits will only upload specified FAT settings to histogram server.
|
||||
hmm configure init 0
|
||||
|
||||
##############################################
|
||||
# Configuring the histogram memories in SICS
|
||||
##############################################
|
||||
|
||||
# Now issue stop to the server.
|
||||
# This not only makes sure it's stopped, but lets us see certain configuration variables
|
||||
# which get placed in the dictionary as part of the status checking done during the stop.
|
||||
hmm configure statuscheck true
|
||||
hmm stop
|
||||
hmm configure statuscheck false
|
||||
}
|
||||
# Here, define a function to let us read back the value of dictionary items from the hmm
|
||||
# such as OAT dimensions.
|
||||
proc hmmdictitemval {histomem dictitem} {
|
||||
set ::errorInfo ""
|
||||
set resp [$histomem configure $dictitem]
|
||||
set retn [lindex [split $resp " "] 2]
|
||||
return $retn
|
||||
@@ -147,10 +106,15 @@ namespace eval histogram_memory {
|
||||
##
|
||||
# @brief Use histogram server to control acquisitions
|
||||
proc set_termination_conditions {count_method count_size count_stop} {
|
||||
hmm configure FAT_COUNT_METHOD $count_method
|
||||
hmm configure FAT_COUNT_SIZE $count_size
|
||||
hmm configure FAT_COUNT_STOP $count_stop
|
||||
hmm init
|
||||
set ::errorInfo ""
|
||||
if [ catch {
|
||||
hmm configure FAT_COUNT_METHOD $count_method
|
||||
hmm configure FAT_COUNT_SIZE $count_size
|
||||
hmm configure FAT_COUNT_STOP $count_stop
|
||||
hmm init
|
||||
} errmsg] {
|
||||
return -code error "$errmsg\n$::errorInfo"
|
||||
}
|
||||
}
|
||||
|
||||
# Simulated counter. No error rate. Required for technical reasons...
|
||||
@@ -183,11 +147,15 @@ namespace eval histogram_memory {
|
||||
#
|
||||
#Function to apply OAT offsets to the histogram server.
|
||||
proc set_oat_offset {oatoff_x oatoff_y oatoff_t} {
|
||||
hmm configure FAT_OFFSET_OAT_X $oatoff_x
|
||||
set ::errorInfo ""
|
||||
if [ catch {
|
||||
hmm configure FAT_OFFSET_OAT_X $oatoff_x
|
||||
hmm configure FAT_OFFSET_OAT_Y $oatoff_y
|
||||
hmm configure FAT_OFFSET_OAT_T $oatoff_t
|
||||
hmm init
|
||||
return
|
||||
} errmsg] {
|
||||
return -code error "$errmsg\n$::errorInfo"
|
||||
}
|
||||
}
|
||||
|
||||
##############################################
|
||||
@@ -197,6 +165,7 @@ namespace eval histogram_memory {
|
||||
# A simple procedure to read the histogram data through SICS
|
||||
# and dump the data to a numbered file.
|
||||
proc savehistodata {histomem filename} {
|
||||
set ::errorInfo ""
|
||||
set fh [open $filename "w"]
|
||||
# To get the whole memory, we don't need to specify the start or end arguments.
|
||||
# But we need to specify the bank number, this sets the type of data to be read.
|
||||
@@ -227,6 +196,7 @@ namespace eval histogram_memory {
|
||||
}
|
||||
|
||||
proc set_sobj_attributes {} {
|
||||
set ::errorInfo ""
|
||||
# SICS commands
|
||||
sicslist setatt blockctr privilege internal;
|
||||
|
||||
@@ -246,7 +216,14 @@ namespace eval histogram_memory {
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
# @brief Returns the histogram memory server clock scale.
|
||||
#
|
||||
# NOTE: The histmem server doesn't provide the clock scale to SICS\n
|
||||
# so we just hardwaire 1000 nanoseconds which is the current (10/01/08)\n
|
||||
# value on all the servers.
|
||||
proc clock_scale {args} {
|
||||
set ::errorInfo ""
|
||||
switch $args {
|
||||
"" { return 1 }
|
||||
"units" { return "microseconds"}
|
||||
@@ -255,13 +232,14 @@ namespace eval histogram_memory {
|
||||
}
|
||||
}
|
||||
}
|
||||
## \brief Calculate axis array from a given list of bin boundaries
|
||||
## @brief Calculate axis array from a given list of bin boundaries
|
||||
#
|
||||
# \param proc_name Fully qualified name of the calling procedure
|
||||
# \param scale_factor axis scale factor or @none
|
||||
# \param offset axis offset or @none
|
||||
# \param boundaries list of bin boundaries or @none
|
||||
# @param proc_name Fully qualified name of the calling procedure
|
||||
# @param scale_factor axis scale factor or @none
|
||||
# @param offset axis offset or @none
|
||||
# @param boundaries list of bin boundaries or @none
|
||||
proc calc_axis {proc_name scale_factor offset boundaries args} {
|
||||
set ::errorInfo ""
|
||||
variable state
|
||||
|
||||
set parlist [join $args]
|
||||
@@ -307,10 +285,11 @@ namespace eval histogram_memory {
|
||||
}
|
||||
}
|
||||
|
||||
sicsdatafactory new ::histogram_memory::y_bin_array
|
||||
##
|
||||
# @brief Provides y_bin boundary array for data axes
|
||||
sicsdatafactory new ::histogram_memory::y_bin_array
|
||||
proc y_bin {args} {
|
||||
set ::errorInfo ""
|
||||
set opt [lindex $args 0]
|
||||
set arglist [lrange $args 1 end]
|
||||
set proc_name [namespace origin [lindex [info level 0] 0]]
|
||||
@@ -341,10 +320,11 @@ namespace eval histogram_memory {
|
||||
sicslist setatt $script_name long_name y_bin
|
||||
unset script_name
|
||||
|
||||
sicsdatafactory new ::histogram_memory::x_bin_array
|
||||
##
|
||||
# @brief Provides x_bin boundary array for data axes
|
||||
sicsdatafactory new ::histogram_memory::x_bin_array
|
||||
proc x_bin {args} {
|
||||
set ::errorInfo ""
|
||||
set opt [lindex $args 0]
|
||||
set arglist [lrange $args 1 end]
|
||||
set proc_name [namespace origin [lindex [info level 0] 0]]
|
||||
@@ -378,6 +358,7 @@ namespace eval histogram_memory {
|
||||
# requires detector_active_width_mm det_radius_mm
|
||||
sicsdatafactory new ::histogram_memory::y_pixel_offset_array
|
||||
proc y_pixel_offset {args} {
|
||||
set ::errorInfo ""
|
||||
variable state
|
||||
set opt [lindex $args 0]
|
||||
set arglist [lrange $args 1 end]
|
||||
@@ -426,6 +407,7 @@ namespace eval histogram_memory {
|
||||
# requires detector_active_width_mm det_radius_mm
|
||||
sicsdatafactory new ::histogram_memory::x_pixel_offset_array
|
||||
proc x_pixel_offset {args} {
|
||||
set ::errorInfo ""
|
||||
variable state
|
||||
set opt [lindex $args 0]
|
||||
set arglist [lrange $args 1 end]
|
||||
@@ -473,6 +455,7 @@ namespace eval histogram_memory {
|
||||
|
||||
sicsdatafactory new ::histogram_memory::time_channel_array
|
||||
proc time_channel {args} {
|
||||
set ::errorInfo ""
|
||||
variable state
|
||||
set opt [lindex $args 0]
|
||||
set arglist [lrange $args 1 end]
|
||||
@@ -532,6 +515,7 @@ namespace eval histogram_memory {
|
||||
# only be called by the upload_config command to set the proposed tables as current
|
||||
# TODO Allow for top level content in tables and attributes in sub-elements
|
||||
proc XXX_TABLE {tag attributes element_list args} {
|
||||
set ::errorInfo ""
|
||||
global hmm_xml
|
||||
if {[llength $args] == 1} {
|
||||
set arguments [lindex $args 0]
|
||||
@@ -632,6 +616,7 @@ proc XXX_TABLE {tag attributes element_list args} {
|
||||
#
|
||||
# @see XXX_TABLE for subcommands.
|
||||
proc BAT_TABLE {args} {
|
||||
set ::errorInfo ""
|
||||
set attributes {}
|
||||
set elements ""
|
||||
set tag BAT
|
||||
@@ -656,6 +641,7 @@ BAT_TABLE -clear
|
||||
#
|
||||
# @see XXX_TABLE for subcommands.
|
||||
proc CAT_TABLE {args} {
|
||||
set ::errorInfo ""
|
||||
set attributes {}
|
||||
set elements ""
|
||||
set tag CAT
|
||||
@@ -680,6 +666,7 @@ CAT_TABLE -clear
|
||||
#
|
||||
# @see XXX_TABLE for subcommands.
|
||||
proc FAT_TABLE {args} {
|
||||
set ::errorInfo ""
|
||||
set attributes {FRAME_FREQUENCY SIZE_PERIOD COUNT_METHOD COUNT_SIZE READ_DATA_TYPE}
|
||||
set elements ""
|
||||
set tag FAT
|
||||
@@ -712,6 +699,7 @@ FAT_TABLE -clear
|
||||
# Sets X_BOUNDARIES, Y_BOUNDARIES and T_BOUNDARIES
|
||||
# @see XXX_TABLE for subcommands.
|
||||
proc OAT_TABLE {args} {
|
||||
set ::errorInfo ""
|
||||
global hmm_xml
|
||||
set attributes {NO_OAT_X_CHANNELS NO_OAT_Y_CHANNELS NO_OAT_T_CHANNELS}
|
||||
set tag OAT
|
||||
@@ -794,6 +782,7 @@ OAT_TABLE -clear
|
||||
#
|
||||
# @see XXX_TABLE for subcommands.
|
||||
proc SAT_TABLE {args} {
|
||||
set ::errorInfo ""
|
||||
set attributes {}
|
||||
set elements ""
|
||||
set tag SAT
|
||||
@@ -814,6 +803,7 @@ proc SAT_TABLE {args} {
|
||||
SAT_TABLE -clear
|
||||
|
||||
proc ::histogram_memory::clear_tables {} {
|
||||
set ::errorInfo ""
|
||||
BAT_TABLE -clear
|
||||
CAT_TABLE -clear
|
||||
FAT_TABLE -clear
|
||||
@@ -829,6 +819,7 @@ proc ::histogram_memory::clear_tables {} {
|
||||
# When anstohm_linked.xml is uploaded to the histogram server it calls this via
|
||||
# command substitution to set the name of the filler defaults file.
|
||||
proc ::histogram_memory::filler_defaults {args} {
|
||||
set ::errorInfo ""
|
||||
variable hmm_def_filename
|
||||
if {[llength $args] == 0} {
|
||||
return $hmm_def_filename
|
||||
@@ -844,6 +835,7 @@ proc ::histogram_memory::configure_server {instdef} {
|
||||
}
|
||||
# TODO Set current oat table after uploading proposed oat_table
|
||||
proc ::histogram_memory::upload_config {filler_defaults} {
|
||||
set ::errorInfo ""
|
||||
if [ catch {
|
||||
::histogram_memory::filler_defaults $filler_defaults
|
||||
hmm stop
|
||||
@@ -860,8 +852,9 @@ proc ::histogram_memory::upload_config {filler_defaults} {
|
||||
hmm stop
|
||||
hmm configure statuscheck false
|
||||
::histogram_memory::configure_dims
|
||||
}] {
|
||||
return -code error $::errorInfo
|
||||
} errmsg] {
|
||||
hmm configure init 0
|
||||
return -code error "$errmsg\n$::errorInfo"
|
||||
}
|
||||
clientput "histmem configuration uploaded"
|
||||
}
|
||||
@@ -871,14 +864,7 @@ proc ::histogram_memory::upload_config {filler_defaults} {
|
||||
# @brief Configure the dimensions for the controlling histogram object, and for
|
||||
# each auxiliary histogram object.
|
||||
proc ::histogram_memory::configure_dims {} {
|
||||
# set hmm_dim0 [hmmdictitemval hmm oat_ntc_eff]
|
||||
# if {[instname] == "wombat"} {
|
||||
# set hmm_dim1 [hmmdictitemval hmm stitch_nyc]
|
||||
# set hmm_dim2 [hmmdictitemval hmm stitch_nxc]
|
||||
# } else {
|
||||
# set hmm_dim1 [hmmdictitemval hmm oat_nyc_eff]
|
||||
# set hmm_dim2 [hmmdictitemval hmm oat_nxc_eff]
|
||||
# }
|
||||
set ::errorInfo ""
|
||||
if {[instname] == "wombat"} {
|
||||
array set dim_map {
|
||||
hmm {{hmm_dim0 oat_ntc_eff} {hmm_dim1 stitch_nyc} {hmm_dim2 stitch_nxc}}
|
||||
@@ -923,7 +909,7 @@ proc ::histogram_memory::configure_dims {} {
|
||||
}
|
||||
$hm_obj configure FAT_READ_DATA_TYPE $dim_map($hm_obj,fat_read_data_type)
|
||||
$hm_obj stop
|
||||
$hm_obj init 0
|
||||
$hm_obj configure init 0
|
||||
$hm_obj init
|
||||
|
||||
for {set i 0} {$i < $rank} {incr i} {
|
||||
@@ -937,6 +923,7 @@ proc ::histogram_memory::configure_dims {} {
|
||||
#
|
||||
# @see ::histogram_memory::set_frame_source
|
||||
proc ::histogram_memory::frame_source_always_internal {args} {
|
||||
set ::errorInfo ""
|
||||
variable fs_always_internal
|
||||
if {$args == ""} {
|
||||
return $fs_always_internal
|
||||
@@ -952,6 +939,7 @@ publish ::histogram_memory::frame_source_always_internal mugger
|
||||
##
|
||||
# @brief Return the last frame source which SICS attempted to set
|
||||
proc ::histogram_memory::get_frame_source {} {
|
||||
set ::errorInfo ""
|
||||
if [::histogram_memory::frame_source_always_internal] {
|
||||
clientput "WARNING: The frame source is set to always_internal" value
|
||||
clientput "Use ::histogram_memory::frame_source_always_internal <true/false> to change this." value
|
||||
@@ -966,6 +954,7 @@ proc ::histogram_memory::get_frame_source {} {
|
||||
# @param srce EXTERNAL or INTERNAL
|
||||
# @param always_internal true or false (optional) (default false)
|
||||
proc ::histogram_memory::set_frame_source {srce} {
|
||||
set ::errorInfo ""
|
||||
if [ catch {
|
||||
if [::histogram_memory::frame_source_always_internal] {
|
||||
clientput "WARNING: The frame source is set to always_internal" value
|
||||
@@ -977,7 +966,7 @@ proc ::histogram_memory::set_frame_source {srce} {
|
||||
::histogram_memory::stop
|
||||
hmm init
|
||||
} errmsg ] {
|
||||
return -code error $errmsg
|
||||
return -code error "$errmsg\n$::errorInfo"
|
||||
}
|
||||
}
|
||||
##
|
||||
@@ -995,45 +984,48 @@ proc ::histogram_memory::get_frame_freq {} {
|
||||
# If freq=0 then it sets the frequency to 50Hz with an internal frame source. This is useful
|
||||
# if you are setting the frequency from a chopper which is stopped.
|
||||
proc ::histogram_memory::set_frame_freq {freq {frame_source EXTERNAL}} {
|
||||
set ::errorInfo ""
|
||||
variable state
|
||||
# Frame source for each instrument if freq = 0, this can happen when automatically
|
||||
# setting frequencies from choppers.
|
||||
array set frame_source_on_zero_freq {
|
||||
echidna INTERNAL
|
||||
koala INTERNAL
|
||||
kowari EXTERNAL
|
||||
pelican INTERNAL
|
||||
platypus EXTERNAL
|
||||
quokka INTERNAL
|
||||
taipan INTERNAL
|
||||
wombat INTERNAL
|
||||
}
|
||||
|
||||
if {[string is double $freq] == 0 || $freq < 0} {
|
||||
return -code error "Frequency must be a non-negative floating point number"
|
||||
}
|
||||
#TODO Add tolerance parameters to choppercontroller
|
||||
if {abs($freq - 0) <= [expr {2.0/60.0}]} {
|
||||
set zf_frame_source $frame_source_on_zero_freq([instname])
|
||||
if {$zf_frame_source == "INTERNAL"} {
|
||||
clientput "WARNING: A histmem frame frequency of zero was requested, setting frequency to 50Hz instead" value
|
||||
} else {
|
||||
clientput "WARNING: A histmem frame frequency of zero was requested, setting frequency to 50Hz instead" value
|
||||
clientput "WARNING: You must provide an external oscillator" value
|
||||
}
|
||||
::histogram_memory::set_frame_source $zf_frame_source
|
||||
set newfreq 50
|
||||
} else {
|
||||
::histogram_memory::set_frame_source [string toupper $frame_source]
|
||||
::set newfreq $freq
|
||||
}
|
||||
|
||||
if [ catch {
|
||||
# Frame source for each instrument if freq = 0, this can happen when automatically
|
||||
# setting frequencies from choppers.
|
||||
array set frame_source_on_zero_freq {
|
||||
echidna INTERNAL
|
||||
koala INTERNAL
|
||||
kowari EXTERNAL
|
||||
pelican INTERNAL
|
||||
platypus EXTERNAL
|
||||
quokka INTERNAL
|
||||
taipan INTERNAL
|
||||
wombat INTERNAL
|
||||
}
|
||||
#TODO Add tolerance parameters to choppercontroller
|
||||
if {abs($freq - 0) <= [expr {2.0/60.0}]} {
|
||||
set zf_frame_source $frame_source_on_zero_freq([instname])
|
||||
if {$zf_frame_source == "INTERNAL"} {
|
||||
clientput "WARNING: A histmem frame frequency of zero was requested, setting frequency to 50Hz instead" value
|
||||
} else {
|
||||
clientput "WARNING: A histmem frame frequency of zero was requested, setting frequency to 50Hz instead" value
|
||||
clientput "WARNING: You must provide an external oscillator" value
|
||||
}
|
||||
::histogram_memory::set_frame_source $zf_frame_source
|
||||
set newfreq 50
|
||||
} else {
|
||||
::histogram_memory::set_frame_source [string toupper $frame_source]
|
||||
::set newfreq $freq
|
||||
}
|
||||
::histogram_memory::stop
|
||||
set clock_scale_ns 1000.0
|
||||
OAT_TABLE -set T_MAX [expr {1.0e9/($newfreq*$clock_scale_ns)}]
|
||||
hmm configure fat_frame_frequency $newfreq
|
||||
hmm init
|
||||
} errmsg ] {
|
||||
return -code error $errmsg
|
||||
} errmsg] {
|
||||
return -code error "$errmsg\n$::errorInfo"
|
||||
}
|
||||
}
|
||||
publish ::histogram_memory::set_frame_freq user
|
||||
@@ -1045,36 +1037,37 @@ proc ::histogram_memory::t_max {} {
|
||||
# @brief Sets histogram server to default configuration, initialises SICS histogram memory
|
||||
# dictionary values and clears SICS OAT BAT CAT FAT ... tables
|
||||
proc ::histogram_memory::_initialize {} {
|
||||
set configuration "::histogram_memory::returnconfigfile config/hmm/anstohm_linked.xml"
|
||||
::histogram_memory::y_bin -boundaries
|
||||
::histogram_memory::x_bin -boundaries
|
||||
::histogram_memory::y_pixel_offset -boundaries
|
||||
::histogram_memory::x_pixel_offset -boundaries
|
||||
::histogram_memory::time_channel -boundaries
|
||||
::histogram_memory::clear_tables
|
||||
#XXX ::histogram_memory::upload_config Filler_defaults
|
||||
|
||||
foreach hm_obj [sicslist type histmem] {
|
||||
$hm_obj configure hmaddress http://das1-[instname].nbi.ansto.gov.au:8080
|
||||
$hm_obj configure username spy
|
||||
$hm_obj configure password 007
|
||||
$hm_obj configure histmode transparent
|
||||
}
|
||||
hmm configure init 0
|
||||
hmm init
|
||||
hmm configure statuscheck true
|
||||
hmm stop
|
||||
hmm configure statuscheck false
|
||||
OAT_TABLE -init
|
||||
OAT_TABLE -set T_MIN 0
|
||||
::histogram_memory::frame_source_always_internal false
|
||||
::histogram_memory::set_frame_freq 50
|
||||
::histogram_memory::count_method unlimited
|
||||
::histogram_memory::count_size 0
|
||||
FAT_TABLE -init SIZE_PERIOD_MAX 125000000
|
||||
hmm configure hmDataPath ../HMData
|
||||
hmm configure hmconfigscript $configuration
|
||||
set ::errorInfo ""
|
||||
if [ catch {
|
||||
set configuration "::histogram_memory::returnconfigfile config/hmm/anstohm_linked.xml"
|
||||
::histogram_memory::y_bin -boundaries
|
||||
::histogram_memory::x_bin -boundaries
|
||||
::histogram_memory::y_pixel_offset -boundaries
|
||||
::histogram_memory::x_pixel_offset -boundaries
|
||||
::histogram_memory::time_channel -boundaries
|
||||
::histogram_memory::clear_tables
|
||||
#XXX ::histogram_memory::upload_config Filler_defaults
|
||||
|
||||
foreach hm_obj [sicslist type histmem] {
|
||||
$hm_obj configure hmaddress http://das1-[instname].nbi.ansto.gov.au:8080
|
||||
$hm_obj configure username spy
|
||||
$hm_obj configure password 007
|
||||
$hm_obj configure histmode transparent
|
||||
}
|
||||
hmm configure init 0
|
||||
hmm init
|
||||
hmm configure statuscheck true
|
||||
hmm stop
|
||||
hmm configure statuscheck false
|
||||
OAT_TABLE -init
|
||||
OAT_TABLE -set T_MIN 0
|
||||
::histogram_memory::frame_source_always_internal false
|
||||
::histogram_memory::set_frame_freq 50
|
||||
::histogram_memory::count_method unlimited
|
||||
::histogram_memory::count_size 0
|
||||
FAT_TABLE -init SIZE_PERIOD_MAX 125000000
|
||||
hmm configure hmDataPath ../HMData
|
||||
hmm configure hmconfigscript $configuration
|
||||
::histogram_memory::configure_dims
|
||||
} ] {
|
||||
clientput $::errorInfo
|
||||
@@ -1100,46 +1093,62 @@ proc ::histogram_memory::post_count {} {}
|
||||
#
|
||||
# @param block (optional) default="noblock"
|
||||
proc ::histogram_memory::start {{blocking "noblock"}} {
|
||||
set options [list block noblock]
|
||||
if {[lsearch $options $blocking] == -1} {
|
||||
return -code error "Valid options are $options"
|
||||
}
|
||||
set ::errorInfo ""
|
||||
if [ catch {
|
||||
set options [list block noblock]
|
||||
if {[lsearch $options $blocking] == -1} {
|
||||
return -code error "Valid options are $options"
|
||||
}
|
||||
::histogram_memory::pre_count
|
||||
hmm init 0
|
||||
hmm init
|
||||
if [catch {hmc start 1000000000 timer pause 1}] {
|
||||
return -code error $::errorInfo
|
||||
}
|
||||
clientput "histmem started" value
|
||||
if {$blocking == "block"} {
|
||||
blockctr count 0
|
||||
::histogram_memory::pause
|
||||
hmm init
|
||||
hmc start 1000000000 timer pause 1
|
||||
set reply [SplitReply [hmm configure daq]]
|
||||
if {$reply != "Started"} {
|
||||
return -code error "Histogram server failed to start"
|
||||
}
|
||||
clientput "histmem started" value
|
||||
if {$blocking == "block"} {
|
||||
blockctr count 0
|
||||
::histogram_memory::pause
|
||||
}
|
||||
} errmsg] {
|
||||
return -code error "$errmsg\n$::errorInfo"
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# @brief This sends the magic incantation which stops the histogram server.
|
||||
proc ::histogram_memory::stop {} {
|
||||
set ::errorInfo ""
|
||||
if [ catch {
|
||||
hmm pause
|
||||
hmm configure statuscheck true
|
||||
hmm stop
|
||||
hmm configure statuscheck false
|
||||
set reply [SplitReply [hmm configure daq]]
|
||||
if {$reply != "Stopped"} {
|
||||
return -code error "Histogram server failed to stop"
|
||||
}
|
||||
clientput "histmem stopped" value
|
||||
} errmsg ] {
|
||||
return -code error $errmsg
|
||||
return -code error "$errmsg\n$::errorInfo"
|
||||
}
|
||||
}
|
||||
##
|
||||
# @brief Allows resume if MULTIPLE_DATASETS=DISABLE, otherwise if MULTIPLE_DATASETS=ENABLE
|
||||
# (the default) this acts like a stop but allows a fast restart.
|
||||
proc ::histogram_memory::pause {} {
|
||||
set ::errorInfo ""
|
||||
if [ catch {
|
||||
hmm pause
|
||||
::histogram_memory::post_count
|
||||
set reply [SplitReply [hmm configure daq]]
|
||||
if {$reply != "Paused"} {
|
||||
return -code error "Histogram server failed to pause"
|
||||
}
|
||||
clientput "histmem paused" value
|
||||
} errmsg ] {
|
||||
return -code error $errmsg
|
||||
return -code error "$errmsg\n$::errorInfo"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1147,30 +1156,32 @@ proc ::histogram_memory::post_count {} {}
|
||||
# @brief Choose method for controlling acquisition duration.
|
||||
#
|
||||
# @param method Set histmem mode or return current mode if blank
|
||||
proc ::histogram_memory::count_method {{method ""}} {
|
||||
set modes [list time monitor unlimited period count frame]
|
||||
if {$method==""} {
|
||||
return [SplitReply [hmm_mode]]
|
||||
} else {
|
||||
if {[lsearch $modes $method] == -1} {
|
||||
return -code error "Count mode, $method, must be one of $modes"
|
||||
}
|
||||
if [ catch {
|
||||
hmm configure FAT_COUNT_METHOD $method
|
||||
hmm init 0
|
||||
hmm init
|
||||
hmm_mode $method
|
||||
}] {
|
||||
return -code error $::errorInfo
|
||||
proc ::histogram_memory::count_method {{method ""}} {
|
||||
set ::errorInfo ""
|
||||
set modes [list time monitor unlimited period count frame]
|
||||
if {$method==""} {
|
||||
return [SplitReply [hmm_mode]]
|
||||
} else {
|
||||
if {[lsearch $modes $method] == -1} {
|
||||
return -code error "Count mode, $method, must be one of $modes"
|
||||
}
|
||||
if [ catch {
|
||||
hmm configure FAT_COUNT_METHOD $method
|
||||
hmm init
|
||||
hmm_mode $method
|
||||
} errmsg] {
|
||||
return -code error "$errmsg\n$::errorInfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Count until the preset count size has been reached.
|
||||
#
|
||||
# @param preset: The interpretation of the preset depends on the count method.
|
||||
# @see count_method
|
||||
proc ::histogram_memory::count_size {{preset ""}} {
|
||||
set ::errorInfo ""
|
||||
variable state
|
||||
|
||||
if {$preset == ""} {
|
||||
@@ -1181,11 +1192,10 @@ proc ::histogram_memory::count_method {{method ""}} {
|
||||
}
|
||||
if [ catch {
|
||||
hmm configure FAT_COUNT_SIZE [expr {100.0 * $preset}]
|
||||
hmm init 0
|
||||
hmm init
|
||||
set state(preset) $preset
|
||||
}] {
|
||||
return -code error $::errorInfo
|
||||
} errmsg] {
|
||||
return -code error "$errmsg\n$::errorInfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1195,10 +1205,11 @@ proc ::histogram_memory::count_method {{method ""}} {
|
||||
#
|
||||
# @return Stopped, Paused, Started, or raises a Tcl error
|
||||
proc ::histogram_memory::status {} {
|
||||
set ::errorInfo ""
|
||||
if [ catch {
|
||||
set reply [SplitReply [hmm configure daq]]
|
||||
} ] {
|
||||
return -code error $::errorInfo
|
||||
} errmsg ] {
|
||||
return -code error "$errmsg\n$::errorInfo"
|
||||
} else {
|
||||
return $reply
|
||||
}
|
||||
@@ -1209,20 +1220,20 @@ proc ::histogram_memory::count_method {{method ""}} {
|
||||
#
|
||||
# @param condition
|
||||
proc ::histogram_memory::stop_condition {condition} {
|
||||
set ::errorInfo ""
|
||||
variable state
|
||||
array set count_stop {immediate IMMEDIATE period AT_END_OF_PERIOD}
|
||||
if [ catch {
|
||||
if {$condition == ""} {
|
||||
return $state(stop_cond)
|
||||
} else {
|
||||
hmm configure FAT_COUNT_STOP $count_stop($condition)
|
||||
hmm init 0
|
||||
hmm init
|
||||
set state(stop_cond) $condition
|
||||
if [ catch {
|
||||
hmm configure FAT_COUNT_STOP $count_stop($condition)
|
||||
hmm init
|
||||
set state(stop_cond) $condition
|
||||
} errmsg] {
|
||||
return -code error "$errmsg\n$::errorInfo"
|
||||
}
|
||||
}
|
||||
}] {
|
||||
return -code error $::errorInfo
|
||||
}
|
||||
}
|
||||
namespace eval ::histogram_memory {
|
||||
#TODO Create GumTree commands to setup, start and stop the histmem
|
||||
@@ -1248,6 +1259,7 @@ namespace eval ::histogram_memory {
|
||||
# @param cmd is one of start, stop, pause, mode, preset, fsrce, status, loadconf
|
||||
# @param args is an optional list of arguments for the given command
|
||||
proc _histmem {cmd args} {
|
||||
set ::errorInfo ""
|
||||
set reply ""
|
||||
if [ catch {
|
||||
switch $cmd {
|
||||
@@ -1300,7 +1312,7 @@ namespace eval ::histogram_memory {
|
||||
}
|
||||
}
|
||||
default {
|
||||
error "Available commands are, start stop pause mode preset freq fsrce status loadconf"
|
||||
return -code error "Available commands are, start stop pause mode preset freq fsrce status loadconf"
|
||||
}
|
||||
}
|
||||
} errmsg ] {
|
||||
|
||||
Reference in New Issue
Block a user