GNU Radio Manual and C++ API Reference 3.10.5.1
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/rfnoc_graph.hpp>
15#include <uhd/stream.hpp>
16#include <uhd/types/device_addr.hpp>
17#include <memory>
18
19namespace gr {
20namespace uhd {
21
22class rfnoc_block;
23
24/*! GNU Radio-specific wrapper for uhd::rfnoc::rfnoc_graph
25 *
26 * This wraps uhd::rfnoc::rfnoc_graph for simpler insertion into GNU Radio flow
27 * graphs. All API calls match those on said class.
28 */
30{
31public:
32 using sptr = std::shared_ptr<rfnoc_graph>;
33
34 static const size_t NULL_ADAPTER_ID =
35 static_cast<size_t>(::uhd::transport::NULL_ADAPTER_ID);
36
37 static sptr make(const ::uhd::device_addr_t& dev_addr);
38
39 virtual ~rfnoc_graph() {}
40
41 //! Connect two blocks, or a block to a streamer, or a streamer to a block
42 //
43 // \param src_block The block ID of the source block (e.g., "0/Radio#0)
44 // \param src_block_port The port on the source block to connect to
45 // \param dst_block The block ID of the destination block (e.g., "0/DDC#0)
46 // \param dst_block_port The port on the destination block to connect to
47 // \param skip_property_propagation Disable property propagation on this
48 // connection (see the UHD documentation)
49 virtual void connect(const std::string& src_block,
50 const size_t src_block_port,
51 const std::string& dst_block,
52 const size_t dst_block_port,
53 const bool skip_property_propagation = false) = 0;
54
55 //! Convenience overload: Defaults to port 0 on both blocks
56 //
57 // \param src_block The block ID of the source block (e.g., "0/Radio#0)
58 // \param dst_block The block ID of the destination block (e.g., "0/DDC#0)
59 // \param skip_property_propagation Disable property propagation on this
60 // connection (see the UHD documentation)
61 virtual void connect(const std::string& src_block,
62 const std::string& dst_block,
63 const bool skip_property_propagation = false) = 0;
64
65 //! Create an RX streamer
66 //
67 // Note: This streamer is not connected to anything after creation.
68 //
69 // See also the UHD documentation for uhd::rfnoc::rfnoc_graph::create_rx_streamer().
70 //
71 // \param num_ports Number of streaming ports
72 // \param args Stream args.
73 virtual ::uhd::rx_streamer::sptr
74 create_rx_streamer(const size_t num_ports, const ::uhd::stream_args_t& args) = 0;
75
76 //! Create a TX streamer
77 //
78 // Note: This streamer is not connected to anything after creation.
79 //
80 // See also the UHD documentation for uhd::rfnoc::rfnoc_graph::create_tx_streamer().
81 //
82 // \param num_ports Number of streaming ports
83 // \param args Stream args.
84 virtual ::uhd::tx_streamer::sptr
85 create_tx_streamer(const size_t num_ports, const ::uhd::stream_args_t& args) = 0;
86
87 //! Set the desired adapter ID for a streamer connection
88 //
89 // If it is desired to connect a streamer to the device using a specific
90 // adapter ID, this method needs to be called before calling connect().
91 //
92 // For more detail on adapter IDs, see the UHD documentation (e.g.,
93 // ::uhd::rfnoc::rfnoc_graph::connect()). Note that this does not have a
94 // corresponding API call in UHD: There, the connect() call is atomic and
95 // takes the adapter ID as an argument. The reason this is different in the
96 // GNU Radio implementation is that this makes it much easier to generate
97 // code from GRC for C++ and Python. It reduces the number of connect calls
98 // down to 1 (from 3 in UHD) and allows the streamer blocks to set this
99 // property on the streamer-edges before connect calls are made later on.
100 virtual void set_streamer_adapter_id(const std::string& stream_block_id,
101 const size_t port,
102 const size_t adapter_id) = 0;
103
104 //! Commit the graph and run initial checks
105 //
106 // See ::uhd::rfnoc::rfnoc_graph::commit() for more documentation.
107 virtual void commit() = 0;
108
109 /*! Return a valid block ID string, if it exists, or an empty string, if not
110 *
111 * This will check the available blocks on the connected devices and see if
112 * they match the block name, device ID, and block number.
113 */
114 virtual std::string get_block_id(const std::string& block_name,
115 const int device_select,
116 const int block_select) = 0;
117
118 //! Set time source on the specified motherboard
119 //
120 // Note: This is a convenience call, it directly dereferences the underlying
121 // motherboard controller.
122 //
123 // \param source Time source (e.g., "internal")
124 // \param mb_index Motherboard index, starting at 0
125 virtual void set_time_source(const std::string& source, const size_t mb_index) = 0;
126
127 //! Set clock source on the specified motherboard
128 //
129 // Note: This is a convenience call, it directly dereferences the underlying
130 // motherboard controller.
131 //
132 // \param source Clock source (e.g., "internal")
133 // \param mb_index Motherboard index, starting at 0
134 virtual void set_clock_source(const std::string& source, const size_t mb_index) = 0;
135
136 //! Return a reference to the block with a given block ID
137 //
138 // This allows to retrieve a shared pointer to a block controller with a
139 // limit. It keeps track of the references given out, and will throw an
140 // exception if called more than max_ref_count times. This is to help ensure
141 // that GNU Radio blocks don't share block controllers unintentionally.
142 //
143 // \param block_id A valid block ID. Use get_block_id() to make sure it is
144 // valid.
145 // \param max_ref_count The maximum number of references that are doled out.
146 //
147 // \throws std::runtime_error if more than \p max_ref_count references are
148 // given out
149 virtual ::uhd::rfnoc::noc_block_base::sptr
150 get_block_ref(const std::string& block_id, const size_t max_ref_count) = 0;
151};
152
153} // namespace uhd
154} // namespace gr
155
156#endif /* INCLUDED_GR_UHD_RFNOC_GRAPH_H */
Definition: rfnoc_graph.h:30
virtual ~rfnoc_graph()
Definition: rfnoc_graph.h:39
virtual void set_streamer_adapter_id(const std::string &stream_block_id, const size_t port, const size_t adapter_id)=0
Set the desired adapter ID for a streamer connection.
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:32
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.
Definition: basic_block.h:29