Minor cleanup
[debian/gnuradio] / gr-usrp2 / src / usrp2.i
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2008 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 %feature("autodoc", "1");               // generate python docstrings
24
25 %include "exception.i"
26 %import "gnuradio.i"                    // the common stuff
27
28 %{
29 #include <gnuradio_swig_bug_workaround.h>
30 #include "usrp2_source_16sc.h"
31 #include "usrp2_source_32fc.h"
32 #include "usrp2_sink_16sc.h"
33 #include "usrp2_sink_32fc.h"
34 %}
35
36 %include <usrp2/tune_result.h>
37
38 // ----------------------------------------------------------------
39
40 class usrp2_base : public gr_sync_block 
41 {
42 protected:
43   usrp2_base() throw (std::runtime_error);
44
45 public:
46   ~usrp2_base();
47
48   std::string mac_addr() const;
49 };
50
51 // ----------------------------------------------------------------
52
53 class usrp2_source_base : public usrp2_base 
54 {
55 protected:
56   usrp2_source_base() throw (std::runtime_error);
57
58 public:
59   ~usrp2_source_base();
60
61   bool set_gain(double gain);
62   %rename(_real_set_center_freq) set_center_freq;
63   bool set_center_freq(double frequency, usrp2::tune_result *r);
64   bool set_decim(int decimation_factor);
65 };
66
67 // ----------------------------------------------------------------
68
69 GR_SWIG_BLOCK_MAGIC(usrp2,source_32fc)
70
71 usrp2_source_32fc_sptr
72 usrp2_make_source_32fc(const std::string ifc="eth0", 
73                        const std::string mac="") 
74   throw (std::runtime_error);
75
76 class usrp2_source_32fc : public usrp2_source_base 
77 {
78 protected:
79   usrp2_source_32fc(const std::string &ifc, const std::string &mac);
80
81 public:
82   ~usrp2_source_32fc();
83 };
84
85 // ----------------------------------------------------------------
86
87 GR_SWIG_BLOCK_MAGIC(usrp2,source_16sc)
88
89 usrp2_source_16sc_sptr
90 usrp2_make_source_16sc(const std::string ifc="eth0", 
91                        const std::string mac="") 
92   throw (std::runtime_error);
93
94 class usrp2_source_16sc : public usrp2_source_base 
95 {
96 protected:
97   usrp2_source_16sc(const std::string &ifc, const std::string &mac);
98
99 public:
100   ~usrp2_source_16sc();
101 };
102
103 // ----------------------------------------------------------------
104
105 class usrp2_sink_base : public usrp2_base 
106 {
107 protected:
108   usrp2_sink_base() throw (std::runtime_error);
109
110 public:
111   ~usrp2_sink_base();
112
113   bool set_gain(double gain);
114   %rename(_real_set_center_freq) set_center_freq;
115   bool set_center_freq(double frequency, usrp2::tune_result *r);
116   bool set_interp(int interp_factor);
117 };
118
119 // ----------------------------------------------------------------
120
121 GR_SWIG_BLOCK_MAGIC(usrp2,sink_32fc)
122
123 usrp2_sink_32fc_sptr
124 usrp2_make_sink_32fc(const std::string ifc="eth0", 
125                      const std::string mac="") 
126   throw (std::runtime_error);
127
128 class usrp2_sink_32fc : public usrp2_sink_base 
129 {
130 protected:
131   usrp2_sink_32fc(const std::string &ifc, const std::string &mac);
132
133 public:
134   ~usrp2_sink_32fc();
135 };
136
137 // ----------------------------------------------------------------
138
139 GR_SWIG_BLOCK_MAGIC(usrp2,sink_16sc)
140
141 usrp2_sink_16sc_sptr
142 usrp2_make_sink_16sc(const std::string ifc="eth0", 
143                      const std::string mac="") 
144   throw (std::runtime_error);
145
146 class usrp2_sink_16sc : public usrp2_sink_base 
147 {
148 protected:
149   usrp2_sink_16sc(const std::string &ifc, const std::string &mac);
150
151 public:
152   ~usrp2_sink_16sc();
153 };
154
155 // ----------------------------------------------------------------
156
157 // create a more pythonic interface
158 %pythoncode %{
159
160 def __set_center_freq(self, freq):
161   tr = tune_result()
162   r = self._real_set_center_freq(freq, tr)
163   if r:
164     return tr
165   else:
166     return None
167
168 usrp2_source_32fc_sptr.set_center_freq = __set_center_freq
169 usrp2_source_16sc_sptr.set_center_freq = __set_center_freq
170 usrp2_sink_32fc_sptr.set_center_freq = __set_center_freq
171 usrp2_sink_16sc_sptr.set_center_freq = __set_center_freq
172 %}