diff --git a/gui/src/aaregui/main_window.py b/gui/src/aaregui/main_window.py index 072096c8..71b11b82 100644 --- a/gui/src/aaregui/main_window.py +++ b/gui/src/aaregui/main_window.py @@ -347,6 +347,7 @@ class MainWindow(QMainWindow): self.daq.update.connect(self.sample_logic.update_daq_status) self.daq.update.connect(self.manual_sample_panel.update_daq_status) + self.daq.update.connect(self.fluor_panel.update_daq_status) self.daq.update.connect(self.update_daq_status) self.daq.standard_scan_completed.connect(self.rotation.scan_completed) diff --git a/gui/src/aaregui/panels/fluorescence_panel.py b/gui/src/aaregui/panels/fluorescence_panel.py index f625cbc5..d977543a 100644 --- a/gui/src/aaregui/panels/fluorescence_panel.py +++ b/gui/src/aaregui/panels/fluorescence_panel.py @@ -5,7 +5,7 @@ from PySide6.QtGui import QPainter, QColor, QPen from PySide6.QtWidgets import QWidget, QGridLayout, QGraphicsSimpleTextItem, QLabel from aaredaqlib.logger_config import setup_logger -from aaredaqlib.models import FluorescenceSpectrumOutputModel +from aaredaqlib.models import FluorescenceSpectrumOutputModel, DAQStatusModel logger = setup_logger("aareGUI") @@ -44,6 +44,7 @@ class FluorescencePanel(QWidget): self._last_x_keV = None self._last_y_counts = None + self._sample_name = None # Average dead time label self.avg_dead_label = QLabel("Average dead time: -") @@ -122,13 +123,19 @@ class FluorescencePanel(QWidget): if self.series.count() == 0: logger.info("No data to save.") return + # Prefer cached arrays; fall back to reading from series x_vals = self._last_x_keV y_vals = self._last_y_counts if x_vals is None or y_vals is None or len(x_vals) != self.series.count(): x_vals = [self.series.at(i).x() for i in range(self.series.count())] y_vals = [self.series.at(i).y() for i in range(self.series.count())] - path, _ = QFileDialog.getSaveFileName(self, "Save Spectrum CSV", "spectrum.csv", "CSV files (*.csv)") + + default_name = "spectrum.csv" + if self._sample_name is not None: + default_name = f"{self._sample_name}_spectrum.csv" + + path, _ = QFileDialog.getSaveFileName(self, "Save Spectrum CSV", default_name, "CSV files (*.csv)") if not path: return try: @@ -232,4 +239,11 @@ class FluorescencePanel(QWidget): self.axis_x.setRange(xmin, xmax) self.axis_y.setRange(ymin, ymax) except Exception as e: - logger.error(f"Update plot error: {e}") \ No newline at end of file + logger.error(f"Update plot error: {e}") + + @Slot(DAQStatusModel) + def update_daq_status(self, s: DAQStatusModel): + if s.sample is not None: + self._sample_name = s.sample.sample_name + else: + self._sample_name = None