SICS-458: Add dsc command to run a DSC acquisition on Quokka.
Also added dsc.py utility which finds the start of a DSC profile in hdf files.
This commit is contained in:
96
site_ansto/instrument/sans/config/commands/growfile.tcl
Normal file
96
site_ansto/instrument/sans/config/commands/growfile.tcl
Normal file
@@ -0,0 +1,96 @@
|
||||
# \file Implements 'dsc actime interval' command.
|
||||
set GROWFILE_STATE "DISABLED"
|
||||
set growfileSaveIndex 0
|
||||
|
||||
|
||||
proc doGrowFile {} {
|
||||
global GROWFILE_STATE
|
||||
global growfileSaveIndex
|
||||
|
||||
# Reset the GROWFILE_STATE variable in case some naughty user sets it directly
|
||||
set GROWFILE_STATE "ENABLED"
|
||||
set HMSTATE [SplitReply [hmm configure daq]]
|
||||
set FSTATE [SplitReply [file_status]]
|
||||
# broadcast CALLED: [info level 0], HMSTATE = $HMSTATE, FSTATE = $FSTATE
|
||||
if { $FSTATE != "UNKNOWN" && $FSTATE != "OPEN" && $HMSTATE == "Started"} {
|
||||
# broadcast growfile $growfileSaveIndex
|
||||
save $growfileSaveIndex "growfile"
|
||||
incr growfileSaveIndex
|
||||
} else {
|
||||
if {$growfileSaveIndex == 0} {
|
||||
broadcast ERROR: GROWFILE HMSTATE = $HMSTATE, FSTATE = $FSTATE. The histmem must be running and you must create a newfile before calling "growfile"
|
||||
} else {
|
||||
broadcast STOP GROWFILE Acquisition finished. HMSTATE = $HMSTATE, FSTATE = $FSTATE.
|
||||
save $growfileSaveIndex "growfile"
|
||||
newfile clear
|
||||
broadcast Saved [hval /experiment/file_name]
|
||||
}
|
||||
set growfileSaveIndex 0
|
||||
sicspoll del doGrowFile
|
||||
set GROWFILE_STATE "DISABLED"
|
||||
hsetprop /instrument/detector/hmm mutable true
|
||||
}
|
||||
}
|
||||
publish doGrowFile user
|
||||
|
||||
|
||||
proc growfile { {interval 300} } {
|
||||
global GROWFILE_STATE
|
||||
global growfileSaveIndex
|
||||
|
||||
set GROWFILE_STATE "DISABLED"
|
||||
set growfileSaveIndex 0
|
||||
|
||||
set as_error 0
|
||||
|
||||
set myrights [set_rights manager]
|
||||
if {$myrights == -1} {
|
||||
return -code error "ERROR: You are not authorized for this operation"
|
||||
}
|
||||
set interval [string tolower $interval]
|
||||
if {$interval == "check" || $interval == "status"} {
|
||||
if { $GROWFILE_STATE == "ENABLED" } {
|
||||
return "GROWFILE $GROWFILE_STATE [sicspoll intervall doGrowFile]"
|
||||
} else {
|
||||
return "GROWFILE $GROWFILE_STATE"
|
||||
}
|
||||
} elseif {[string is integer $interval]} {
|
||||
if {$interval <= 0} {
|
||||
if { $GROWFILE_STATE == "ENABLED" } {
|
||||
sicspoll del doGrowFile
|
||||
set GROWFILE_STATE "DISABLED"
|
||||
}
|
||||
} else {
|
||||
if {$GROWFILE_STATE == "DISABLED"} {
|
||||
sicspoll add doGrowFile script $interval doGrowFile
|
||||
# sicspoll listen # WARNING:When the listening client exits it leaves SICSPOLL task with a corrupt connection object.
|
||||
set GROWFILE_STATE "ENABLED"
|
||||
} else {
|
||||
sicspoll intervall doGrowFile $interval
|
||||
}
|
||||
}
|
||||
} else {
|
||||
set as_error 1
|
||||
}
|
||||
|
||||
set_rights $myrights
|
||||
|
||||
if {$as_error} {
|
||||
return -code error "ERROR: Invalid argument in '[info level 0]', should be an integer or 'check'"
|
||||
}
|
||||
}
|
||||
publish growfile user
|
||||
|
||||
# \brief Run histogram for the specified time and save XY binned data at the given interval.
|
||||
# \param actime Acquisition time in seconds.
|
||||
# \param saveint Save interval in seconds.
|
||||
proc dsc {actime saveint} {
|
||||
hsetprop /instrument/detector/hmm mutable false
|
||||
newfile HISTOGRAM_XY
|
||||
histmem mode time
|
||||
histmem preset $actime
|
||||
histmem start
|
||||
growfile $saveint
|
||||
}
|
||||
|
||||
publish dsc user
|
||||
Reference in New Issue
Block a user