From 59b953be0ee7471ebad310c42e39aa826ff0d18e Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Thu, 1 Nov 2007 13:01:39 +1100 Subject: [PATCH] Move creation of hmm objects to common hmm configuration file. pre_count does nothing now. Added function to set hmm freq to match chopper freq and extended _histmem with a tochfreq subcommand. r2216 | ffr | 2007-11-01 13:01:39 +1100 (Thu, 01 Nov 2007) | 4 lines --- .../config/hmm/hmm_configuration.tcl | 95 ++++++++----------- 1 file changed, 38 insertions(+), 57 deletions(-) diff --git a/site_ansto/instrument/reflectometer/config/hmm/hmm_configuration.tcl b/site_ansto/instrument/reflectometer/config/hmm/hmm_configuration.tcl index 9c295038..3ed52110 100644 --- a/site_ansto/instrument/reflectometer/config/hmm/hmm_configuration.tcl +++ b/site_ansto/instrument/reflectometer/config/hmm/hmm_configuration.tcl @@ -1,62 +1,6 @@ -set sim_mode [SplitReply [hmm_simulation]] -if {$sim_mode == "true"} { - MakeHM hmm SIM - MakeHM hmm_xy SIM - MakeHM hmm_xt SIM - MakeHM hmm_yt SIM - MakeHM hmm_x SIM - MakeHM hmm_y SIM - MakeHM hmm_t SIM - hmm configure daq Stopped - hmm configure statuscheck false - namespace eval histogram_memory { - proc hmc {_start _preset _mode _pause} { - bm mode $_mode; - bm preset $_preset; - hmm countblock; - } - } -} else { - MakeHM hmm anstohttp; - MakeHM hmm_xy anstohttp; - MakeHM hmm_xt anstohttp; - MakeHM hmm_yt anstohttp; - MakeHM hmm_x anstohttp; - MakeHM hmm_y anstohttp; - MakeHM hmm_t anstohttp; - - MakeHMControl_ANSTO hmc bm hmm; -} - -hmm configure rank 3 -hmm_xy configure rank 2 -hmm_xt configure rank 2 -hmm_yt configure rank 2 -hmm_x configure rank 1 -hmm_y configure rank 1 -hmm_t configure rank 1 - source $cfPath(hmm)/hmm_configuration_common_1.tcl -if {$sim_mode == "true"} { - proc ::histogram_memory::initialize {} { - hmm configure hmaddress http://das1-[SplitReply [instrument]]:8080; - hmm configure username spy; - hmm configure password 007; - hmm configure hmDataPath ../HMData; - } -} -proc ::histogram_memory::pre_count {} { - set freq [::chopper::get_frequency] - #TODO Add tolerance parameters to choppercontroller - if {abs($freq - 0) <= [expr 2.0/60.0]} { - hmm configure fat_frame_source INTERNAL - ::histogram_memory::set_frame_freq 50 - } else { - hmm configure fat_frame_source EXTERNAL - ::histogram_memory::set_frame_freq $freq - } -} +proc ::histogram_memory::pre_count {} {} proc ::histogram_memory::post_count {} {} proc ::histogram_memory::initialize {} { ::histogram_memory::_initialize @@ -92,3 +36,40 @@ proc ::histogram_memory::initialize {} { ::nexus::data alias ::histogram_memory::vertical_axis ::histogram_memory::y_bin ::nexus::data alias ::histogram_memory::horizontal_axis ::histogram_memory::x_bin } + +## +# @brief Set histogram memory frame frequency to match the current chopper frequency +proc ::histogram_memory::tochfreq {} { + if [ catch { + ::chopper::ready? + set chfreq [::chopper::get_frequency] + ::histogram_memory::set_frame_freq $chfreq EXTERNAL + } errmsg ] { + return -code error $errmsg + } +} + +## +# @brief Extends the core _histmem command with platypus specific subcommands +# +# @param tochfreq updates chopper status and then sets histmem frame frequency to match +# the chopper frequency. +# +# NOTE: If the chopper is stopped (ie freq=0) then the histogram frequency will be set to +# 50Hz with an internal frame_source.\n +# @see ::histogram_memory::set_frame_freq +proc histmem {cmd args} { + if [ catch { + switch $cmd { + "tochfreq" { + ::histogram_memory::tochfreq + } + default { + eval "_histmem $cmd $args" + } + } + } errmsg ] { + return -code error $errmsg + } +} +publish histmem user