diff --git a/cfg/terascan.cfg b/cfg/terascan.cfg index 3406a67..e15af4b 100644 --- a/cfg/terascan.cfg +++ b/cfg/terascan.cfg @@ -56,7 +56,8 @@ logic: options: record_length_ms: 1 # Length of data (in ms) to take at each wavelength. Only integers. laser_timeout_s: 10 # time in seconds before we automatically restart the laser scan - + mode_hop_overlap_med: 0.001 # in nm, from the SolsTiS control panel. This is how far back we go to discard data every time a mode hop occurs + mode_hop_overlap_fine: 0.00025 # "" # daq_reader_logic: # module.Class: 'common.daq_reader_logic.DAQReaderLogic' diff --git a/src/qudi/gui/swabian/photon_counts_time_average_gui.py b/src/qudi/gui/swabian/photon_counts_time_average_gui.py index 544a765..22a68a1 100644 --- a/src/qudi/gui/swabian/photon_counts_time_average_gui.py +++ b/src/qudi/gui/swabian/photon_counts_time_average_gui.py @@ -62,7 +62,7 @@ def on_activate(self) -> None: def on_deactivate(self) -> None: # When you call a connector, you should do it as a function, as shown here. Noone knows why. # For some reason, when connecting to an external connector, you also need to specify which function you are disconnecting - self._photon_counts_logic().sigPhotonCounts.disconnect(self._counts_changed) + self._photon_counts_logic().sigScanFinished.disconnect(self._counts_changed) self._mw.start_button.clicked.disconnect() diff --git a/src/qudi/logic/terascan_logic.py b/src/qudi/logic/terascan_logic.py index 2cb3efe..231f659 100644 --- a/src/qudi/logic/terascan_logic.py +++ b/src/qudi/logic/terascan_logic.py @@ -41,6 +41,8 @@ class TerascanLogic(LogicBase): options: record_length_ms: 1 # Length of data (in ms) to take at each wavelength. Only integers. laser_timeout_s: 10 # Time in seconds to wait for the laser to lock before automatically restarting the scan + mode_hop_overlap_med: 0.001 # in nm, from the SolsTiS control panel. This is how far back we go to discard data every time a mode hop occurs + mode_hop_overlap_fine: 0.00025 # "" """ # declare connectors @@ -55,6 +57,9 @@ class TerascanLogic(LogicBase): missing='info') _laser_timeout_s = ConfigOption(name='laser_timeout_s', default=10) + + _mode_hop_overlap_med = ConfigOption(name='mode_hop_overlap_med', default=0.001) + _mode_hop_overlap_fine = ConfigOption(name='mode_hop_overlap_fine', default=0.00025) # status variables: _start_wavelength = StatusVar('start_wavelength', default=0.75) @@ -65,7 +70,7 @@ class TerascanLogic(LogicBase): _scan_type = StatusVar('scan_type', default=2) # SCAN_TYPE_FINE _laser_locked = StatusVar('laser_locked', default=False) - _current_data = StatusVar('current_data', default=[]) # list of TerascanData + _current_data = [] # list of TerascanData _last_locked: float = 0 @@ -255,11 +260,43 @@ def _new_daq_data(self, data: List[ReaderVal]): # self.sigStartCounting.emit() if not i.val and self._laser_locked: + # We just mode hopped and are now unlocked self._laser_locked = False - # self.sigStopCounting.emit() + self._remove_mode_hop() + self.sigLaserLocked.emit(self._laser_locked) + + ### Internal Functions ### + def _remove_mode_hop(self): + """ Function to remove previous data when a mode hop occurs. + Assumes we are locked externally. + """ + target = -1 + scan_up = self._start_wavelength < self._end_wavelength + + if self._scan_type == 1: # MEDIUM Scan + target = self._current_wavelength - self._mode_hop_overlap_med \ + if scan_up else self._current_wavelength + self._mode_hop_overlap_med + elif self._scan_type == 2: # FINE Scan + target = self._current_wavelength - self._mode_hop_overlap_fine \ + if scan_up else self._current_wavelength + self._mode_hop_overlap_fine + else: + self.log.warning('Unknown scan type. Not removing data.') + return + + while len(self._current_data) > 0: + if (scan_up and \ + self._current_data[-1].wavelength > target) or \ + (not scan_up and \ + self._current_data[-1].wavelength < target): + # We need to check if we are scanning up or down + self._current_data.pop() + else: + break + + #### Watchdog Timer #### def __watchdog(self):