aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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(),