|
@@ -556,26 +556,26 @@ def bk_get_board_config(board_id):
|
|
|
"""
|
|
|
return board.get_board_config(board_id)
|
|
|
|
|
|
-def bk_change_num_of_orbits(board_id, value, silent=False):
|
|
|
+def bk_change_num_of_turns(board_id, value, silent=False):
|
|
|
"""
|
|
|
- Send new number of orbits to board and update in config
|
|
|
+ Send new number of turns to board and update in config
|
|
|
:param board_id: id of the board do manipulate
|
|
|
:param value: the value to send
|
|
|
:param silent: (bool) if True do not inform observers on update
|
|
|
:return: -
|
|
|
"""
|
|
|
- bk_update_config(board_id, "orbits_observe", value, silent=silent)
|
|
|
+ bk_update_config(board_id, "turns_observe", value, silent=silent)
|
|
|
|
|
|
|
|
|
-def bk_change_num_of_skipped_orbits(board_id, value, silent=False):
|
|
|
+def bk_change_num_of_skipped_turns(board_id, value, silent=False):
|
|
|
"""
|
|
|
- Send new number of orbits to skip to board and update in config
|
|
|
+ Send new number of turns to skip to board and update in config
|
|
|
:param board_id: id of the board do manipulate
|
|
|
:param value: the value to send
|
|
|
:param silent: (bool) if True do not inform observers on update
|
|
|
:return: -
|
|
|
"""
|
|
|
- bk_update_config(board_id, "orbits_skip", value, silent=silent)
|
|
|
+ bk_update_config(board_id, "turns_skip", value, silent=silent)
|
|
|
|
|
|
|
|
|
def bk_change_count(board_id, value, silent=False):
|
|
@@ -597,7 +597,7 @@ def bk_change_wait(board_id, value, silent=False):
|
|
|
:param silent: (bool) if True do not inform observers on update
|
|
|
:return: -
|
|
|
"""
|
|
|
- bk_update_config(board_id, "orbits_wait_time", value, silent=silent)
|
|
|
+ bk_update_config(board_id, "turns_wait_time", value, silent=silent)
|
|
|
|
|
|
|
|
|
def bk_change_build_spectrograms(board_id, value, silent=False):
|
|
@@ -644,7 +644,7 @@ def _bif_iterate_spectrograms(board_id, path):
|
|
|
f = open(filename, 'ab')
|
|
|
if write_header:
|
|
|
f.write("#hsp\n") # heb spectrogram magic number
|
|
|
- f.write("#"+str(board.get_board_config(board_id).get("orbits_skip")))
|
|
|
+ f.write("#"+str(board.get_board_config(board_id).get("turns_skip")))
|
|
|
f.write("\n")
|
|
|
line = transform[i, :]
|
|
|
f.write('{:0.3f} '.format(time.time()))
|
|
@@ -662,9 +662,9 @@ def _bif_read_data_and_save(board_id):
|
|
|
:return:
|
|
|
"""
|
|
|
now = time.time()
|
|
|
- if not os.path.isdir(str(storage.storage.save_location + '/' + storage.storage.subdirname)):
|
|
|
- os.makedirs(str(storage.storage.save_location + '/' + storage.storage.subdirname))
|
|
|
- filename = storage.storage.save_location + '/' + storage.storage.subdirname+'/{:0.3f}.out'.format(now)
|
|
|
+ if not os.path.isdir(str(os.path.join(storage.storage.save_location, storage.storage.subdirname))):
|
|
|
+ os.makedirs(str(os.path.join(storage.storage.save_location, storage.storage.subdirname)))
|
|
|
+ filename = os.path.join(storage.storage.save_location, storage.storage.subdirname,'{:0.3f}.out'.format(now))
|
|
|
board.get_board_status(board_id).last_file = filename
|
|
|
|
|
|
try:
|
|
@@ -674,7 +674,7 @@ def _bif_read_data_and_save(board_id):
|
|
|
if not os.path.isfile(filename):
|
|
|
error(0x001, "No File Created")
|
|
|
except IndexError:
|
|
|
- error(0x002, "Unexpected output of pci for number of orbits to observe. Returning")
|
|
|
+ error(0x002, "Unexpected output of pci for number of turns to observe. Returning")
|
|
|
return
|
|
|
_bif_read_and_update_data_from_file(board_id, filename)
|
|
|
except board.BoardError as e:
|
|
@@ -807,7 +807,7 @@ def _bif_start_acquisition(board_id):
|
|
|
_bif_read_data_and_save(board_id)
|
|
|
|
|
|
if board.get_board_config(board_id).get("build_spectrograms"):
|
|
|
- spectrogram_dir = storage.storage.save_location + '/' + storage.storage.subdirname+"/spectrograms_{:0.3f}".format(time.time())
|
|
|
+ spectrogram_dir = os.path.join(storage.storage.save_location, storage.storage.subdirname, "spectrograms_{:0.3f}".format(time.time()))
|
|
|
os.makedirs(spectrogram_dir)
|
|
|
_bif_iterate_spectrograms(board_id, spectrogram_dir) # TODO: not here?
|
|
|
|
|
@@ -827,7 +827,7 @@ def _bif_start_acquisition(board_id):
|
|
|
storage.get_board_specific_storage(board_id).acquisition_progressbar.remove(0)
|
|
|
|
|
|
storage.get_board_specific_storage(board_id).acquisition_timer.timeout.connect(on_timeout)
|
|
|
- storage.get_board_specific_storage(board_id).acquisition_timer.start(board.get_board_config(board_id).get('orbits_wait_time') * 1000)
|
|
|
+ storage.get_board_specific_storage(board_id).acquisition_timer.start(board.get_board_config(board_id).get('turns_wait_time') * 1000)
|
|
|
|
|
|
|
|
|
def bk_single_read(board_id):
|
|
@@ -915,7 +915,7 @@ def _bif_read_data(board_id):
|
|
|
try:
|
|
|
board.wait_for_revolutions(board_id)
|
|
|
except IndexError:
|
|
|
- error(0x002, "Unexpected output of pci for number of orbits to observe. Returning")
|
|
|
+ error(0x002, "Unexpected output of pci for number of turns to observe. Returning")
|
|
|
return
|
|
|
board.stop_acquisition(board_id)
|
|
|
board.enable_transfer(board_id)
|
|
@@ -954,7 +954,7 @@ def bk_get_temperature(board_id):
|
|
|
backup_get_temp = bk_get_temperature
|
|
|
|
|
|
|
|
|
-def bk_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, orbits_observe=None, orbits_skip=None, bucket_to_use=None):
|
|
|
+def bk_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, turns_observe=None, turns_skip=None):
|
|
|
"""
|
|
|
Toggle Timescan.
|
|
|
:param board_id: id of the board do manipulate
|
|
@@ -964,14 +964,14 @@ def bk_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, orbits_
|
|
|
:param f_to: (int) To value for fine scan
|
|
|
:param ts_pbar: Handle to the Timescan Progressbar
|
|
|
:param plot_func: Function to plot when timescan ended.
|
|
|
- :param orbits_observe: Number of orbits to observe for the timescan (original values will be restored after timescan)
|
|
|
- :param orbits_skip: Number of orbits to skipfor the timescan (original values will be restored after timescan)
|
|
|
+ :param turns_observe: Number of turns to observe for the timescan (original values will be restored after timescan)
|
|
|
+ :param turns_skip: Number of turns to skipfor the timescan (original values will be restored after timescan)
|
|
|
:return: -
|
|
|
"""
|
|
|
if board.get_board_status(board_id).time_scan:
|
|
|
_bif_stop_time_scan(board_id, ts_pbar)
|
|
|
else:
|
|
|
- _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, orbits_observe, orbits_skip, bucket_to_use)
|
|
|
+ _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, turns_observe, turns_skip)
|
|
|
|
|
|
|
|
|
def _bif_stop_time_scan(board_id, ts_pbar):
|
|
@@ -1000,7 +1000,7 @@ def _bif_stop_time_scan(board_id, ts_pbar):
|
|
|
# thread_ts = None
|
|
|
|
|
|
|
|
|
-def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressbar, plot_func, orbits_observe, orbits_skip, bucket_to_use=None):
|
|
|
+def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressbar, plot_func, turns_observe, turns_skip):
|
|
|
"""
|
|
|
Start the timscan. This starts the timer
|
|
|
:param board_id: id of the board do manipulate
|
|
@@ -1010,9 +1010,8 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
|
|
|
:param f_to: To value for fine scan
|
|
|
:param timescan_progressbar: Handle for the timescan progressbar
|
|
|
:param plot_func: Function to use to plot the data
|
|
|
- :param orbits_observe: Number of orbits to observe for the timescan (original values will be restored after timescan)
|
|
|
- :param orbits_skip: Number of orbits to skip for the timescan (original values will be restored after timescan)
|
|
|
- :param bucket_to_use: Number of the bucket whos data will be used to calculate the average signal at each timescan step (if None all bunches will be used)
|
|
|
+ :param turns_observe: Number of turns to observe for the timescan (original values will be restored after timescan)
|
|
|
+ :param turns_skip: Number of turns to skip for the timescan (original values will be restored after timescan)
|
|
|
:return: -
|
|
|
"""
|
|
|
thread = storage.get_board_specific_storage(board_id).setdefault("TimeScanThread", storage.ThreadStorage())
|
|
@@ -1057,30 +1056,29 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
|
|
|
stopSignal = QtCore.pyqtSignal()
|
|
|
finished = QtCore.pyqtSignal()
|
|
|
|
|
|
- def __init__(self, c_frm, c_to, f_frm, f_to, timescan_progressbar, bucket_to_use):
|
|
|
+ def __init__(self, c_frm, c_to, f_frm, f_to, timescan_progressbar):
|
|
|
super(thread_time_scan, self).__init__()
|
|
|
self.c_frm = c_frm
|
|
|
self.c_to = c_to
|
|
|
self.f_frm = f_frm
|
|
|
self.f_to = f_to
|
|
|
self.timescan_progressbar = timescan_progressbar
|
|
|
- self.bucket_to_use = bucket_to_use
|
|
|
|
|
|
def time_scan(self):
|
|
|
'''Method to run in the thread that does the timescan'''
|
|
|
Elements.setEnabled('acquire_{}'.format(board_id), False, exclude=Elements.getElements('start_time_scan_{}'.format(board_id)))
|
|
|
- if orbits_observe:
|
|
|
- if not hasattr(storage.storage, 'orbits_observe_before_timescan'):
|
|
|
- storage.storage.orbits_observe_before_timescan = {}
|
|
|
- storage.storage.orbits_observe_before_timescan[board_id] = board.get_board_config(board_id).get("orbits_observe") # save old values to restore after timescan
|
|
|
- board.get_board_config(board_id).update("orbits_observe", orbits_observe)
|
|
|
- bk_change_num_of_orbits(board_id, orbits_observe)
|
|
|
- if orbits_skip is not None:
|
|
|
- if not hasattr(storage.storage, 'orbits_skip_before_timescan'):
|
|
|
- storage.storage.orbits_skip_before_timescan = {}
|
|
|
- storage.storage.orbits_skip_before_timescan[board_id] = board.get_board_config(board_id).get("orbits_skip")
|
|
|
- board.get_board_config(board_id).update("orbits_skip", orbits_skip)
|
|
|
- bk_change_num_of_skipped_orbits(board_id, orbits_skip)
|
|
|
+ if turns_observe:
|
|
|
+ if not hasattr(storage.storage, 'turns_observe_before_timescan'):
|
|
|
+ storage.storage.turns_observe_before_timescan = {}
|
|
|
+ storage.storage.turns_observe_before_timescan[board_id] = board.get_board_config(board_id).get("turns_observe") # save old values to restore after timescan
|
|
|
+ board.get_board_config(board_id).update("turns_observe", turns_observe)
|
|
|
+ bk_change_num_of_turns(board_id, turns_observe)
|
|
|
+ if turns_skip is not None:
|
|
|
+ if not hasattr(storage.storage, 'turns_skip_before_timescan'):
|
|
|
+ storage.storage.turns_skip_before_timescan = {}
|
|
|
+ storage.storage.turns_skip_before_timescan[board_id] = board.get_board_config(board_id).get("turns_skip")
|
|
|
+ board.get_board_config(board_id).update("turns_skip", turns_skip)
|
|
|
+ bk_change_num_of_skipped_turns(board_id, turns_skip)
|
|
|
|
|
|
c_step = 0
|
|
|
for coarse in range(self.c_frm, self.c_to + 1):
|
|
@@ -1103,7 +1101,7 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
|
|
|
try:
|
|
|
board.wait_for_revolutions(board_id) # Wait before asking for data
|
|
|
except IndexError:
|
|
|
- error(0x002, "Unexpected output of pci for number of orbits to observe. Stopping Timescan")
|
|
|
+ error(0x002, "Unexpected output of pci for number of turns to observe. Stopping Timescan")
|
|
|
self.stopSignal.emit()
|
|
|
return
|
|
|
board.stop_acquisition(board_id)
|
|
@@ -1131,10 +1129,7 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
|
|
|
return
|
|
|
|
|
|
for adc in range(4):
|
|
|
- if self.bucket_to_use is None:
|
|
|
- buckets = data.array[:, adc]
|
|
|
- else:
|
|
|
- buckets = data.array[self.bucket_to_use::config.bunches_per_turn, adc]
|
|
|
+ buckets = data.array[:, adc:adc + 1].reshape(-1)
|
|
|
heatmap[adc, f_step, c_step] = float(buckets.sum()) / buckets.shape[0]
|
|
|
# Uncomment this to change back to the old (non functional) method of maxima determination
|
|
|
# if heatmap[adc, f_step, c_step] > maximum[adc, 0]:
|
|
@@ -1161,12 +1156,12 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
|
|
|
thread.stop()
|
|
|
_bif_stop_time_scan(board_id, timescan_progressbar)
|
|
|
Elements.setEnabled('acquire_{}'.format(board_id), True, exclude=Elements.getElements('start_time_scan_{}'.format(board_id)))
|
|
|
- if orbits_observe:
|
|
|
- board.get_board_config(board_id).update("orbits_observe", storage.storage.orbits_observe_before_timescan[board_id]) # restore values
|
|
|
- bk_change_num_of_orbits(board_id, storage.storage.orbits_observe_before_timescan[board_id])
|
|
|
- if orbits_skip:
|
|
|
- board.get_board_config(board_id).update("orbits_skip", storage.storage.orbits_skip_before_timescan[board_id])
|
|
|
- bk_change_num_of_skipped_orbits(board_id, storage.storage.orbits_skip_before_timescan[board_id])
|
|
|
+ if turns_observe:
|
|
|
+ board.get_board_config(board_id).update("turns_observe", storage.storage.turns_observe_before_timescan[board_id]) # restore values
|
|
|
+ bk_change_num_of_turns(board_id, storage.storage.turns_observe_before_timescan[board_id])
|
|
|
+ if turns_skip:
|
|
|
+ board.get_board_config(board_id).update("turns_skip", storage.storage.turns_skip_before_timescan[board_id])
|
|
|
+ bk_change_num_of_skipped_turns(board_id, storage.storage.turns_skip_before_timescan[board_id])
|
|
|
board.get_board_config(board_id).set_delay(storage.storage.th_old[board_id])
|
|
|
|
|
|
board.get_board_config(board_id).set_chip_delay(
|
|
@@ -1220,7 +1215,7 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
|
|
|
|
|
|
return
|
|
|
|
|
|
- tst = thread_time_scan(c_frm, c_to, f_frm, f_to, timescan_progressbar, bucket_to_use)
|
|
|
+ tst = thread_time_scan(c_frm, c_to, f_frm, f_to, timescan_progressbar)
|
|
|
thread.register(tst)
|
|
|
thread.connect('pbarSignal', timescan_progressbar.setValue)
|
|
|
thread.connect('finished', lambda: finished(timescan_progressbar))
|
|
@@ -1383,7 +1378,7 @@ def _bif_start_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, ti
|
|
|
# def step():
|
|
|
if self._quit:
|
|
|
break
|
|
|
- filename = self.path +'/{:0.3f}.out'.format(time.time())
|
|
|
+ filename = os.path.join(self.path, '{:0.3f}.out'.format(time.time()))
|
|
|
board.pci.read_data_to_file(board_id, filename=filename, timeout=(self.timeout*1000000))
|
|
|
# rename with correct timestamp - last modified time
|
|
|
self.countUpdate.emit(num_of_acq + 1)
|
|
@@ -1393,12 +1388,11 @@ def _bif_start_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, ti
|
|
|
error(0x001, "No File Created")
|
|
|
continue
|
|
|
|
|
|
- newfile = '{path}/trigger_{num:05}_{htime}_{unixtime}.out'.format(
|
|
|
+ newfile = os.path.join(self.path, 'trigger_{num:05}_{htime}_{unixtime}.out'.format(
|
|
|
num=num_of_acq,
|
|
|
htime=dt.fromtimestamp(os.path.getmtime(filename)).strftime('%Y-%m-%dT%Hh%Mm%Ss%f'),
|
|
|
- unixtime=int(os.path.getmtime(filename)),
|
|
|
- path=self.path
|
|
|
- )
|
|
|
+ unixtime=int(os.path.getmtime(filename))
|
|
|
+ ))
|
|
|
os.rename(filename, newfile)
|
|
|
if os.path.getsize(newfile) > 0:
|
|
|
self.liveplot.emit(board_id, newfile)
|
|
@@ -1424,7 +1418,7 @@ def _bif_start_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, ti
|
|
|
if not timeout:
|
|
|
board.pci.write(board_id, '000f0', hex_mask='8F0') # disable readout
|
|
|
board.pci.write(board_id, '007f0', hex_mask='CF0') # enable transfer
|
|
|
- filename = self.path +'/{:0.3f}.out'.format(time.time())
|
|
|
+ filename = os.path.join(self.path,'{:0.3f}.out'.format(time.time()))
|
|
|
board.pci.read_data_to_file(board_id, filename=filename, timeout=(self.timeout*1000000))
|
|
|
# board.pci.write(board_id, '000f0', hex_mask='4F0') # disable transfer
|
|
|
self.countUpdate.emit(copy.deepcopy(num_of_acq+1))
|
|
@@ -1436,12 +1430,11 @@ def _bif_start_wait_on_trigger(board_id, num_of_acquisitions=None, skip=None, ti
|
|
|
error(0x001, "No File Created")
|
|
|
continue
|
|
|
|
|
|
- newfile = '{path}/trigger_{num:05}_{htime}_{unixtime}.out'.format(
|
|
|
+ newfile = os.path.join(self.path, 'trigger_{num:05}_{htime}_{unixtime}.out'.format(
|
|
|
num=num_of_acq,
|
|
|
htime=dt.fromtimestamp(os.path.getmtime(filename)).strftime('%Y-%m-%dT%Hh%Mm%Ss%f'),
|
|
|
- unixtime=int(os.path.getmtime(filename)),
|
|
|
- path=self.path
|
|
|
- )
|
|
|
+ unixtime=int(os.path.getmtime(filename))
|
|
|
+ ))
|
|
|
os.rename(filename, newfile)
|
|
|
self.liveplot.emit(board_id, newfile)
|
|
|
else:
|