aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Scholten2025-10-14 13:39:50 +1000
committerSam Scholten2025-10-14 13:40:25 +1000
commit80f94d3c6a88aa59ef3601f0f0bb9a670635d59e (patch)
tree61032ce1eb074b0de5e58c69bea8b97f4d6d4cd4
parent1c107939ed5799e4b43a494f7829e237ce2c6862 (diff)
downloadpicostream-80f94d3c6a88aa59ef3601f0f0bb9a670635d59e.tar.gz
picostream-80f94d3c6a88aa59ef3601f0f0bb9a670635d59e.zip
Reset plotter state and remove old HDF5 file for new acquisitions
-rw-r--r--picostream/dfplot.py1
-rw-r--r--picostream/main.py15
2 files changed, 15 insertions, 1 deletions
diff --git a/picostream/dfplot.py b/picostream/dfplot.py
index 89784ac..63ffe33 100644
--- a/picostream/dfplot.py
+++ b/picostream/dfplot.py
@@ -286,6 +286,7 @@ class HDF5LivePlotter(QWidget):
# Reset rate calculation to avoid confusion
self.rate_check_start_time = None
self.rate_check_start_samples = 0
+ self.last_displayed_size = 0
def _handle_stale_data(self) -> None:
"""Handle a file check where no new data is found."""
diff --git a/picostream/main.py b/picostream/main.py
index b40c2c1..f1504fb 100644
--- a/picostream/main.py
+++ b/picostream/main.py
@@ -1,5 +1,6 @@
+import os
import sys
from typing import Any, Dict, Optional
@@ -162,11 +163,23 @@ class PicoStreamMainWindow(QMainWindow):
self.start_button.setEnabled(False)
self.stop_button.setEnabled(True)
+ output_file = self.output_file_input.text()
+
+ # Reset plotter state and ensure a clean file for the new acquisition.
+ self.plotter.set_hdf5_path(output_file)
+ if os.path.exists(output_file):
+ try:
+ os.remove(output_file)
+ except OSError as e:
+ self.on_acquisition_error(f"Failed to remove old file: {e}")
+ self.on_acquisition_finished() # Reset UI state
+ return
+
settings = {
"sample_rate_msps": self.sample_rate_input.value(),
"resolution_bits": int(self.resolution_input.currentText()),
"channel_range_str": self.voltage_range_input.currentText(),
- "output_file": self.output_file_input.text(),
+ "output_file": output_file,
"hardware_downsample": self.hw_downsample_input.value(),
"downsample_mode": self.downsample_mode_input.currentText(),
"offset_v": self.offset_v_input.value(),