Skip to content
Snippets Groups Projects
Commit f0be7835 authored by Günter Quast's avatar Günter Quast
Browse files

moved mimoCoRB callback function redP_mimoCoRB.py

parent 6ab8b7eb
No related branches found
No related tags found
No related merge requests found
"""
**redP_mimoCoRB**: a simple template to use mimoCoRB with the RedPitaya and redPoscdaq.py
**redP_mimoCoRB**: use mimoCoRB with the RedPitaya and redPoscdaq.py
Input data is provided as numpy-arry of shape (number_of_channels, number_of_samples).
"""
......@@ -8,8 +8,33 @@ import time
import sys
import redPoscdaq as rp
from mimocorb.buffer_control import rbPut
class redP_mimocorb():
""" Interface to the daq rinbuffer mimoCoRB for redPoscdaq
"""
def __init__(self, source_list=None, sink_list=None, observe_list=None, config_dict=None,
**rb_info):
# initialize mimoCoRB interface
self.action = rbPut(config_dict=config_dict, sink_list=sink_list, **rb_info)
self.number_of_channels = len(self.action.sink.dtype)
self.events_required = 1000 if "eventcount" not in config_dict else config_dict["eventcount"]
self.event_count = 0
self.active=True
def data_sink(self, data):
"""function called by redPoscdaq
"""
if (self.events_required == 0 or self.event_count < self.events_required) and self.active:
# deliver pulse data and no metadata
active = self.action(data, None) # send data
self.event_count += 1
else:
active = self.action(None, None) # send None to signal end
print("redPoscdaq exiting")
sys.exit()
def redP_to_rb(source_list=None, sink_list=None, observe_list=None, config_dict=None, **rb_info):
"""
Get data from RedPitaya and pass data to buffer
......@@ -27,7 +52,7 @@ def redP_to_rb(source_list=None, sink_list=None, observe_list=None, config_dict=
"""
# initialize mimocorb class inside redPoscidaq
datasource= rp.redP_mimocorb(config_dict=config_dict, sink_list=sink_list, **rb_info)
datasource= redP_mimocorb(config_dict=config_dict, sink_list=sink_list, **rb_info)
#print("data source initialized")
# start oscilloscope
......
......@@ -3,8 +3,7 @@
application running on a RedPitaya FPGA board
Contains a button to run the oscilloscope in daq mode, i.e. it is restarted
continously. If defined, data is eported to a callback function. A callback
class redP_mimocorb() implements an interface to the daq rinbuffer mimoCoRB.
continously. If defined, data is exported via calling a callback function.
Optionally, triggered waveforms can be stored a numpy binary file
(.npy format).
......@@ -52,11 +51,6 @@ import matplotlib
from matplotlib.figure import Figure
from multiprocessing import Event
# !!! for conditional import from npy_append_array !!!
def import_mimocorb():
global rbPut
from mimocorb.buffer_control import rbPut
# !!! for conditional import from npy_append_array !!!
def import_npy_append_array():
global NpyAppendArray
......@@ -897,36 +891,7 @@ class redP_consumer():
status_txt = "active: {:.1f}s trigger rate: {:.2f} Hz, data rate: {:.4g} MB/s".format(T_active, r, r*l_tot*4e-6)
print(status_txt, end='\r')
class redP_mimocorb():
def __init__(self, source_list=None, sink_list=None, observe_list=None, config_dict=None,
**rb_info):
# import rbPut() from mimoCoRB
import_mimocorb()
# initialize mimoCoRB interface
self.action = rbPut(config_dict=config_dict, sink_list=sink_list, **rb_info)
self.number_of_channels = len(self.action.sink.dtype)
self.events_required = 1000 if "eventcount" not in config_dict else config_dict["eventcount"]
self.event_count = 0
self.active=True
def data_sink(self, data):
"""function called by redPoscdaq
"""
if (self.events_required == 0 or self.event_count < self.events_required) and self.active:
# deliver pulse data and no metadata
active = self.action(data, None) # send data
self.event_count += 1
else:
active = self.action(None, None) # send None to signal end
print("redPoscdaq exiting")
sys.exit()
def run_rpControl(callback=None, conf_dict=None):
if conf_dict is not None:
# need module rbPut() from mimoCoRB, import here
import_mimocorb()
# start redPidaya GUI under Qt5
app = QApplication(sys.argv)
dpi = app.primaryScreen().logicalDotsPerInch()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment