1 /* -*- c++ -*- */ 2 /* 3 * Copyright 2006,2013 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_IMPL_H 24 #define INCLUDED_GR_BIN_STATISTICS_F_IMPL_H 25 26 #include <gnuradio/blocks/bin_statistics_f.h> 27 #include <gnuradio/feval.h> 28 #include <gnuradio/message.h> 29 #include <gnuradio/msg_queue.h> 30 31 namespace gr { 32 namespace blocks { 33 34 class bin_statistics_f_impl : public bin_statistics_f 35 { 36 private: 37 enum state_t { ST_INIT, ST_TUNE_DELAY, ST_DWELL_DELAY }; 38 39 size_t d_vlen; 40 msg_queue::sptr d_msgq; 41 feval_dd* d_tune; 42 size_t d_tune_delay; 43 size_t d_dwell_delay; 44 double d_center_freq; 45 46 state_t d_state; 47 size_t d_delay; // nsamples remaining to state transition 48 49 void enter_init(); 50 void enter_tune_delay(); 51 void enter_dwell_delay(); 52 void leave_dwell_delay(); 53 54 protected: 55 std::vector<float> d_max; // per bin maxima 56 vlen()57 size_t vlen() const { return d_vlen; } center_freq()58 double center_freq() const { return d_center_freq; } msgq()59 msg_queue::sptr msgq() const { return d_msgq; } 60 61 virtual void reset_stats(); 62 virtual void accrue_stats(const float* input); 63 virtual void send_stats(); 64 65 public: 66 bin_statistics_f_impl(unsigned int vlen, 67 msg_queue::sptr msgq, 68 feval_dd* tune, 69 size_t tune_delay, 70 size_t dwell_delay); 71 ~bin_statistics_f_impl(); 72 73 int work(int noutput_items, 74 gr_vector_const_void_star& input_items, 75 gr_vector_void_star& output_items); 76 }; 77 78 } /* namespace blocks */ 79 } /* namespace gr */ 80 81 #endif /* INCLUDED_GR_BIN_STATISTICS_F_IMPL_H */ 82