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