summaryrefslogtreecommitdiff
path: root/gr-uhd/lib/rfnoc_rx_streamer_impl.h
blob: df9cb0c368bc11817b1334c105ccdb7bece139f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* -*- c++ -*- */
/*
 * Copyright 2019 Ettus Research, a National Instruments Brand.
 * Copyright 2020 Free Software Foundation, Inc.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#ifndef INCLUDED_GR_UHD_RFNOC_RX_STREAMER_IMPL_H
#define INCLUDED_GR_UHD_RFNOC_RX_STREAMER_IMPL_H

#include <gnuradio/uhd/rfnoc_rx_streamer.h>

namespace gr {
namespace uhd {

class rfnoc_rx_streamer_impl : public rfnoc_rx_streamer
{
public:
    rfnoc_rx_streamer_impl(rfnoc_graph::sptr graph,
                           const size_t num_chans,
                           const ::uhd::stream_args_t& stream_args,
                           const size_t vlen,
                           const bool issue_stream_cmd_on_start);
    ~rfnoc_rx_streamer_impl();

    std::string get_unique_id() const override { return d_unique_id; }

    /***** API ***************************************************************/
    void set_start_time(const ::uhd::time_spec_t& time);

    /***** GNU Radio API *****************************************************/
    bool check_topology(int, int) override;
    bool start() override;
    bool stop() override;
    int work(int noutput_items,
             gr_vector_const_void_star& input_items,
             gr_vector_void_star& output_items) override;

private:
    void flush();

    //! Bytes per item (e.g. 4 for sc16)
    const size_t d_itemsize;
    //! Input vector length
    const size_t d_vlen;
    //! Reference to the underlying graph
    rfnoc_graph::sptr d_graph;
    //! Stream args
    ::uhd::stream_args_t d_stream_args;
    //! Reference to the actual streamer
    ::uhd::rx_streamer::sptr d_streamer;
    //! Copy of the streamer's block ID
    const std::string d_unique_id;
    //! Stash for the TX metadata
    ::uhd::rx_metadata_t d_metadata;
    //! RX timeout value
    double d_timeout = 1.0;
    //! True if the stream should immediately start with the flow graph without
    // external prompting
    const bool d_issue_stream_cmd_on_start;
    //! True if d_start_time holds a value we need to process
    bool d_start_time_set = false;
    //! A start time for the next stream command
    ::uhd::time_spec_t d_start_time;
};

} // namespace uhd
} // namespace gr

#endif /* INCLUDED_GR_UHD_RFNOC_RX_STREAMER_IMPL_H */