UHD  003.004.004-release
include/uhd/usrp/multi_usrp.hpp
Go to the documentation of this file.
00001 //
00002 // Copyright 2010-2011 Ettus Research LLC
00003 //
00004 // This program is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 #ifndef INCLUDED_UHD_USRP_MULTI_USRP_HPP
00019 #define INCLUDED_UHD_USRP_MULTI_USRP_HPP
00020 
00021 //define API capabilities for compile time detection of new features
00022 #define UHD_USRP_MULTI_USRP_REF_SOURCES_API
00023 #define UHD_USRP_MULTI_USRP_GET_RATES_API
00024 #define UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
00025 #define UHD_USRP_MULTI_USRP_COMMAND_TIME_API
00026 #define UHD_USRP_MULTI_USRP_BW_RANGE_API
00027 #define UHD_USRP_MULTI_USRP_USER_REGS_API
00028 
00029 #include <uhd/config.hpp>
00030 #include <uhd/device.hpp>
00031 #include <uhd/deprecated.hpp>
00032 #include <uhd/types/ranges.hpp>
00033 #include <uhd/types/stream_cmd.hpp>
00034 #include <uhd/types/tune_request.hpp>
00035 #include <uhd/types/tune_result.hpp>
00036 #include <uhd/types/sensors.hpp>
00037 #include <uhd/usrp/subdev_spec.hpp>
00038 #include <uhd/usrp/dboard_iface.hpp>
00039 #include <boost/shared_ptr.hpp>
00040 #include <boost/utility.hpp>
00041 #include <complex>
00042 #include <string>
00043 #include <vector>
00044 
00045 namespace uhd{ namespace usrp{
00046 
00093 class UHD_API multi_usrp : boost::noncopyable{
00094 public:
00095     typedef boost::shared_ptr<multi_usrp> sptr;
00096 
00098     static const size_t ALL_MBOARDS = size_t(~0);
00099 
00101     static const size_t ALL_CHANS = size_t(~0);
00102 
00104     static const std::string ALL_GAINS;
00105 
00111     static sptr make(const device_addr_t &dev_addr);
00112 
00118     virtual device::sptr get_device(void) = 0;
00119 
00121     rx_streamer::sptr get_rx_stream(const stream_args_t &args){
00122         return this->get_device()->get_rx_stream(args);
00123     }
00124 
00126     tx_streamer::sptr get_tx_stream(const stream_args_t &args){
00127         return this->get_device()->get_tx_stream(args);
00128     }
00129 
00130     /*******************************************************************
00131      * Mboard methods
00132      ******************************************************************/
00133 
00144     virtual void set_master_clock_rate(double rate, size_t mboard = ALL_MBOARDS) = 0;
00145 
00151     virtual double get_master_clock_rate(size_t mboard = 0) = 0;
00152 
00157     virtual std::string get_pp_string(void) = 0;
00158 
00164     virtual std::string get_mboard_name(size_t mboard = 0) = 0;
00165 
00171     virtual time_spec_t get_time_now(size_t mboard = 0) = 0;
00172 
00178     virtual time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
00179 
00191     virtual void set_time_now(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
00192 
00205     virtual void set_time_next_pps(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
00206 
00222     virtual void set_time_unknown_pps(const time_spec_t &time_spec) = 0;
00223 
00230     virtual bool get_time_synchronized(void) = 0;
00231 
00242     virtual void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
00243 
00249     virtual void clear_command_time(size_t mboard = ALL_MBOARDS) = 0;
00250 
00263     virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t chan = ALL_CHANS) = 0;
00264 
00273     virtual void set_clock_config(const clock_config_t &clock_config, size_t mboard = ALL_MBOARDS) = 0;
00274 
00283     virtual void set_time_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
00284 
00290     virtual std::string get_time_source(const size_t mboard) = 0;
00291 
00297     virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
00298 
00306     virtual void set_clock_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
00307 
00313     virtual std::string get_clock_source(const size_t mboard) = 0;
00314 
00320     virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
00321 
00325     virtual size_t get_num_mboards(void) = 0;
00326 
00333     virtual sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
00334 
00340     virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
00341 
00349     virtual void set_user_register(const boost::uint8_t addr, const boost::uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
00350 
00351     /*******************************************************************
00352      * RX methods
00353      ******************************************************************/
00362     virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
00363 
00369     virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0;
00370 
00376     virtual size_t get_rx_num_channels(void) = 0;
00377 
00383     virtual std::string get_rx_subdev_name(size_t chan = 0) = 0;
00384 
00390     virtual void set_rx_rate(double rate, size_t chan = ALL_CHANS) = 0;
00391 
00397     virtual double get_rx_rate(size_t chan = 0) = 0;
00398 
00404     virtual meta_range_t get_rx_rates(size_t chan = 0) = 0;
00405 
00412     virtual tune_result_t set_rx_freq(
00413         const tune_request_t &tune_request, size_t chan = 0
00414     ) = 0;
00415 
00421     virtual double get_rx_freq(size_t chan = 0) = 0;
00422 
00428     virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
00429 
00437     virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
00438 
00440     void set_rx_gain(double gain, size_t chan = 0){
00441         return this->set_rx_gain(gain, ALL_GAINS, chan);
00442     }
00443 
00451     virtual double get_rx_gain(const std::string &name, size_t chan = 0) = 0;
00452 
00454     double get_rx_gain(size_t chan = 0){
00455         return this->get_rx_gain(ALL_GAINS, chan);
00456     }
00457 
00465     virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan = 0) = 0;
00466 
00468     gain_range_t get_rx_gain_range(size_t chan = 0){
00469         return this->get_rx_gain_range(ALL_GAINS, chan);
00470     }
00471 
00478     virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
00479 
00485     virtual void set_rx_antenna(const std::string &ant, size_t chan = 0) = 0;
00486 
00492     virtual std::string get_rx_antenna(size_t chan = 0) = 0;
00493 
00499     virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0;
00500 
00506     UHD_DEPRECATED bool get_rx_lo_locked(size_t chan = 0){
00507         return this->get_rx_sensor("lo_locked", chan).to_bool();
00508     }
00509 
00515     virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0;
00516 
00522     virtual double get_rx_bandwidth(size_t chan = 0) = 0;
00523 
00529     virtual meta_range_t get_rx_bandwidth_range(size_t chan = 0) = 0;
00530 
00537     UHD_DEPRECATED double read_rssi(size_t chan = 0){
00538         return this->get_rx_sensor("rssi", chan).to_real();
00539     }
00540 
00548     virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0;
00549 
00556     virtual sensor_value_t get_rx_sensor(const std::string &name, size_t chan = 0) = 0;
00557 
00563     virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0;
00564 
00577     virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0;
00578 
00586     virtual void set_rx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
00587 
00595     virtual void set_rx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
00596 
00597     /*******************************************************************
00598      * TX methods
00599      ******************************************************************/
00608     virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
00609 
00615     virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0;
00616 
00622     virtual size_t get_tx_num_channels(void) = 0;
00623 
00629     virtual std::string get_tx_subdev_name(size_t chan = 0) = 0;
00630 
00636     virtual void set_tx_rate(double rate, size_t chan = ALL_CHANS) = 0;
00637 
00643     virtual double get_tx_rate(size_t chan = 0) = 0;
00644 
00650     virtual meta_range_t get_tx_rates(size_t chan = 0) = 0;
00651 
00658     virtual tune_result_t set_tx_freq(
00659         const tune_request_t &tune_request, size_t chan = 0
00660     ) = 0;
00661 
00667     virtual double get_tx_freq(size_t chan = 0) = 0;
00668 
00674     virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
00675 
00683     virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
00684 
00686     void set_tx_gain(double gain, size_t chan = 0){
00687         return this->set_tx_gain(gain, ALL_GAINS, chan);
00688     }
00689 
00697     virtual double get_tx_gain(const std::string &name, size_t chan = 0) = 0;
00698 
00700     double get_tx_gain(size_t chan = 0){
00701         return this->get_tx_gain(ALL_GAINS, chan);
00702     }
00703 
00711     virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan = 0) = 0;
00712 
00714     gain_range_t get_tx_gain_range(size_t chan = 0){
00715         return this->get_tx_gain_range(ALL_GAINS, chan);
00716     }
00717 
00724     virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
00725 
00731     virtual void set_tx_antenna(const std::string &ant, size_t chan = 0) = 0;
00732 
00738     virtual std::string get_tx_antenna(size_t chan = 0) = 0;
00739 
00745     virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0;
00746 
00752     UHD_DEPRECATED bool get_tx_lo_locked(size_t chan = 0){
00753         return this->get_tx_sensor("lo_locked", chan).to_bool();
00754     }
00755 
00761     virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0;
00762 
00768     virtual double get_tx_bandwidth(size_t chan = 0) = 0;
00769 
00775     virtual meta_range_t get_tx_bandwidth_range(size_t chan = 0) = 0;
00776 
00784     virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0;
00785 
00792     virtual sensor_value_t get_tx_sensor(const std::string &name, size_t chan = 0) = 0;
00793 
00799     virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0;
00800 
00807     virtual void set_tx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
00808 
00816     virtual void set_tx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
00817 
00818 };
00819 
00820 }}
00821 
00822 #endif /* INCLUDED_UHD_USRP_MULTI_USRP_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines