diff --git a/redP_mimoCoRB.py b/redP_mimoCoRB.py index 12afa9bbae4086f53240a8ecdcf4fa5c58781cbe..46e65ad354b9aaff351723d32671bb2c70be183c 100644 --- a/redP_mimoCoRB.py +++ b/redP_mimoCoRB.py @@ -7,66 +7,48 @@ via callback of function data_sink() in class redP_mimoCoRB. 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 + """ Interface for redPoscdaq.py to the daq rinbuffer mimoCoRB """ 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.rb_exporter = rbPut(config_dict=config_dict, sink_list=sink_list, **rb_info) + self.number_of_channels = len(self.rb_exporter.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): + def __call__(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 + # deliver pulse data and no metadata + active = self.rb_exporter(data, None) # send data + self.event_count += 1 else: - active = self.action(None, None) # send None to signal end - print("redPoscdaq exiting") - sys.exit() + active = self.rb_exporter(None, None) # send None when done + 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 - - The class mimocorb.buffer_control/rbImport is used to interface to the - newBuffer and Writer classes of the package mimoCoRB.mimo_buffer - - This example may serve as a template for other data sources - - :param config_dict: configuration dictionary - - - events_required: number of events to taken - - number_of_samples, sample_time_ns, pretrigger_samples and analogue_offset - - decimation index, invert fags, trigger mode and trigger direction for RedPitaya + """Main function, + executed as a multiprocessing Process, to pass data from RedPitaya to a mimoCoRB buffer + + :param config_dict: configuration dictionary + - events_required: number of events to be taken + - number_of_samples, sample_time_ns, pretrigger_samples and analogue_offset + - decimation index, invert flags, trigger mode and trigger direction for RedPitaya """ - # initialize mimocorb class inside redPoscidaq - datasource= redP_mimocorb(config_dict=config_dict, sink_list=sink_list, **rb_info) + # initialize mimocorb class + rb_source= redP_mimocorb(config_dict=config_dict, sink_list=sink_list, **rb_info) #print("data source initialized") - # start oscilloscope + # start oscilloscope in callback mode #print("starting osci") - rp.run_rpControl(callback=datasource.data_sink, conf_dict=config_dict) - + rp.run_rpControl(callback=rb_source, conf_dict=config_dict) -#daq = run_mimoDAQ('redP_mimoCoRB.yaml') -#daq.setup() -#RB_1 = daq.ringbuffers['RB_1'] -#sink_dict = RB_1.new_writer() -#datasource= rp.redP_mimocorb(config_dict={}, sink_list=[sink_dict], RB_1='write') -#print("data source initialized") -#rp.run_rpControl(callback=datasource.data_sink) -#print("starting DAQ") -#daq.run() diff --git a/redPoscdaq.py b/redPoscdaq.py index d13f13ffeba58d743e588b497b7f945bb7e45070..5dddd8e6d2a25e5b9aad446cdf34e79387847117 100755 --- a/redPoscdaq.py +++ b/redPoscdaq.py @@ -3,13 +3,11 @@ 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 exported via calling a callback function. - Optionally, triggered waveforms can be stored a numpy binary file - (.npy format). + continously. Triggered wave forms can be exported via calling a callback + function stored in a numpy binary file in .npy format. - Code derived from mcpha.py by Pavel Demin - - This code is compatible with release 20240204 of the alpine linux image + This code is derived from mcpha.py by Pavel Demin and + compatible with release 20240204 of the alpine linux image https://github.com/pavel-demin/red-pitaya-notes/releases/tag/20240204 """ diff --git a/setup.yaml b/setup.yaml index a4c5088d83df52ff7247d53311d9cf8e3b787aeb..5576b533e96d82607a9f06f8576260898b602f5a 100644 --- a/setup.yaml +++ b/setup.yaml @@ -23,14 +23,14 @@ RingBuffer: # define ring buffers - RB_1: # raw input data buffer (from picoScope, file or simulation) - number_of_slots: 16 + number_of_slots: 100 channel_per_slot: 1000 data_type: 1: ['ch1', "float32"] 2: ['ch2', "float32"] - RB_2: # buffer with correct signature double pulse parameters - number_of_slots: 16 + number_of_slots: 100 channel_per_slot: 1 data_type: data_type: