aboutsummaryrefslogtreecommitdiffstats
path: root/host/include/uhd/simple_device.hpp
blob: 64ec85a5ca01ea368f60382314e75231bc4f626e (plain)
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
103
104
105
106
107
108
109
110
111
//
// Copyright 2010 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//

#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
#include <uhd/device.hpp>
#include <vector>

#ifndef INCLUDED_UHD_SIMPLE_DEVICE_HPP
#define INCLUDED_UHD_SIMPLE_DEVICE_HPP

namespace uhd{

/*!
 * The tune result struct holds result of a 2-phase tuning:
 * The struct hold the result of tuning the dboard as
 * the target and actual intermediate frequency.
 * The struct hold the result of tuning the DDC/DUC as
 * the target and actual digital converter frequency.
 * It also tell us weather or not the spectrum is inverted.
 */
struct tune_result_t{
    double target_inter_freq;
    double actual_inter_freq;
    double target_dxc_freq;
    double actual_dxc_freq;
    bool spectrum_inverted;
    tune_result_t(void);
};

/*!
 * The simple UHD device class:
 * A simple device facilitates ease-of-use for most use-case scenarios.
 * The wrapper provides convenience functions to tune the devices
 * as well as to set the dboard gains, antennas, and other properties.
 */
class simple_device : boost::noncopyable{
public:
    typedef boost::shared_ptr<simple_device> sptr;
    static sptr make(const std::string &args);

    virtual device::sptr get_device(void) = 0;

    virtual std::string get_name(void) = 0;

    /*******************************************************************
     * Streaming
     ******************************************************************/
    virtual void set_streaming(bool enb) = 0;
    virtual bool get_streaming(void) = 0;

    /*******************************************************************
     * RX methods
     ******************************************************************/
    virtual void set_rx_rate(double rate) = 0;
    virtual double get_rx_rate(void) = 0;
    virtual std::vector<double> get_rx_rates(void) = 0;

    virtual tune_result_t set_rx_freq(double target_freq, double lo_offset) = 0;
    virtual double get_rx_freq_min(void) = 0;
    virtual double get_rx_freq_max(void) = 0;

    virtual void set_rx_gain(float gain) = 0;
    virtual float get_rx_gain(void) = 0;
    virtual float get_rx_gain_min(void) = 0;
    virtual float get_rx_gain_max(void) = 0;
    virtual float get_rx_gain_step(void) = 0;

    virtual void set_rx_antenna(const std::string &ant) = 0;
    virtual std::string get_rx_antenna(void) = 0;
    virtual std::vector<std::string> get_rx_antennas(void) = 0;

    /*******************************************************************
     * TX methods
     ******************************************************************/
    virtual void set_tx_rate(double rate) = 0;
    virtual double get_tx_rate(void) = 0;
    virtual std::vector<double> get_tx_rates(void) = 0;

    virtual tune_result_t set_tx_freq(double target_freq, double lo_offset) = 0;
    virtual double get_tx_freq_min(void) = 0;
    virtual double get_tx_freq_max(void) = 0;

    virtual void set_tx_gain(float gain) = 0;
    virtual float get_tx_gain(void) = 0;
    virtual float get_tx_gain_min(void) = 0;
    virtual float get_tx_gain_max(void) = 0;
    virtual float get_tx_gain_step(void) = 0;

    virtual void set_tx_antenna(const std::string &ant) = 0;
    virtual std::string get_tx_antenna(void) = 0;
    virtual std::vector<std::string> get_tx_antennas(void) = 0;
};

} //namespace uhd

#endif /* INCLUDED_UHD_SIMPLE_DEVICE_HPP */