aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--picostream/cli.py2
-rw-r--r--picostream/dfplot.py11
-rw-r--r--picostream/main.py3
3 files changed, 13 insertions, 3 deletions
diff --git a/picostream/cli.py b/picostream/cli.py
index 8fc65b0..23922e3 100644
--- a/picostream/cli.py
+++ b/picostream/cli.py
@@ -327,8 +327,8 @@ class Streamer:
logger.info("Stopping data acquisition and saving...")
- self._join_threads()
self.pico_device.close_device()
+ self._join_threads()
logger.success("Shutdown complete.")
diff --git a/picostream/dfplot.py b/picostream/dfplot.py
index 63ffe33..ebf6f03 100644
--- a/picostream/dfplot.py
+++ b/picostream/dfplot.py
@@ -105,10 +105,9 @@ class HDF5LivePlotter(QWidget):
# Setup UI
self.setup_ui()
- # Setup update timer
+ # Setup update timer, which is controlled externally
self.timer = QTimer()
self.timer.timeout.connect(self.update_from_file)
- self.timer.start(self.update_interval_ms)
logger.info(
f"HDF5LivePlotter initialized: path={hdf5_path}, interval={update_interval_ms}ms"
@@ -133,6 +132,14 @@ class HDF5LivePlotter(QWidget):
self.curve.setData([], []) # Clear plot
self.check_file_exists()
+ def start_updates(self) -> None:
+ """Starts the plot update timer."""
+ self.timer.start(self.update_interval_ms)
+
+ def stop_updates(self) -> None:
+ """Stops the plot update timer."""
+ self.timer.stop()
+
def setup_ui(self) -> None:
"""Sets up the main window, widgets, and plot layout."""
layout = QVBoxLayout(self)
diff --git a/picostream/main.py b/picostream/main.py
index a882b80..9fdb423 100644
--- a/picostream/main.py
+++ b/picostream/main.py
@@ -205,9 +205,11 @@ class PicoStreamMainWindow(QMainWindow):
self.worker.error.connect(self.on_acquisition_error)
self.thread.start()
+ self.plotter.start_updates()
def stop_acquisition(self) -> None:
"""Stop the background data acquisition."""
+ self.plotter.stop_updates()
if self.worker:
self.worker.stopRequested.emit()
self.stop_button.setEnabled(False)
@@ -215,6 +217,7 @@ class PicoStreamMainWindow(QMainWindow):
def on_acquisition_finished(self) -> None:
"""Handle acquisition completion (both success and failure)."""
print("Acquisition finished.")
+ self.plotter.stop_updates()
self.start_button.setEnabled(True)
self.stop_button.setEnabled(False)
self.thread = None