Skip to content
Snippets Groups Projects
Commit 10a5112c authored by Guenter Quast's avatar Guenter Quast
Browse files

streamlining of code in redP_mimocorb.py, fixed docu

parent bc9f81b2
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......@@ -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
"""
......
......@@ -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:
......
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