The Inspector (GNU Radio module gr-inspector)
signal_separator_c_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2016 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * This 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  * This software 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 this software; 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 #ifndef INCLUDED_INSPECTOR_SIGNAL_SEPARATOR_C_IMPL_H
24 #define INCLUDED_INSPECTOR_SIGNAL_SEPARATOR_C_IMPL_H
25 
27 #include <gnuradio/filter/firdes.h>
28 #include <gnuradio/filter/fir_filter.h>
29 #include <gnuradio/blocks/rotator.h>
30 #include <gnuradio/thread/thread.h>
31 #include <gnuradio/messages/msg_queue.h>
32 
33 namespace gr {
34  namespace inspector {
35 
37  private:
38  bool d_use_file;
39  int d_buffer_len;
40  unsigned int d_buffer_stage;
41  float d_trans_width, d_oversampling;
42  double d_samp_rate;
43  gr_complex* d_temp_buffer;
44 
45  filter::firdes::win_type d_window;
46 
47  std::vector<filter::kernel::fir_filter_ccf*> d_filterbank;
48  std::vector<std::vector<float> > d_rf_map;
49 
50  std::vector<float> build_taps(double cutoff);
51  std::vector<int> d_decimations;
52  std::vector<int> d_ntaps;
53  std::vector<blocks::rotator> d_rotators;
54 
55  std::vector<gr_complex*> d_history_buffer;
56  std::vector<std::vector<gr_complex> > d_result_vector;
57  gr::thread::mutex d_mutex;
58 
59  std::map<float, std::vector<float> > d_precalc;
60  std::vector<float> d_taps;
61 
62 
63  public:
65  float oversampling, bool taps_file,
66  std::map<float, std::vector<float> > &file_path);
67 
69 
70  // free allocated buffer arrays and FIR filters
71  void free_allocation();
72  // build new filter for signal
73  void build_filter(unsigned int signal);
74  // build new filters for all signals
75  void rebuild_all_filters();
76  // apply filter no i to history buffer i
77  void apply_filter(int i);
78  // trigger rebuild of filters and unpack message
79  void handle_msg(pmt::pmt_t msg);
80  // create pmt from filtered samples
81  pmt::pmt_t pack_message();
82  // create RF map from received message
83  void unpack_message(pmt::pmt_t msg);
84 
85  // Where all the action really happens
86  void forecast(int noutput_items,
87  gr_vector_int &ninput_items_required);
88 
89  int general_work(int noutput_items,
90  gr_vector_int &ninput_items,
91  gr_vector_const_void_star &input_items,
92  gr_vector_void_star &output_items);
93 
94  //<editor-fold desc="Getter and Setter">
95 
96  double samp_rate() const {
97  return d_samp_rate;
98  }
99 
100  void set_samp_rate(double d_samp_rate) {
101  signal_separator_c_impl::d_samp_rate = d_samp_rate;
103  }
104 
105  filter::firdes::win_type window() const {
106  return d_window;
107  }
108 
109  void set_window(int d_window) {
110  signal_separator_c_impl::d_window =
111  static_cast<filter::firdes::win_type >(d_window);
113  }
114 
115  float trans_width() const {
116  return d_trans_width;
117  }
118 
119  void set_trans_width(float d_trans_width) {
120  signal_separator_c_impl::d_trans_width = d_trans_width;
121 
122  }
123 
124  int oversampling() const {
125  return d_oversampling;
126  }
127 
128  void set_oversampling(float d_oversampling) {
129  signal_separator_c_impl::d_oversampling = d_oversampling;
131  }
132 
133  //</editor-fold>
134 
135  };
136 
137  } // namespace inspector
138 } // namespace gr
139 
140 #endif /* INCLUDED_INSPECTOR_SIGNAL_SEPARATOR_C_IMPL_H */
signal_separator_c_impl(double samp_rate, int window, float trans_width, float oversampling, bool taps_file, std::map< float, std::vector< float > > &file_path)
Signal Separator takes input signal and RF map as input and passes samples of each filtered and decim...
Definition: signal_separator_c.h:56
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
void set_oversampling(float d_oversampling)
Definition: signal_separator_c_impl.h:128
double samp_rate() const
Definition: signal_separator_c_impl.h:96
void set_window(int d_window)
Definition: signal_separator_c_impl.h:109
Definition: ofdm_bouzegzi_c.h:30
int oversampling() const
Definition: signal_separator_c_impl.h:124
void build_filter(unsigned int signal)
void forecast(int noutput_items, gr_vector_int &ninput_items_required)
filter::firdes::win_type window() const
Definition: signal_separator_c_impl.h:105
Definition: signal_separator_c_impl.h:36
void set_trans_width(float d_trans_width)
Definition: signal_separator_c_impl.h:119
void set_samp_rate(double d_samp_rate)
Definition: signal_separator_c_impl.h:100
float trans_width() const
Definition: signal_separator_c_impl.h:115