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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
//
// Copyright 2021 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
#pragma once
#include <uhd/property_tree.hpp>
#include <uhd/rfnoc/rf_control/core_iface.hpp>
#include <unordered_map>
#include <functional>
#include <memory>
#include <string>
#include <vector>
namespace uhd { namespace rfnoc { namespace rf_control {
/*! Interface for setting and getting the current antenna.
*/
class antenna_iface
{
public:
using sptr = std::shared_ptr<antenna_iface>;
virtual ~antenna_iface() = default;
/*! Return a list of valid antenna for channel \p chan.
*
* \return The selected antenna.
*/
virtual std::vector<std::string> get_antennas(const size_t chan) const = 0;
/*! Select antenna \p for channel \p chan.
*
* \throws uhd::value_error if \p ant is not a valid value.
*/
virtual void set_antenna(const std::string& ant, const size_t chan) = 0;
/*! Return the selected antenna for channel \p chan.
*
* \return The selected antenna.
*/
virtual std::string get_antenna(const size_t chan) const = 0;
};
/*! Class for getting and setting antennas out of an enumerated set, where
* the API calls for the antenna actually map to property nodes.
*/
class enumerated_antenna : public antenna_iface
{
public:
using prop_path = std::function<fs_path(const size_t chan)>;
/*! Constructs an enumerated_antenna class.
*
* \param tree The property tree the nodes are on
* \param prop_path_generator Closure to generate the property path given the channel.
* \param possible_antennas A vector of legal antennas.
* \param compat_map A map of alternative names for antennas.
*/
enumerated_antenna(uhd::property_tree::sptr tree,
prop_path prop_path_generator,
const std::vector<std::string>& possible_antennas,
const std::unordered_map<std::string, std::string>& compat_map);
virtual ~enumerated_antenna() = default;
std::vector<std::string> get_antennas(const size_t chan) const override;
void set_antenna(const std::string& ant, const size_t chan) override;
std::string get_antenna(const size_t chan) const override;
private:
// The property tree & node used to implement the API
uhd::property_tree::sptr _tree;
prop_path _prop_path_generator;
std::vector<std::string> _possible_antennas;
const std::unordered_map<std::string, std::string>& _compat_map;
};
/*! Partially implements core_iface for antenna, redirecting to one of two
* subobjects for RX or TX.
*/
class antenna_radio_control_mixin : virtual public core_iface
{
public:
virtual ~antenna_radio_control_mixin() = default;
std::string get_tx_antenna(const size_t chan) const override;
std::vector<std::string> get_tx_antennas(const size_t chan) const override;
void set_tx_antenna(const std::string& ant, const size_t chan) override;
std::string get_rx_antenna(const size_t chan) const override;
std::vector<std::string> get_rx_antennas(const size_t chan) const override;
void set_rx_antenna(const std::string& ant, const size_t chan) override;
protected:
antenna_iface::sptr _rx_antenna;
antenna_iface::sptr _tx_antenna;
};
}}} // namespace uhd::rfnoc::rf_control
|