Statistics
| Branch: | Tag: | Revision:

root / gnuradio-core / src / lib / general / gr_bin_statistics_f.h @ 38fe2e1b

History | View | Annotate | Download (2.7 kB)

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_sync_block.h>
28
#include <gr_feval.h>
29
#include <gr_message.h>
30
#include <gr_msg_queue.h>
31
32
class gr_bin_statistics_f;
33
typedef boost::shared_ptr<gr_bin_statistics_f> gr_bin_statistics_f_sptr;
34
35
36
gr_bin_statistics_f_sptr
37
gr_make_bin_statistics_f(unsigned int vlen,        // vector length
38
                         gr_msg_queue_sptr msgq,
39
                         gr_feval_dd *tune,        // callback
40
                         size_t tune_delay,        // samples
41
                         size_t dwell_delay);        // samples
42
                        
43
/*!
44
 * \brief control scanning and record frequency domain statistics
45
 * \ingroup sink_blk
46
 */
47
class gr_bin_statistics_f : public gr_sync_block
48
{
49
  friend gr_bin_statistics_f_sptr
50
  gr_make_bin_statistics_f(unsigned int vlen,           // vector length
51
                           gr_msg_queue_sptr msgq,
52
                           gr_feval_dd *tune,      // callback
53
                           size_t tune_delay,           // samples
54
                           size_t dwell_delay);           // samples
55
56
  enum state_t { ST_INIT, ST_TUNE_DELAY, ST_DWELL_DELAY };
57
58
  size_t             d_vlen;
59
  gr_msg_queue_sptr  d_msgq;
60
  gr_feval_dd       *d_tune;
61
  size_t             d_tune_delay;
62
  size_t             d_dwell_delay;
63
  double             d_center_freq;
64
65
  state_t             d_state;
66
  size_t             d_delay;        // nsamples remaining to state transition
67
68
  gr_bin_statistics_f(unsigned int vlen,
69
                      gr_msg_queue_sptr msgq,
70
                      gr_feval_dd *tune,
71
                      size_t tune_delay,
72
                      size_t dwell_delay);
73
74
  void enter_init();
75
  void enter_tune_delay();
76
  void enter_dwell_delay();
77
  void leave_dwell_delay();
78
79
protected:
80
  std::vector<float> d_max;        // per bin maxima
81
82
  size_t vlen() const { return d_vlen; }
83
  double center_freq() const { return d_center_freq; }
84
  gr_msg_queue_sptr msgq() const { return d_msgq; }
85
86
  virtual void reset_stats();
87
  virtual void accrue_stats(const float *input);
88
  virtual void send_stats();
89
90
public:
91
  ~gr_bin_statistics_f();
92
93
  int work(int noutput_items,
94
           gr_vector_const_void_star &input_items,
95
           gr_vector_void_star &output_items);
96
  
97
};
98
99
#endif