From 2539fa7e25cf1b67efbd503ea146ee70c67dae35 Mon Sep 17 00:00:00 2001 From: wendtalexander Date: Thu, 10 Oct 2024 15:10:50 +0200 Subject: [PATCH] [dataio/daq] adding stop signal from gui, commentin out --- pyrelacs/dataio/daq_producer.py | 35 +++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/pyrelacs/dataio/daq_producer.py b/pyrelacs/dataio/daq_producer.py index bda3ecd..a88c5cb 100644 --- a/pyrelacs/dataio/daq_producer.py +++ b/pyrelacs/dataio/daq_producer.py @@ -22,6 +22,8 @@ class DaqProducer: self.ai_device = self.device.get_ai_device() self.channels = channels + self.stop = False + def read_analog_continously( self, *args, @@ -67,7 +69,7 @@ class DaqProducer: while daq_status != uldaq.ScanStatus.IDLE: prev_count = 0 prev_index = 0 - while time.time() - start_time < 10: + while not self.stop: daq_status, transfer_status = self.ai_device.get_scan_status() # The index into the data buffer immediately following the last sample transferred. current_index = transfer_status.current_index @@ -154,17 +156,20 @@ class DaqProducer: break return "Done. " - -if __name__ == "__main__": - devices = uldaq.get_daq_device_inventory(uldaq.InterfaceType.USB) - log.debug(f"Found daq devices {len(devices)}, connecting to the first one") - try: - daq_device = uldaq.DaqDevice(devices[0]) - except uldaq.ul_exception.ULException as e: - log.error("Did not found daq devices, please connect one") - raise e - daq_device.connect() - - buf = CircBuffer(size=1_000_000, samplerate=100) - producer = DaqProducer(buf, daq_device, [1, 1]) - producer.read_analog_continously() + def stop_aquisition(self): + self.stop = True + + +# if __name__ == "__main__": +# devices = uldaq.get_daq_device_inventory(uldaq.InterfaceType.USB) +# log.debug(f"Found daq devices {len(devices)}, connecting to the first one") +# try: +# daq_device = uldaq.DaqDevice(devices[0]) +# except uldaq.ul_exception.ULException as e: +# log.error("Did not found daq devices, please connect one") +# raise e +# daq_device.connect() +# +# buf = CircBuffer(size=1_000_000, samplerate=100) +# producer = DaqProducer(buf, daq_device, [1, 1]) +# producer.read_analog_continously()