GNU Radio Manual and C++ API Reference  v3.9.2.0-89-gb7c7001e
The Free & Open Software Radio Ecosystem
rfnoc_graph.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2019 Ettus Research, a National Instruments Brand.
4  * Copyright 2020 Free Software Foundation, Inc.
5  *
6  * SPDX-License-Identifier: GPL-3.0-or-later
7  */
8 
9 #ifndef INCLUDED_GR_UHD_RFNOC_GRAPH_H
10 #define INCLUDED_GR_UHD_RFNOC_GRAPH_H
11 
12 #include <gnuradio/uhd/api.h>
13 #include <uhd/rfnoc/noc_block_base.hpp>
14 #include <uhd/stream.hpp>
15 #include <uhd/types/device_addr.hpp>
16 #include <memory>
17 
18 namespace gr {
19 namespace uhd {
20 
21 class rfnoc_block;
22 
23 /*! GNU Radio-specific wrapper for uhd::rfnoc::rfnoc_graph
24  *
25  * This wraps uhd::rfnoc::rfnoc_graph for simpler insertion into GNU Radio flow
26  * graphs. All API calls match those on said class.
27  */
29 {
30 public:
31  using sptr = std::shared_ptr<rfnoc_graph>;
32 
33  static sptr make(const ::uhd::device_addr_t& dev_addr);
34 
35  virtual ~rfnoc_graph() {}
36 
37  //! Connect two blocks, or a block to a streamer, or a streamer to a block
38  //
39  // \param src_block The block ID of the source block (e.g., "0/Radio#0)
40  // \param src_block_port The port on the source block to connect to
41  // \param dst_block The block ID of the destination block (e.g., "0/DDC#0)
42  // \param dst_block_port The port on the destination block to connect to
43  // \param skip_property_propagation Disable property propagation on this
44  // connection (see the UHD documentation)
45  virtual void connect(const std::string& src_block,
46  const size_t src_block_port,
47  const std::string& dst_block,
48  const size_t dst_block_port,
49  const bool skip_property_propagation = false) = 0;
50 
51  //! Convenience overload: Defaults to port 0 on both blocks
52  //
53  // \param src_block The block ID of the source block (e.g., "0/Radio#0)
54  // \param dst_block The block ID of the destination block (e.g., "0/DDC#0)
55  // \param skip_property_propagation Disable property propagation on this
56  // connection (see the UHD documentation)
57  virtual void connect(const std::string& src_block,
58  const std::string& dst_block,
59  const bool skip_property_propagation = false) = 0;
60 
61  //! Create an RX streamer
62  //
63  // Note: This streamer is not connected to anything after creation.
64  //
65  // See also the UHD documentation for uhd::rfnoc::rfnoc_graph::create_rx_streamer().
66  //
67  // \param num_ports Number of streaming ports
68  // \param args Stream args.
69  virtual ::uhd::rx_streamer::sptr
70  create_rx_streamer(const size_t num_ports, const ::uhd::stream_args_t& args) = 0;
71 
72  //! Create a TX streamer
73  //
74  // Note: This streamer is not connected to anything after creation.
75  //
76  // See also the UHD documentation for uhd::rfnoc::rfnoc_graph::create_tx_streamer().
77  //
78  // \param num_ports Number of streaming ports
79  // \param args Stream args.
80  virtual ::uhd::tx_streamer::sptr
81  create_tx_streamer(const size_t num_ports, const ::uhd::stream_args_t& args) = 0;
82 
83  //! Commit the graph and run initial checks
84  //
85  // See ::uhd::rfnoc::rfnoc_graph::commit() for more documentation.
86  virtual void commit() = 0;
87 
88  /*! Return a valid block ID string, if it exists, or an empty string, if not
89  *
90  * This will check the available blocks on the connected devices and see if
91  * they match the block name, device ID, and block number.
92  */
93  virtual std::string get_block_id(const std::string& block_name,
94  const int device_select,
95  const int block_select) = 0;
96 
97  //! Set time source on the specified motherboard
98  //
99  // Note: This is a convenience call, it directly dereferences the underlying
100  // motherboard controller.
101  //
102  // \param source Time source (e.g., "internal")
103  // \param mb_index Motherboard index, starting at 0
104  virtual void set_time_source(const std::string& source, const size_t mb_index) = 0;
105 
106  //! Set clock source on the specified motherboard
107  //
108  // Note: This is a convenience call, it directly dereferences the underlying
109  // motherboard controller.
110  //
111  // \param source Clock source (e.g., "internal")
112  // \param mb_index Motherboard index, starting at 0
113  virtual void set_clock_source(const std::string& source, const size_t mb_index) = 0;
114 
115  //! Return a reference to the block with a given block ID
116  //
117  // This allows to retrieve a shared pointer to a block controller with a
118  // limit. It keeps track of the references given out, and will throw an
119  // exception if called more than max_ref_count times. This is to help ensure
120  // that GNU Radio blocks don't share block controllers unintentionally.
121  //
122  // \param block_id A valid block ID. Use get_block_id() to make sure it is
123  // valid.
124  // \param max_ref_count The maximum number of references that are doled out.
125  //
126  // \throws std::runtime_error if more than \p max_ref_count references are
127  // given out
128  virtual ::uhd::rfnoc::noc_block_base::sptr
129  get_block_ref(const std::string& block_id, const size_t max_ref_count) = 0;
130 };
131 
132 } // namespace uhd
133 } // namespace gr
134 
135 #endif /* INCLUDED_GR_UHD_RFNOC_GRAPH_H */
Definition: rfnoc_graph.h:29
virtual ~rfnoc_graph()
Definition: rfnoc_graph.h:35
virtual void connect(const std::string &src_block, const std::string &dst_block, const bool skip_property_propagation=false)=0
Convenience overload: Defaults to port 0 on both blocks.
virtual void connect(const std::string &src_block, const size_t src_block_port, const std::string &dst_block, const size_t dst_block_port, const bool skip_property_propagation=false)=0
Connect two blocks, or a block to a streamer, or a streamer to a block.
virtual void set_time_source(const std::string &source, const size_t mb_index)=0
Set time source on the specified motherboard.
static sptr make(const ::uhd::device_addr_t &dev_addr)
virtual void commit()=0
Commit the graph and run initial checks.
std::shared_ptr< rfnoc_graph > sptr
Definition: rfnoc_graph.h:31
virtual ::uhd::rx_streamer::sptr create_rx_streamer(const size_t num_ports, const ::uhd::stream_args_t &args)=0
Create an RX streamer.
virtual std::string get_block_id(const std::string &block_name, const int device_select, const int block_select)=0
virtual ::uhd::tx_streamer::sptr create_tx_streamer(const size_t num_ports, const ::uhd::stream_args_t &args)=0
Create a TX streamer.
virtual void set_clock_source(const std::string &source, const size_t mb_index)=0
Set clock source on the specified motherboard.
virtual ::uhd::rfnoc::noc_block_base::sptr get_block_ref(const std::string &block_id, const size_t max_ref_count)=0
Return a reference to the block with a given block ID.
#define GR_UHD_API
Definition: gr-uhd/include/gnuradio/uhd/api.h:18
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:29