Skip to content

Commit

Permalink
add working terascan_logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lange50 committed Apr 28, 2025
1 parent e077744 commit d84945e
Show file tree
Hide file tree
Showing 4 changed files with 641 additions and 412 deletions.
36 changes: 16 additions & 20 deletions src/qudi/gui/terascan/terascan_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
from qudi.util.paths import get_artwork_dir
from qudi.util.colordefs import QudiPalettePale as palette

from qudi.hardware.terascan.terascan_logic import TerascanLogicData

pg.setConfigOption('useOpenGL', True) # Add this at the top of your file


Expand Down Expand Up @@ -68,8 +66,10 @@ def on_activate(self) -> None:

#################### CONNECT SIGNALS FROM LOGIC TO GUI ####################
self._terascan_logic().sigNewData.connect(self._update_data) # Update the GUI with new data
self._terascan_logic().sigStartScan.connect(self._scan_started) # Update the GUI when the scan starts
self._terascan_logic().sigStopScan.connect(self._scan_stopped) # Update the GUI when the scan stops
self._terascan_logic().sigSetScanType.connect(self._set_scan_type) # Update the GUI with new scan type
self._terascan_logic().sigSetScanRate.connect(self._set_scan_rate) # Update the GUI with new scan rate
self._terascan_logic().sigScanStarted.connect(self._scan_started) # Update the GUI when the scan starts
self._terascan_logic().sigScanStopped.connect(self._scan_stopped) # Update the GUI when the scan stops


################### CONNECT SIGNALS FROM GUI TO LOGIC ####################
Expand All @@ -96,7 +96,8 @@ def on_activate(self) -> None:
)

####################### REFERENCE TO TERASCAN DATA ####################
self.data: TerascanLogicData = TerascanLogicData()
self.wavelength_data: List[float] = [] # Wavelength data from the logic module
self.counts_data: List[float] = [] # Counts data from the logic module

# Set up update timer for plot updates
self.__timer = QtCore.QTimer()
Expand Down Expand Up @@ -157,19 +158,10 @@ def _start_stop_pressed(self) -> None:
stop_wl = self._terascan_logic().stop_wavelength
self._mw.plot_widget.setXRange(start_wl, stop_wl)
else:
self.sigStopMeasurement.emit() # Tell the logic to stop the scan
self.sigStopMeasurement.emit() # Tell the logic to stop the scan


@QtCore.Slot(int)
def _scan_type_changed(self, _: int):
self.sigSetScanType.emit(self._mw.scan_type.currentData().value)
self._mw.scan_rate.clear()
for txt, scan_rate in self._terascan_logic().scan_rates.items():
self._mw.scan_rate.addItem(txt, scan_rate)

@QtCore.Slot(int)
def _scan_rate_changed(self, _: int):
if self._mw.scan_rate.currentData() is not None:
self.sigSetScanRate.emit(self._mw.scan_rate.currentData().value)

# @QtCore.Slot(bool)
# def _laser_lock_ui(self, locked: bool) -> None:
Expand All @@ -192,8 +184,11 @@ def _scan_stopped(self) -> None:

@QtCore.Slot()
def __update_gui(self):
x_array = self.data.valid_wavelength_data
y_array = self.data.valid_counts_data
x_array = self.wavelength_data
y_array = self.counts_data

if len(x_array) == 0 or len(y_array) == 0:
return

# If running average is enabled, apply a rolling average
if self._mw.checkbox_running_avg.isChecked():
Expand All @@ -214,9 +209,10 @@ def _update_running_avg_points(self, points: int) -> None:
self._running_avg_points = points

@QtCore.Slot()
def _update_data(self, data: TerascanLogicdata) -> None:
def _update_data(self, wavelength_data, counts_data) -> None:
""" Update the data from the logic module """
self.data = data
self.wavelength_data = wavelength_data
self.counts_data = counts_data



Expand Down
Loading

0 comments on commit d84945e

Please sign in to comment.