Autosave Ferdi Franceschini 2008-08-29 16:47 Commands autosave With no arguments enables autosaving with a default interval of 300 seconds (5 minutes) Parameters autosave n n <= 0 disables autosaving n > 0 enables autosaving with an interval of n seconds (if already running it just sets a new interval) autosave Reports if autosave is enabled or disabled. Return messages are: AUTOSAVE_STATE = DISABLED AUTOSAVE_STATE = ENABLED autosave example autosave check AUTOSAVE_STATE = DISABLED autosave 10 OK autosave check AUTOSAVE_STATE = ENABLED Description Data will be saved in the "designated" next data slot in a file. It's tricky because a sequence of datasets can be saved in a single data file (this is in fact the normal case across the instruments). I say "designated" because when you save a sequence of data acquistions in a file autosave cannot tell if the last entry in the file was "autosaved" or deliberately saved. The next slot is designated by making a call to save eg save 3 will cause autosave to save data at the next index (ie. 4). This will be made clearer later with examples. Data will be autosaved under the following conditions: autosave is enabled, of course :) newfile has been called to create a new file. The histogram memory is acquiring data. After autosave has been enabled it will start saving data at point zero in the data file, in other words it is equivalent to calling save 0 at regular intervals. If a call is made to save eg save 0 then autosaving will start saving data in the next slot, ie it saves data in index 1. Autosaving is suspended under the following conditions: The histogram memory has been paused It resumes after a histogram start The histogram memory has been stopped It resumes after a histogram start newfile clear has been called (this forces you to call newfile again before a new file can be saved). It resumes saving data in a new file at index 0 after a call like newfile HISTOGRAM_XY or newfile scratch When a runscan terminates. It resumes saving in a new file starting from index 0 when a new runscan is called. A typical autosave run autosave 1 OK newfile HISTOGRAM_XY OK histmem mode time histmem preset 5 histmem start block histmem started autosave 0 QKK0000035.nx.hdf updated autosave 0 QKK0000035.nx.hdf updated histmem paused save 0 QKK0000035.nx.hdf updated OK newfile HISTOGRAM_XY OK histmem start block histmem started autosave 0 QKK0000036.nx.hdf updated autosave 0 QKK0000036.nx.hdf updated histmem paused save 0 QKK0000036.nx.hdf updated OK You should notice that there are a couple of autosave commands before the histogram memory pauses to allow a deliberate call to save and that you must call newfile to autosave data in a new file otherwise you will overwrite data from the previous acquisition (NOTE: this is not a problem with autosave, this is what happens already if you're not careful). autosave example simulates saving a sequence of acquisitions in a single data file autosave 10 OK newfile HISTOGRAM_XY OK histmem start histmem started autosave 0 QKK0000025.nx.hdf updated autosave 0 QKK0000025.nx.hdf updated histmem pause histmem paused save 0 QKK0000025.nx.hdf updated OK histmem start histmem started autosave 1 QKK0000025.nx.hdf updated autosave 1 QKK0000025.nx.hdf updated histmem pause histmem paused save 1 QKK0000025.nx.hdf updated OK autosave 0 OK Note how autosave increments after the save 0. You should also be aware that autosaving is suspended when the histogram memory is paused or stopped, it resumes when the histogram is restarted. autosave example using <command>runscan</command> autosave 2 OK runscan dummy_motor 7.8 -1.5 2 time 10 Scan start: 7.800000 , Scan step: -9.300000, Number of points: 2 Datatype: HISTOGRAM_XYT histmem started autosave 0 QKK0000027.nx.hdf updated autosave 0 QKK0000027.nx.hdf updated autosave 0 QKK0000027.nx.hdf updated histmem paused NP dummy_mot Counts Time 0 7.800 45775 10.00 Monitor 1 2746 Monitor 2 3217 Monitor 3 9863 QKK0000027.nx.hdf updated histmem started autosave 1 QKK0000027.nx.hdf updated autosave 1 QKK0000027.nx.hdf updated autosave 1 QKK0000027.nx.hdf updated histmem paused NP dummy_mot Counts Time 1 -1.500 45981 10.00 Monitor 1 229 Monitor 2 909 Monitor 3 5385 QKK0000027.nx.hdf updated histmem stopped OK autosave check AUTOSAVE_STATE = ENABLED autosave 0 OK autosave check AUTOSAVE_STATE = DISABLED autosaving is suspended at the end of runscan because the histogram memory has stopped running, but autosaving is still enabled as can be seen from the call to autosave check. However there is no risk that data will be overwritten if the histogram is restarted because the runscan command makes a call to newfile clear when it terminates. autosave example using two <command>runscan</command> commands autosave 1 OK runscan dummy_motor 7.8 -1.5 2 time 5 Scan start: 7.800000 , Scan step: -9.300000, Number of points: 2 Datatype: HISTOGRAM_XYT histmem started autosave 0 QKK0000031.nx.hdf updated autosave 0 QKK0000031.nx.hdf updated histmem paused NP dummy_mot Counts Time 0 7.800 22846 5.00 Monitor 1 276 Monitor 2 1152 Monitor 3 2643 QKK0000031.nx.hdf updated histmem started autosave 1 QKK0000031.nx.hdf updated autosave 1 QKK0000031.nx.hdf updated histmem paused NP dummy_mot Counts Time 1 -1.500 22898 5.00 Monitor 1 91 Monitor 2 79 Monitor 3 5071 QKK0000031.nx.hdf updated histmem stopped OK ...autosave example continued runscan dummy_motor 7.8 -1.5 2 time 5 Scan start: 7.800000 , Scan step: -9.300000, Number of points: 2 Datatype: HISTOGRAM_XYT histmem started autosave 0 QKK0000032.nx.hdf updated autosave 0 QKK0000032.nx.hdf updated histmem paused NP dummy_mot Counts Time 0 7.800 23043 5.00 Monitor 1 8630 Monitor 2 6962 Monitor 3 4012 QKK0000032.nx.hdf updated histmem started autosave 1 QKK0000032.nx.hdf updated autosave 1 QKK0000032.nx.hdf updated histmem paused NP dummy_mot Counts Time 1 -1.500 22887 5.00 Monitor 1 2449 Monitor 2 7798 Monitor 3 9172 QKK0000032.nx.hdf updated histmem stopped OK You should notice that after the first runscan data is autosaved to file 31 and after the second runscan it is autosaved to file 32. example shows what happens if you enable <command>autosave</command> after a couple of datasets have been acquired and saved newfile HISTOGRAM_XY OK histmem start histmem started save 0 QKK0000038.nx.hdf updated OK save 1 QKK0000038.nx.hdf updated OK autosave 5 <---- AUTOSAVE enabled here. OK autosave 2 QKK0000038.nx.hdf updated autosave 2 QKK0000038.nx.hdf updated save 2 QKK0000038.nx.hdf updated OK autosave 3 QKK0000038.nx.hdf updated histmem stop histmem stopped save 3 QKK0000038.nx.hdf updated OK You shold notice that autosaving properly commences saving data at index 2 after it has been enabled instead of autosaving over index 0 or 1. It's a bit contrived but it attempts to show the sort of thing that should happen if you are saving multiple periods from a histogram memory. Known Issues Under exceptional conditions your data file may end up with one more entry than you intended. In other words if you fail to disable autosaving after a deliberate save and newfile has not been called before the histogram memory starts acquiring data again, then another entry will be saved beyond your last save. No data will be lost but you may get more than you expected.