Files
sics/site_ansto/instrument/hipd/config/hmm/hmm_rapid.tcl
2014-05-16 17:23:58 +10:00

154 lines
3.8 KiB
Tcl

# Test script for multi period acquisition and saving.
# latest mods 21 Oct 09 based on info from Ferdi - ajs
set n_periods 1
proc open_hist_file {} {
newfile HISTOGRAM_XY
}
proc histset_XY {} {
set histstr "proc open_hist_file {} {newfile HISTOGRAM_XY}"
eval $histstr
}
proc histset_XYperiod {} {
set histstr "proc open_hist_file {} {newfile HISTOPERIOD_XY}"
eval $histstr
}
proc histset_XYT {} {
set histstr "proc open_hist_file {} {newfile HISTOGRAM_XYT}"
eval $histstr
}
proc histset_XYTperiod {} {
set histstr "proc open_hist_file {} {newfile HISTOPERIOD_XYT}"
}
proc histmem_period_single { } {
# Because bugs may not yet have been corrected in hmm_configuration_common_1.tcl,
# apply the default settings before attempting del/clear.
global n_periods
set n_periods 1
FAT_TABLE -set NOS_PERIODS 1
# FAT_TABLE -del NOS_PERIODS
# BAT_TABLE -set PERIOD_INDICES { 0 } NO_BAT_ENTRIES 1 NO_BAT_PERIODS 1 NO_REPEAT_ENTRY 0 NO_REPEAT_TABLE 0 NO_EXECUTE_TABLE 0
BAT_TABLE -set PERIOD_INDICES { 0 } NO_BAT_ENTRIES 1 NO_BAT_PERIODS 1 NO_REPEAT_ENTRY 1 NO_REPEAT_TABLE 1 NO_EXECUTE_TABLE 1
histmem loadconf
# BAT_TABLE -clear
histset_XY
}
Publish histmem_period_single User
# orig version of this pre Oct 09
#
#proc histmem_period_sequence { Np Nf } {
# Note - sequence needs to be at least 2 periods.
# global n_periods
# set n_periods $Np
# set fatstr "FAT_TABLE -set NOS_PERIODS $Np"
# set fatstr2 "FAT_TABLE -set PERIOD_INDICES { 0 1 }"
# set batstr "BAT_TABLE -set NO_BAT_ENTRIES $Np NO_BAT_PERIODS $Np NO_REPEAT_ENTRY $Nf NO_REPEAT_TABLE 1 NO_EXECUTE_TABLE 1"
# eval $fatstr
# eval $fatstr2
# eval $batstr
# histmem loadconf
#
#}
proc histmem_period_sequence {Np} {
global n_periods
set n_periods $Np
FAT_TABLE -set NOS_PERIODS $Np
BAT_TABLE -set PERIOD_INDICES { 0 } NO_BAT_ENTRIES 1 NO_BAT_PERIODS 1 NO_REPEAT_ENTRY 1 NO_REPEAT_TABLE 1 NO_EXECUTE_TABLE $Np
histmem loadconf
histset_XYperiod
}
proc histmem_period_sequence_off {} {
global n_periods
set n_periods $Np
FAT_TABLE -set NOS_PERIODS 1
BAT_TABLE -set PERIOD_INDICES { 0 } NO_BAT_ENTRIES 1 NO_BAT_PERIODS 1 NO_REPEAT_ENTRY 0 NO_REPEAT_TABLE 0 NO_EXECUTE_TABLE 0
histmem loadconf
histset_XYperiod
}
Publish histmem_period_sequence User
proc histmem_save_period_sequence { } {
global n_periods
open_hist_file
for { set i 0 } { $i < $n_periods } { incr i } {
# hmm configure read_data_period_number $i
save $i
}
}
Publish histmem_save_period_sequence User
proc histmem_period_strobo {Freq Bins} {
global nos_bins
set nos_bins $Bins
set bintime [expr int(1000000./($Freq*$Bins))]
histmem fsrce EXTERNAL
set oatstr "OAT_TABLE -set T {0 $bintime} NTC $Bins"
# OAT_TABLE -set T { 0 $bintime } NTC $Bins
eval $oatstr
histmem loadconf
histset_XYT
}
Publish histmem_period_strobo User
proc histmem_strobo_off {} {
histmem fsrce INTERNAL
OAT_TABLE -set T { 0 200000 } NTC 1
histmem loadconf
histset_XY
}
Publish histmem_strobo_off User
proc histmem_acquire_period_sequence { Np Nf } {
newfile HISTOGRAM_XYT
histmem stop
histmem_period_sequence $Np $Nf
histmem loadconf
histmem start
set dlytime [ expr int( 1000 * $Nf / 50. ) ]
# clientput "Waiting for" $dlytime "ms..."
after $dlytime
# clientput "tc1 reading is: " [tc1 get]
global n_periods
for { set i 0 } { $i < $n_periods } { incr i } {
# after $dlytime
# set current_period -1
# while { $current_period < $i } {
# update
# after 500
# # hmm count
# # hmm init 2
# clientput [hmm configure current_period]
# set current_period [lindex [split [hmm configure current_period] " "] 2]
# clientput "i = " $i " and the current period is " $current_period
# }
hmm configure read_data_period_number $i
save [expr $i]
}
clientput "Acquisition completed."
}
Publish histmem_acquire_period_sequence User