GNU Radio's OsmoSDR Package
source_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012 Dimitri Stolnikov <horiz0n@gmx.net>
4  *
5  * GNU Radio is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3, or (at your option)
8  * any later version.
9  *
10  * GNU Radio is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with GNU Radio; see the file COPYING. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street,
18  * Boston, MA 02110-1301, USA.
19  */
20 #ifndef INCLUDED_OSMOSDR_SOURCE_IMPL_H
21 #define INCLUDED_OSMOSDR_SOURCE_IMPL_H
22 
23 #include <osmosdr/source.h>
24 
25 #ifdef HAVE_IQBALANCE
26 #include <gnuradio/iqbalance/optimize_c.h>
27 #include <gnuradio/iqbalance/fix_cc.h>
28 #endif
29 
30 #include <source_iface.h>
31 
32 #include <map>
33 
35 {
36 public:
37  source_impl( const std::string & args );
38 
39  size_t get_num_channels( void );
40 
42  double set_sample_rate( double rate );
43  double get_sample_rate( void );
44 
45  osmosdr::freq_range_t get_freq_range( size_t chan = 0 );
46  double set_center_freq( double freq, size_t chan = 0 );
47  double get_center_freq( size_t chan = 0 );
48  double set_freq_corr( double ppm, size_t chan = 0 );
49  double get_freq_corr( size_t chan = 0 );
50 
51  std::vector<std::string> get_gain_names( size_t chan = 0 );
52  osmosdr::gain_range_t get_gain_range( size_t chan = 0 );
53  osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 );
54  bool set_gain_mode( bool automatic, size_t chan = 0 );
55  bool get_gain_mode( size_t chan = 0 );
56  double set_gain( double gain, size_t chan = 0 );
57  double set_gain( double gain, const std::string & name, size_t chan = 0 );
58  double get_gain( size_t chan = 0 );
59  double get_gain( const std::string & name, size_t chan = 0 );
60 
61  double set_if_gain( double gain, size_t chan = 0 );
62  double set_bb_gain( double gain, size_t chan = 0 );
63 
64  std::vector< std::string > get_antennas( size_t chan = 0 );
65  std::string set_antenna( const std::string & antenna, size_t chan = 0 );
66  std::string get_antenna( size_t chan = 0 );
67 
68  void set_dc_offset_mode( int mode, size_t chan = 0 );
69  void set_dc_offset( const std::complex<double> &offset, size_t chan = 0 );
70 
71  void set_iq_balance_mode( int mode, size_t chan = 0 );
72  void set_iq_balance( const std::complex<double> &balance, size_t chan = 0 );
73 
74  double set_bandwidth( double bandwidth, size_t chan = 0 );
75  double get_bandwidth( size_t chan = 0 );
76  osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 );
77 
78 private:
79  std::vector< source_iface * > _devs;
80 
81  /* cache to prevent multiple device calls with the same value coming from grc */
82  double _sample_rate;
83  std::map< size_t, double > _center_freq;
84  std::map< size_t, double > _freq_corr;
85  std::map< size_t, bool > _gain_mode;
86  std::map< size_t, double > _gain;
87  std::map< size_t, double > _if_gain;
88  std::map< size_t, double > _bb_gain;
89  std::map< size_t, std::string > _antenna;
90 #ifdef HAVE_IQBALANCE
91  std::vector< gr::iqbalance::fix_cc * > _iq_fix;
92  std::vector< gr::iqbalance::optimize_c * > _iq_opt;
93  std::map< size_t, std::pair<float, float> > _vals;
94 #endif
95  std::map< size_t, double > _bandwidth;
96 };
97 
98 #endif /* INCLUDED_OSMOSDR_SOURCE_IMPL_H */
size_t get_num_channels(void)
double set_gain(double gain, size_t chan=0)
std::string get_antenna(size_t chan=0)
double set_bandwidth(double bandwidth, size_t chan=0)
Definition: source_impl.h:34
osmosdr::gain_range_t get_gain_range(size_t chan=0)
void set_dc_offset(const std::complex< double > &offset, size_t chan=0)
double set_center_freq(double freq, size_t chan=0)
bool get_gain_mode(size_t chan=0)
bool set_gain_mode(bool automatic, size_t chan=0)
osmosdr::freq_range_t get_freq_range(size_t chan=0)
void set_iq_balance(const std::complex< double > &balance, size_t chan=0)
source_impl(const std::string &args)
Definition: ranges.h:69
Provides a stream of complex samples.This uses the preferred technique: subclassing gr::hier_block2...
Definition: source.h:37
void set_dc_offset_mode(int mode, size_t chan=0)
double set_if_gain(double gain, size_t chan=0)
double set_sample_rate(double rate)
std::vector< std::string > get_gain_names(size_t chan=0)
osmosdr::freq_range_t get_bandwidth_range(size_t chan=0)
double set_bb_gain(double gain, size_t chan=0)
std::vector< std::string > get_antennas(size_t chan=0)
osmosdr::meta_range_t get_sample_rates(void)
double get_bandwidth(size_t chan=0)
double get_gain(size_t chan=0)
double get_freq_corr(size_t chan=0)
double get_center_freq(size_t chan=0)
std::string set_antenna(const std::string &antenna, size_t chan=0)
double set_freq_corr(double ppm, size_t chan=0)
double get_sample_rate(void)
void set_iq_balance_mode(int mode, size_t chan=0)