GNU Radio 3.5.1 C++ API
|
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_core_api.h> 00028 #include <gr_sync_block.h> 00029 #include <gr_feval.h> 00030 #include <gr_message.h> 00031 #include <gr_msg_queue.h> 00032 00033 class gr_bin_statistics_f; 00034 typedef boost::shared_ptr<gr_bin_statistics_f> gr_bin_statistics_f_sptr; 00035 00036 00037 GR_CORE_API gr_bin_statistics_f_sptr 00038 gr_make_bin_statistics_f(unsigned int vlen, // vector length 00039 gr_msg_queue_sptr msgq, 00040 gr_feval_dd *tune, // callback 00041 size_t tune_delay, // samples 00042 size_t dwell_delay); // samples 00043 00044 /*! 00045 * \brief control scanning and record frequency domain statistics 00046 * \ingroup sink_blk 00047 */ 00048 class GR_CORE_API gr_bin_statistics_f : public gr_sync_block 00049 { 00050 friend GR_CORE_API gr_bin_statistics_f_sptr 00051 gr_make_bin_statistics_f(unsigned int vlen, // vector length 00052 gr_msg_queue_sptr msgq, 00053 gr_feval_dd *tune, // callback 00054 size_t tune_delay, // samples 00055 size_t dwell_delay); // samples 00056 00057 enum state_t { ST_INIT, ST_TUNE_DELAY, ST_DWELL_DELAY }; 00058 00059 size_t d_vlen; 00060 gr_msg_queue_sptr d_msgq; 00061 gr_feval_dd *d_tune; 00062 size_t d_tune_delay; 00063 size_t d_dwell_delay; 00064 double d_center_freq; 00065 00066 state_t d_state; 00067 size_t d_delay; // nsamples remaining to state transition 00068 00069 gr_bin_statistics_f(unsigned int vlen, 00070 gr_msg_queue_sptr msgq, 00071 gr_feval_dd *tune, 00072 size_t tune_delay, 00073 size_t dwell_delay); 00074 00075 void enter_init(); 00076 void enter_tune_delay(); 00077 void enter_dwell_delay(); 00078 void leave_dwell_delay(); 00079 00080 protected: 00081 std::vector<float> d_max; // per bin maxima 00082 00083 size_t vlen() const { return d_vlen; } 00084 double center_freq() const { return d_center_freq; } 00085 gr_msg_queue_sptr msgq() const { return d_msgq; } 00086 00087 virtual void reset_stats(); 00088 virtual void accrue_stats(const float *input); 00089 virtual void send_stats(); 00090 00091 public: 00092 ~gr_bin_statistics_f(); 00093 00094 int work(int noutput_items, 00095 gr_vector_const_void_star &input_items, 00096 gr_vector_void_star &output_items); 00097 00098 }; 00099 00100 #endif