From 22b899e7236ec11fbae3fae4f08880dd8b6657dd Mon Sep 17 00:00:00 2001 From: wendtalexander Date: Wed, 9 Oct 2024 17:15:58 +0200 Subject: [PATCH] [ui] adding stop button --- pyrelacs/ui/mainwindow.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pyrelacs/ui/mainwindow.py b/pyrelacs/ui/mainwindow.py index 7a8994d..ef67fe4 100644 --- a/pyrelacs/ui/mainwindow.py +++ b/pyrelacs/ui/mainwindow.py @@ -78,14 +78,15 @@ class PyRelacs(QMainWindow): widget.setLayout(layout) self.setCentralWidget(widget) - SAMPLERATE = 1000 - BUFFERSIZE = 1_000 + SAMPLERATE = 1_000 + BUFFERSIZE = 1_0000 self.buffer = CircBuffer(size=BUFFERSIZE, samplerate=SAMPLERATE) # self.connect_dac() # self.daq_producer = DaqProducer(self.buffer, self.daq_device, [1, 1]) self.sin_producer = SinProducer(self.buffer) self.continously_plot = Continously(self.figure, self.buffer) + self.continously_plot.plot_daq() def create_actions(self): self._rlx_exitaction = QAction(QIcon(":/icons/exit.png"), "Exit", self) @@ -125,7 +126,7 @@ class PyRelacs(QMainWindow): self._run_sinus_action = QAction(QIcon(":/icons/record.png"), "Sinus", self) self._run_sinus_action.triggered.connect(self.run_sinus) - self._stop_recording = QAction("Stop", self) + self._stop_recording = QAction(QIcon(":/icons/stop.png"), "Stop", self) self._stop_recording.triggered.connect(self.stop_recording) self.create_menu() @@ -211,12 +212,19 @@ class PyRelacs(QMainWindow): sinus_pro.signals.progress.connect(self.progress_fn) self.threadpool.start(sinus_pro) - # time.sleep(0.05) - self.continously_plot.plot_daq() + # plot_daq = Worker(self.continously_plot.plot_daq) + # plot_daq.signals.result.connect(self.print_output) + # plot_daq.signals.finished.connect(self.thread_complete) + # plot_daq.signals.progress.connect(self.progress_fn) + # self.threadpool.start(plot_daq) + + # self.continously_plot.plot_daq() def stop_recording(self): self.add_to_textfield("pressed") self._stop_recording.setEnabled(False) + self.sin_producer.stop_request() + self.continously_plot.stop_plotting() def connect_dac(self): devices = uldaq.get_daq_device_inventory(uldaq.InterfaceType.USB) @@ -257,6 +265,7 @@ class PyRelacs(QMainWindow): def on_exit(self): log.info("exit button!") + self.stop_recording() self.add_to_textfield("exiting") self.disconnect_dac() self.close()