GNU Radio 3.3.0 C++ API
gr_bin_statistics_f.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2006 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef INCLUDED_GR_BIN_STATISTICS_F_H
00024 #define INCLUDED_GR_BIN_STATISTICS_F_H
00025 
00026 
00027 #include <gr_sync_block.h>
00028 #include <gr_feval.h>
00029 #include <gr_message.h>
00030 #include <gr_msg_queue.h>
00031 
00032 class gr_bin_statistics_f;
00033 typedef boost::shared_ptr<gr_bin_statistics_f> gr_bin_statistics_f_sptr;
00034 
00035 
00036 gr_bin_statistics_f_sptr
00037 gr_make_bin_statistics_f(unsigned int vlen,     // vector length
00038                          gr_msg_queue_sptr msgq,
00039                          gr_feval_dd *tune,     // callback
00040                          size_t tune_delay,     // samples
00041                          size_t dwell_delay);   // samples
00042                         
00043 /*!
00044  * \brief control scanning and record frequency domain statistics
00045  * \ingroup sink_blk
00046  */
00047 class gr_bin_statistics_f : public gr_sync_block
00048 {
00049   friend gr_bin_statistics_f_sptr
00050   gr_make_bin_statistics_f(unsigned int vlen,      // vector length
00051                            gr_msg_queue_sptr msgq,
00052                            gr_feval_dd *tune,      // callback
00053                            size_t tune_delay,      // samples
00054                            size_t dwell_delay);    // samples
00055 
00056   enum state_t { ST_INIT, ST_TUNE_DELAY, ST_DWELL_DELAY };
00057 
00058   size_t             d_vlen;
00059   gr_msg_queue_sptr  d_msgq;
00060   gr_feval_dd       *d_tune;
00061   size_t             d_tune_delay;
00062   size_t             d_dwell_delay;
00063   double             d_center_freq;
00064 
00065   state_t            d_state;
00066   size_t             d_delay;   // nsamples remaining to state transition
00067 
00068   gr_bin_statistics_f(unsigned int vlen,
00069                       gr_msg_queue_sptr msgq,
00070                       gr_feval_dd *tune,
00071                       size_t tune_delay,
00072                       size_t dwell_delay);
00073 
00074   void enter_init();
00075   void enter_tune_delay();
00076   void enter_dwell_delay();
00077   void leave_dwell_delay();
00078 
00079 protected:
00080   std::vector<float> d_max;     // per bin maxima
00081 
00082   size_t vlen() const { return d_vlen; }
00083   double center_freq() const { return d_center_freq; }
00084   gr_msg_queue_sptr msgq() const { return d_msgq; }
00085 
00086   virtual void reset_stats();
00087   virtual void accrue_stats(const float *input);
00088   virtual void send_stats();
00089 
00090 public:
00091   ~gr_bin_statistics_f();
00092 
00093   int work(int noutput_items,
00094            gr_vector_const_void_star &input_items,
00095            gr_vector_void_star &output_items);
00096   
00097 };
00098 
00099 #endif