"""
**redP_mimoCoRB**: a simple template to use mimoCoRB with the RedPitaya and redPoscdaq.py 

Input data is provided as numpy-arry of shape (number_of_channels, number_of_samples).
"""

import time
import sys

import redPoscdaq as rp


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 be simulated or 0 for infinite
      - sleeptime: (mean) time between events
      - random: random time between events according to a Poission process
      - number_of_samples, sample_time_ns, pretrigger_samples and analogue_offset
        describe the waveform data to be generated (as for oscilloscope setup)

    Internal parameters of the simulated physics process (the decay of a muon)
    are (presently) not exposed to user.
    """

    # initialize mimocorb class inside redPoscidaq
    datasource= rp.redP_mimocorb(config_dict=config_dict, sink_list=sink_list, **rb_info)
    #print("data source initialized")

    # start oscilloscope
    #print("starting osci")
    rp.run_rpControl(callback=datasource.data_sink, 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()