Autosave
r3213 | ffr | 2011-06-20 09:41:41 +1000 (Mon, 20 Jun 2011) | 1 line
This commit is contained in:
committed by
Douglas Clowes
parent
ea79b86986
commit
9c93861ae7
@@ -10,6 +10,7 @@ sicsdatafactory new nxscript_data
|
||||
::utility::mkVar eend Text user end_time true entry false true
|
||||
::utility::mkVar timestamp int user time_stamp true entry false true
|
||||
::utility::mkVar data_run_number int user run_number true instrument false true
|
||||
::utility::mkVar autosaveIndex int user autosaveIndex true instrument false true
|
||||
::utility::mkVar save_count int user save_count true experiment true true
|
||||
::utility::mkVar currpoint int user currpoint true experiment true true
|
||||
::utility::mkVar nexus_datatype text user DataType true data false true
|
||||
@@ -346,6 +347,7 @@ proc ::nexus::newfile_collection {args} {
|
||||
}
|
||||
save_count 0
|
||||
currpoint 0
|
||||
autosaveIndex 0
|
||||
file_status $file_states(U)
|
||||
if {$param(-filetype) == "clear"} {
|
||||
::hdb::set_save / false
|
||||
@@ -366,6 +368,7 @@ proc ::nexus::newfile_collection {args} {
|
||||
}
|
||||
::nexus::process_filetype_policy $param(-filetype)
|
||||
nexus_datatype $param(-filetype)
|
||||
file_status "NEWFILE"
|
||||
}
|
||||
} message ] {
|
||||
return -code error "([info level 0]) $message"
|
||||
@@ -423,12 +426,15 @@ proc ::nexus::newfile_collection {args} {
|
||||
#
|
||||
# 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.
|
||||
proc ::nexus::save {{point 0}} {
|
||||
proc ::nexus::save {{point 0} {callType "normalsave"}} {
|
||||
if [ catch {
|
||||
::nexus::save_collection -index $point
|
||||
} message ] {
|
||||
return -code error "([info level 0]) $message"
|
||||
}
|
||||
}
|
||||
if {$callType == "normalsave"} {
|
||||
autosaveIndex [expr [SplitReply [data_run_number]] + 1]
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
|
||||
@@ -247,6 +247,8 @@ proc server_init {} {
|
||||
if [file exists $::sicsroot/log/status.tcl ] {
|
||||
restore
|
||||
}
|
||||
file_status "UNKNOWN"
|
||||
|
||||
MakeStateMon hmscan
|
||||
sicslist setatt sics_suid privilege readonly
|
||||
sicslist setatt sics_suid klass data
|
||||
@@ -257,6 +259,9 @@ proc server_init {} {
|
||||
sicslist setatt sics_suid nxsave true
|
||||
sicslist setatt sics_suid long_name sics_suid
|
||||
|
||||
VarMake AUTOSAVE_STATE Text user
|
||||
AUTOSAVE_STATE "DISABLED"
|
||||
|
||||
if [file exists ../extraconfig.tcl] {
|
||||
fileeval ../extraconfig.tcl
|
||||
}
|
||||
@@ -266,3 +271,43 @@ proc server_init {} {
|
||||
} message ]
|
||||
handle_exception $catch_status $message
|
||||
}
|
||||
|
||||
proc doAutosave {} {
|
||||
# Reset the AUTOSAVE_STATE variable in case some naughty user sets it directly
|
||||
AUTOSAVE_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"} {
|
||||
set saveIndex [SplitReply [autosaveIndex] ]
|
||||
broadcast autosave $saveIndex
|
||||
save $saveIndex "autosave"
|
||||
}
|
||||
}
|
||||
publish doAutosave user
|
||||
proc autosave { {interval 300} } {
|
||||
set stateVal [SplitReply [AUTOSAVE_STATE]]
|
||||
if {$interval == "check"} {
|
||||
return [AUTOSAVE_STATE]
|
||||
} elseif {[string is integer $interval]} {
|
||||
if {$interval <= 0} {
|
||||
if { $stateVal == "ENABLED" } {
|
||||
sicspoll del doAutosave
|
||||
AUTOSAVE_STATE "DISABLED"
|
||||
}
|
||||
} else {
|
||||
if {$stateVal == "DISABLED"} {
|
||||
sicspoll add doAutosave script $interval doAutosave
|
||||
sicspoll listen
|
||||
AUTOSAVE_STATE "ENABLED"
|
||||
} else {
|
||||
sicspoll intervall doAutosave $interval
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return -code error "ERROR: Invalid argument in '[info level 0]', should be an integer or 'check'"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
publish autosave user
|
||||
|
||||
Reference in New Issue
Block a user