GNU Radio 3.6.4.1 C++ API
gr_bin_statistics_f.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006 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 #ifndef INCLUDED_GR_BIN_STATISTICS_F_H
24 #define INCLUDED_GR_BIN_STATISTICS_F_H
25 
26 
27 #include <gr_core_api.h>
28 #include <gr_sync_block.h>
29 #include <gr_feval.h>
30 #include <gr_message.h>
31 #include <gr_msg_queue.h>
32 
35 
36 
38 gr_make_bin_statistics_f(unsigned int vlen, // vector length
40  gr_feval_dd *tune, // callback
41  size_t tune_delay, // samples
42  size_t dwell_delay); // samples
43 
44 /*!
45  * \brief control scanning and record frequency domain statistics
46  * \ingroup sink_blk
47  */
49 {
51  gr_make_bin_statistics_f(unsigned int vlen, // vector length
52  gr_msg_queue_sptr msgq,
53  gr_feval_dd *tune, // callback
54  size_t tune_delay, // samples
55  size_t dwell_delay); // samples
56 
57  enum state_t { ST_INIT, ST_TUNE_DELAY, ST_DWELL_DELAY };
58 
59  size_t d_vlen;
60  gr_msg_queue_sptr d_msgq;
61  gr_feval_dd *d_tune;
62  size_t d_tune_delay;
63  size_t d_dwell_delay;
64  double d_center_freq;
65 
66  state_t d_state;
67  size_t d_delay; // nsamples remaining to state transition
68 
69  gr_bin_statistics_f(unsigned int vlen,
70  gr_msg_queue_sptr msgq,
71  gr_feval_dd *tune,
72  size_t tune_delay,
73  size_t dwell_delay);
74 
75  void enter_init();
76  void enter_tune_delay();
77  void enter_dwell_delay();
78  void leave_dwell_delay();
79 
80 protected:
81  std::vector<float> d_max; // per bin maxima
82 
83  size_t vlen() const { return d_vlen; }
84  double center_freq() const { return d_center_freq; }
85  gr_msg_queue_sptr msgq() const { return d_msgq; }
86 
87  virtual void reset_stats();
88  virtual void accrue_stats(const float *input);
89  virtual void send_stats();
90 
91 public:
93 
94  int work(int noutput_items,
95  gr_vector_const_void_star &input_items,
96  gr_vector_void_star &output_items);
97 
98 };
99 
100 #endif