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 
41  bool seek( long seek_point, int whence, size_t chan );
42 
44  double set_sample_rate( double rate );
45  double get_sample_rate( void );
46 
47  osmosdr::freq_range_t get_freq_range( size_t chan = 0 );
48  double set_center_freq( double freq, size_t chan = 0 );
49  double get_center_freq( size_t chan = 0 );
50  double set_freq_corr( double ppm, size_t chan = 0 );
51  double get_freq_corr( size_t chan = 0 );
52 
53  std::vector<std::string> get_gain_names( size_t chan = 0 );
54  osmosdr::gain_range_t get_gain_range( size_t chan = 0 );
55  osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 );
56  bool set_gain_mode( bool automatic, size_t chan = 0 );
57  bool get_gain_mode( size_t chan = 0 );
58  double set_gain( double gain, size_t chan = 0 );
59  double set_gain( double gain, const std::string & name, size_t chan = 0 );
60  double get_gain( size_t chan = 0 );
61  double get_gain( const std::string & name, size_t chan = 0 );
62 
63  double set_if_gain( double gain, size_t chan = 0 );
64  double set_bb_gain( double gain, size_t chan = 0 );
65 
66  std::vector< std::string > get_antennas( size_t chan = 0 );
67  std::string set_antenna( const std::string & antenna, size_t chan = 0 );
68  std::string get_antenna( size_t chan = 0 );
69 
70  void set_dc_offset_mode( int mode, size_t chan = 0 );
71  void set_dc_offset( const std::complex<double> &offset, size_t chan = 0 );
72 
73  void set_iq_balance_mode( int mode, size_t chan = 0 );
74  void set_iq_balance( const std::complex<double> &balance, size_t chan = 0 );
75 
76  double set_bandwidth( double bandwidth, size_t chan = 0 );
77  double get_bandwidth( size_t chan = 0 );
78  osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 );
79 
80 private:
81  std::vector< source_iface * > _devs;
82 
83  /* cache to prevent multiple device calls with the same value coming from grc */
84  double _sample_rate;
85  std::map< size_t, double > _center_freq;
86  std::map< size_t, double > _freq_corr;
87  std::map< size_t, bool > _gain_mode;
88  std::map< size_t, double > _gain;
89  std::map< size_t, double > _if_gain;
90  std::map< size_t, double > _bb_gain;
91  std::map< size_t, std::string > _antenna;
92 #ifdef HAVE_IQBALANCE
93  std::vector< gr::iqbalance::fix_cc * > _iq_fix;
94  std::vector< gr::iqbalance::optimize_c * > _iq_opt;
95  std::map< size_t, std::pair<float, float> > _vals;
96 #endif
97  std::map< size_t, double > _bandwidth;
98 };
99 
100 #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)
bool seek(long seek_point, int whence, size_t chan)
seek file to seek_point relative to whence
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)