Commit 09cbdde6 authored by Antoine Laudrain's avatar Antoine Laudrain
Browse files

MSO: get TTAGs from trigger channel instead of first readout channel.

Now read out the actual trigger channel after the setting process, and
use this one as default channel for waveform information (WAV:COUNt?
polling in the event loop) and for the TTAGs information.
Since the TTAG are trigger time difference, I'm not sure what it looks
like on non-trigger channels (the trigger channel is not always the
first in the readout list).

The default channel setting is now done at the start of each run (ie
after the data fetch and writing from any channel occured at the end of
the previous run).

Improves the readout settings that was changed in #5911603e
parent 9ec93e47
Pipeline #131999 passed with stages
in 3 minutes and 37 seconds
......@@ -118,19 +118,18 @@ def write_output(instr, channel, outpath):
logger.info("Written data file : %s", outpath_data)
def write_ttags(instr, channel, outpath):
"""Retrieve the TTAGs for a given channel and dump to file.
def write_ttags(instr, trigger_channel, outpath):
"""Retrieve the TTAGs from the trigger channel and dump to file.
@param[in] instr: instrument
@param[in] channel: int,
Channel number to get the TTAGs from (should be the same for
all channels).
@param[in] trigger_channel: string,
Name of the trigger channel, used to get the TTAGs info.
@param[in] outpath: string, see `main`
"""
logger.info("Writing ttags... (using CHAN%d)", channel)
logger.info("Writing ttags... (using %s)", trigger_channel)
setup_readout(instr)
log_write(instr, ':WAV:FORMat ASCii') # Overwrite format to be ascii.
log_write(instr, f':WAV:SOURce CHAN{channel}')
log_write(instr, f':WAV:SOURce {trigger_channel}')
outpath += ".ttags.txt"
log_write(instr, ':WAV:SEGMented:XLISt? TTAG')
......@@ -263,11 +262,13 @@ def main(outpath, nevents, nruns, read_channels, wait_seconds=60,
setup_channel(instr, channel=4, offset=-100e-3, scale=50e-3, skew=0)
setup_trigger(instr, channel=1, level=-230e-3, slope='-')
# Use trigger channel for taking waveform counts and ttag info.
trigger_channel = process_query_answer(instr.query(':TRIGger:EDGE:SOURce?'))
logger.info("Default info will be taken from trigger channel: %s",
trigger_channel)
setup_datataking(instr, nevents)
setup_readout(instr)
# Setup one default waveform source (used to get how many waveform are
# recorded).
log_write(instr, f':WAVeform:SOURce CHAN{read_channels[0]}')
info_channels(instr)
info_timebase(instr)
......@@ -303,6 +304,10 @@ def main(outpath, nevents, nruns, read_channels, wait_seconds=60,
for irun in range(nruns):
outpath_time = outpath + "." + strftime("%y%m%d_%H%M%S")
# Setup one default waveform source (used to get how many waveform are
# recorded).
log_write(instr, f':WAVeform:SOURce {trigger_channel}')
if log_each_run:
# Add log file for this run.
file_handler = logging.FileHandler(outpath_time + ".log")
......@@ -327,7 +332,7 @@ def main(outpath, nevents, nruns, read_channels, wait_seconds=60,
log_write(instr, ':STOP')
if dump_ttags:
write_ttags(instr, read_channels[0], outpath_time)
write_ttags(instr, trigger_channel, outpath_time)
for channel in read_channels:
write_output(instr, channel, outpath_time)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment