Statistics
| Branch: | Tag: | Revision:

root / host / lib / usrp / dboard_base.cpp @ 5a678852

History | View | Annotate | Download (3.44 KB)

1
//
2
// Copyright 2010-2011 Ettus Research LLC
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
//
17

    
18
#include "dboard_ctor_args.hpp"
19
#include <uhd/usrp/dboard_base.hpp>
20
#include <boost/format.hpp>
21
#include <stdexcept>
22

    
23
using namespace uhd;
24
using namespace uhd::usrp;
25

    
26
/***********************************************************************
27
 * dboard_base dboard dboard_base class
28
 **********************************************************************/
29
struct dboard_base::impl{
30
    dboard_ctor_args_t args;
31
};
32

    
33
dboard_base::dboard_base(ctor_args_t args){
34
    _impl = UHD_PIMPL_MAKE(impl, ());
35
    _impl->args = *static_cast<dboard_ctor_args_t *>(args);
36
}
37

    
38
std::string dboard_base::get_subdev_name(void){
39
    return _impl->args.sd_name;
40
}
41

    
42
dboard_iface::sptr dboard_base::get_iface(void){
43
    return _impl->args.db_iface;
44
}
45

    
46
dboard_id_t dboard_base::get_rx_id(void){
47
    return _impl->args.rx_id;
48
}
49

    
50
dboard_id_t dboard_base::get_tx_id(void){
51
    return _impl->args.tx_id;
52
}
53

    
54
property_tree::sptr dboard_base::get_rx_subtree(void){
55
    return _impl->args.rx_subtree;
56
}
57

    
58
property_tree::sptr dboard_base::get_tx_subtree(void){
59
    return _impl->args.tx_subtree;
60
}
61

    
62
/***********************************************************************
63
 * xcvr dboard dboard_base class
64
 **********************************************************************/
65
xcvr_dboard_base::xcvr_dboard_base(ctor_args_t args) : dboard_base(args){
66
    if (get_rx_id() == dboard_id_t::none()){
67
        throw uhd::runtime_error(str(boost::format(
68
            "cannot create xcvr board when the rx id is \"%s\""
69
        ) % dboard_id_t::none().to_pp_string()));
70
    }
71
    if (get_tx_id() == dboard_id_t::none()){
72
        throw uhd::runtime_error(str(boost::format(
73
            "cannot create xcvr board when the tx id is \"%s\""
74
        ) % dboard_id_t::none().to_pp_string()));
75
    }
76
}
77

    
78
/***********************************************************************
79
 * rx dboard dboard_base class
80
 **********************************************************************/
81
rx_dboard_base::rx_dboard_base(ctor_args_t args) : dboard_base(args){
82
    if (get_tx_id() != dboard_id_t::none()){
83
        throw uhd::runtime_error(str(boost::format(
84
            "cannot create rx board when the tx id is \"%s\""
85
            " -> expected a tx id of \"%s\""
86
        ) % get_tx_id().to_pp_string() % dboard_id_t::none().to_pp_string()));
87
    }
88
}
89

    
90
/***********************************************************************
91
 * tx dboard dboard_base class
92
 **********************************************************************/
93
tx_dboard_base::tx_dboard_base(ctor_args_t args) : dboard_base(args){
94
    if (get_rx_id() != dboard_id_t::none()){
95
        throw uhd::runtime_error(str(boost::format(
96
            "cannot create tx board when the rx id is \"%s\""
97
            " -> expected a rx id of \"%s\""
98
        ) % get_rx_id().to_pp_string() % dboard_id_t::none().to_pp_string()));
99
    }
100
}