Imported Upstream version 3.2.2
[debian/gnuradio] / usrp / host / lib / legacy / db_base.i
1 /* -*- c++ -*- */
2 //
3 // Copyright 2008,2009 Free Software Foundation, Inc.
4 // 
5 // This file is part of GNU Radio
6 // 
7 // GNU Radio is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3, or (at your option)
10 // any later version.
11 // 
12 // GNU Radio is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 // 
17 // You should have received a copy of the GNU General Public License
18 // along with GNU Radio; see the file COPYING.  If not, write to
19 // the Free Software Foundation, Inc., 51 Franklin Street,
20 // Boston, MA 02110-1301, USA.
21 //
22
23
24 %{
25 #include "db_base.h"
26 %}
27
28 %include <gr_shared_ptr.i>
29
30 class usrp_tune_result
31 {
32 public:  
33   usrp_tune_result(double baseband=0, double dxc=0, 
34                    double residual=0, bool inv=0);
35   ~usrp_tune_result();
36
37   double baseband_freq;
38   double dxc_freq;
39   double residual_freq;
40   bool  inverted;
41 };
42
43 struct freq_result_t
44 {
45   bool  ok;
46   double baseband_freq;
47 };
48
49 class db_base
50 {
51  private:
52   db_base(boost::shared_ptr<usrp_basic> usrp, int which);
53
54  public:
55   virtual ~db_base();
56
57   int dbid();
58   std::string name();
59   std::string side_and_name();
60   int which() { return d_which; }
61
62   bool bypass_adc_buffers(bool bypass);
63   bool set_atr_mask(int v);
64   bool set_atr_txval(int v);
65   bool set_atr_rxval(int v);
66   bool set_atr_tx_delay(int v);
67   bool set_atr_rx_delay(int v);
68   bool set_lo_offset(double offset);
69   double lo_offset() { return d_lo_offset; }
70
71   virtual float gain_min() = 0;
72   virtual float gain_max() = 0;
73   virtual float gain_db_per_step() = 0;
74   virtual double freq_min() = 0;
75   virtual double freq_max() = 0;
76   virtual struct freq_result_t set_freq(double target_freq) = 0;
77   virtual bool set_gain(float gain) = 0;
78   virtual bool is_quadrature() = 0;
79   virtual bool i_and_q_swapped();
80   virtual bool spectrum_inverted();
81   virtual bool set_enable(bool on);
82   virtual bool set_auto_tr(bool on);
83   virtual bool select_rx_antenna(int which_antenna);
84   virtual bool select_rx_antenna(const std::string &antenna);
85   virtual bool set_bw(float bw);
86 };
87
88 // Create templates for db's, vectors of db's, and vector of vectors of db's
89 typedef boost::shared_ptr<db_base> db_base_sptr;
90 %template(db_base_sptr) boost::shared_ptr<db_base>;
91 %template(db_base_sptr_vector) std::vector<db_base_sptr>;
92 %template(db_base_sptr_vector_vector) std::vector<std::vector<db_base_sptr> >;
93
94 // Set better class name in Python
95 // Enable freq_range and gain_range from public methods of class not implemented in C++
96 // And create a dummy wrapper for backwards compatability with some of the example code
97 %pythoncode %{
98   db_base_sptr.__repr__ = lambda self: "<db_base::%s>" % (self.name(),)
99   db_base_sptr.freq_range = lambda self: (self.freq_min(), self.freq_max(), 1)
100   db_base_sptr.gain_range = lambda self: (self.gain_min(), self.gain_max(), self.gain_db_per_step())
101
102 %}