USRP Hardware Driver and USRP Manual Version: 4.2.0.0
UHD and USRP Manual
rfnoc_graph.hpp
Go to the documentation of this file.
1//
2// Copyright 2019 Ettus Research, a National Instruments Brand
3//
4// SPDX-License-Identifier: GPL-3.0-or-later
5//
6
7#pragma once
8
9#include <uhd/config.hpp>
13#include <uhd/stream.hpp>
18#include <boost/units/detail/utility.hpp> // for demangle
19#include <memory>
20#include <vector>
21
22namespace uhd { namespace rfnoc {
23
24class mb_controller;
25
32class UHD_API rfnoc_graph : public uhd::noncopyable, public std::enable_shared_from_this<rfnoc_graph>
33{
34public:
38 using sptr = std::shared_ptr<rfnoc_graph>;
39
40 virtual ~rfnoc_graph() {}
41
42 /******************************************
43 * Factory
44 ******************************************/
53 static sptr make(const device_addr_t& dev_addr);
54
55 /******************************************
56 * Block Discovery/Retrieval
57 ******************************************/
77 virtual std::vector<block_id_t> find_blocks(
78 const std::string& block_id_hint) const = 0;
79
82 template <typename T>
83 std::vector<block_id_t> find_blocks(const std::string& block_id_hint) const
84 {
85 std::vector<block_id_t> all_block_ids = find_blocks(block_id_hint);
86 std::vector<block_id_t> filt_block_ids;
87 for (size_t i = 0; i < all_block_ids.size(); i++) {
88 if (has_block<T>(all_block_ids[i])) {
89 filt_block_ids.push_back(all_block_ids[i]);
90 }
91 }
92 return filt_block_ids;
93 }
94
101 virtual bool has_block(const block_id_t& block_id) const = 0;
102
108 template <typename T>
109 bool has_block(const block_id_t& block_id) const
110 {
111 return has_block(block_id)
112 && bool(std::dynamic_pointer_cast<T>(get_block(block_id)));
113 }
114
123 virtual noc_block_base::sptr get_block(const block_id_t& block_id) const = 0;
124
139 template <typename T>
140 std::shared_ptr<T> get_block(const block_id_t& block_id) const
141 {
142 std::shared_ptr<T> blk = std::dynamic_pointer_cast<T>(get_block(block_id));
143 if (blk) {
144 return blk;
145 } else {
146 throw uhd::lookup_error(
147 std::string("This device does not have a block of type ")
148 + boost::units::detail::demangle(typeid(T).name())
149 + " with ID: " + block_id.to_string());
150 }
151 }
152
153 /**************************************************************************
154 * Connection APIs
155 *************************************************************************/
164 virtual bool is_connectable(const block_id_t& src_blk,
165 size_t src_port,
166 const block_id_t& dst_blk,
167 size_t dst_port) = 0;
168
188 virtual void connect(const block_id_t& src_blk,
189 size_t src_port,
190 const block_id_t& dst_blk,
191 size_t dst_port,
192 bool skip_property_propagation = false) = 0;
193
205 virtual void connect(uhd::tx_streamer::sptr streamer,
206 size_t strm_port,
207 const block_id_t& dst_blk,
208 size_t dst_port,
209 uhd::transport::adapter_id_t adapter_id = uhd::transport::NULL_ADAPTER_ID) = 0;
210
222 virtual void connect(const block_id_t& src_blk,
223 size_t src_port,
224 uhd::rx_streamer::sptr streamer,
225 size_t strm_port,
226 uhd::transport::adapter_id_t adapter_id = uhd::transport::NULL_ADAPTER_ID) = 0;
227
241 virtual void disconnect(const block_id_t& src_blk,
242 size_t src_port,
243 const block_id_t& dst_blk,
244 size_t dst_port) = 0;
245
255 virtual void disconnect(const std::string& streamer_id) = 0;
256
267 virtual void disconnect(const std::string& streamer_id, size_t port) = 0;
268
278 virtual std::vector<uhd::transport::adapter_id_t> enumerate_adapters_from_src(
279 const block_id_t& src_blk, size_t src_port) = 0;
280
290 virtual std::vector<uhd::transport::adapter_id_t> enumerate_adapters_to_dst(
291 const block_id_t& dst_blk, size_t dst_port) = 0;
292
302 virtual std::vector<graph_edge_t> enumerate_static_connections() const = 0;
303
311 virtual std::vector<graph_edge_t> enumerate_active_connections() = 0;
312
320 virtual void commit() = 0;
321
327 virtual void release() = 0;
328
329 /******************************************
330 * Streaming
331 ******************************************/
332
344 const size_t num_ports, const stream_args_t& args) = 0;
345
357 const size_t num_ports, const stream_args_t& args) = 0;
358
359 /**************************************************************************
360 * Hardware Control
361 *************************************************************************/
362 virtual size_t get_num_mboards() const = 0;
364 //
365 // See also uhd::rfnoc::mb_controller
366 virtual std::shared_ptr<mb_controller> get_mb_controller(
367 const size_t mb_index = 0) = 0;
368
390 const uhd::time_spec_t& time_spec, const bool quiet) = 0;
391
393 virtual uhd::property_tree::sptr get_tree(void) const = 0;
394}; // class rfnoc_graph
395
396}}; // namespace uhd::rfnoc
Definition: device_addr.hpp:38
std::shared_ptr< property_tree > sptr
Definition: property_tree.hpp:222
Definition: block_id.hpp:40
std::string to_string() const
Return a string like this: "0/FFT#1" (includes all components, if set)
std::shared_ptr< noc_block_base > sptr
Definition: noc_block_base.hpp:48
Definition: rfnoc_graph.hpp:33
virtual void commit()=0
virtual void disconnect(const std::string &streamer_id, size_t port)=0
virtual size_t get_num_mboards() const =0
bool has_block(const block_id_t &block_id) const
Definition: rfnoc_graph.hpp:109
virtual std::vector< uhd::transport::adapter_id_t > enumerate_adapters_from_src(const block_id_t &src_blk, size_t src_port)=0
virtual ~rfnoc_graph()
Definition: rfnoc_graph.hpp:40
virtual void release()=0
virtual std::vector< uhd::transport::adapter_id_t > enumerate_adapters_to_dst(const block_id_t &dst_blk, size_t dst_port)=0
virtual void connect(uhd::tx_streamer::sptr streamer, size_t strm_port, const block_id_t &dst_blk, size_t dst_port, uhd::transport::adapter_id_t adapter_id=uhd::transport::NULL_ADAPTER_ID)=0
virtual bool is_connectable(const block_id_t &src_blk, size_t src_port, const block_id_t &dst_blk, size_t dst_port)=0
virtual std::vector< graph_edge_t > enumerate_static_connections() const =0
virtual tx_streamer::sptr create_tx_streamer(const size_t num_ports, const stream_args_t &args)=0
virtual std::shared_ptr< mb_controller > get_mb_controller(const size_t mb_index=0)=0
Return a reference to a motherboard controller.
virtual void connect(const block_id_t &src_blk, size_t src_port, uhd::rx_streamer::sptr streamer, size_t strm_port, uhd::transport::adapter_id_t adapter_id=uhd::transport::NULL_ADAPTER_ID)=0
virtual bool has_block(const block_id_t &block_id) const =0
Checks if a specific NoC block exists on the device.
std::shared_ptr< T > get_block(const block_id_t &block_id) const
Definition: rfnoc_graph.hpp:140
virtual rx_streamer::sptr create_rx_streamer(const size_t num_ports, const stream_args_t &args)=0
virtual void disconnect(const block_id_t &src_blk, size_t src_port, const block_id_t &dst_blk, size_t dst_port)=0
virtual noc_block_base::sptr get_block(const block_id_t &block_id) const =0
Returns a block controller class for an NoC block.
virtual std::vector< block_id_t > find_blocks(const std::string &block_id_hint) const =0
virtual void connect(const block_id_t &src_blk, size_t src_port, const block_id_t &dst_blk, size_t dst_port, bool skip_property_propagation=false)=0
virtual uhd::property_tree::sptr get_tree(void) const =0
Return a reference to the property tree.
std::vector< block_id_t > find_blocks(const std::string &block_id_hint) const
Definition: rfnoc_graph.hpp:83
static sptr make(const device_addr_t &dev_addr)
virtual void disconnect(const std::string &streamer_id)=0
virtual bool synchronize_devices(const uhd::time_spec_t &time_spec, const bool quiet)=0
std::shared_ptr< rfnoc_graph > sptr
Definition: rfnoc_graph.hpp:38
virtual std::vector< graph_edge_t > enumerate_active_connections()=0
std::shared_ptr< rx_streamer > sptr
Definition: stream.hpp:169
Definition: time_spec.hpp:31
std::shared_ptr< tx_streamer > sptr
Definition: stream.hpp:267
#define UHD_API
Definition: config.h:87
size_t adapter_id_t
Host transport adapter ID.
Definition: adapter_id.hpp:14
Definition: build_info.hpp:12
boost::noncopyable noncopyable
Definition: noncopyable.hpp:45
Definition: exception.hpp:59
Definition: stream.hpp:48