// // Copyright 2021 Ettus Research, a National Instruments Brand // // SPDX-License-Identifier: GPL-3.0-or-later // #pragma once #include #include #include #include #include #include #include namespace uhd { namespace rfnoc { namespace rf_control { /*! Interface for setting and getting the current antenna. */ class antenna_iface { public: using sptr = std::shared_ptr; virtual ~antenna_iface() = default; /*! Return a list of valid antenna for channel \p chan. * * \return The selected antenna. */ virtual std::vector 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; /*! 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& possible_antennas, const std::unordered_map& compat_map); virtual ~enumerated_antenna() = default; std::vector 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 _possible_antennas; const std::unordered_map& _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 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 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