From d50ef540406fa9187f7fb2f23286565c5a6a4b0d Mon Sep 17 00:00:00 2001 From: Guenter Quast <guenter.quast@online.de> Date: Sun, 2 Jun 2024 14:43:20 +0200 Subject: [PATCH] changed naming: callback fuction --- redPoscdaq.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/redPoscdaq.py b/redPoscdaq.py index 3b24c6c..62218ba 100755 --- a/redPoscdaq.py +++ b/redPoscdaq.py @@ -47,6 +47,7 @@ from functools import partial import numpy as np import matplotlib from matplotlib.figure import Figure +from multiprocessing import Event from npy_append_array import NpyAppendArray @@ -90,14 +91,15 @@ class rpControl(QMainWindow, Ui_MCPHA): """ rates = {0:1, 1: 4, 2: 8, 3: 16, 4: 32, 5: 64, 6: 128, 7: 256} - def __init__(self, external_datasink=None): + def __init__(self, callback=None): """ Args: interactive: if True run in interactive mode, else run as mimoCoRB client """ super(rpControl, self).__init__() - self.external_datasink = external_datasink + self.callback_function = callback + self.callback = True # get command line arguments self.parse_args() # set physical units (for axis labels) @@ -325,8 +327,8 @@ class rpControl(QMainWindow, Ui_MCPHA): self.timestamp = time.time() self.reset_osc() self.osc_daq.process_data() - if self.external_datasink is not None: - self.external_datasink(self.osc_daq.data) + if self.callback: + self.callback_function(self.osc_daq.data) self.start_osc() self.osc_daq.deadT += time.time() - self.timestamp else: @@ -828,15 +830,17 @@ class redP_consumer(): def data_sink(self, data): """function called by redPoscdaq - - this version calculates statistics + this simple version calculates statistics only """ + self.databuffer = data + # analyze data self.NTrig += 1 t = time.time() dt = t - self.Tprev self.Tprev = t self.dT += dt - l_tot = len(data[0]) + l_tot = len(self.databuffer[0]) + # output status and update scope display once per second if self.dT >= 1.: dN = self.NTrig - self.Nprev @@ -848,12 +852,12 @@ class redP_consumer(): print(status_txt, end='\r') -def run_rpControl(sink=None): +def run_rpControl(callback=None): # start redPidaya GUI under Qt5 app = QApplication(sys.argv) dpi = app.primaryScreen().logicalDotsPerInch() matplotlib.rcParams["figure.dpi"] = dpi - application = rpControl(external_datasink=sink) + application = rpControl(callback=callback) application.show() sys.exit(app.exec_()) @@ -862,4 +866,4 @@ if __name__ == '__main__': # -------------------------------------------- # run_rpControl() sink = redP_consumer() - run_rpControl(sink=sink.data_sink) + run_rpControl(callback=sink.data_sink) -- GitLab