[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r3853 - gnuradio/branches/developers/eb/binstats/gnura
From: |
eb |
Subject: |
[Commit-gnuradio] r3853 - gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general |
Date: |
Tue, 24 Oct 2006 17:48:42 -0600 (MDT) |
Author: eb
Date: 2006-10-24 17:48:42 -0600 (Tue, 24 Oct 2006)
New Revision: 3853
Added:
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/gr_bin_statistics_f.cc
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/gr_bin_statistics_f.h
Removed:
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/gr_peak_detector_f.cc
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/gr_peak_detector_f.h
Modified:
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/Makefile.am
Log:
work in progress
Modified:
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/Makefile.am
===================================================================
---
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/Makefile.am
2006-10-24 22:03:38 UTC (rev 3852)
+++
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/Makefile.am
2006-10-24 23:48:42 UTC (rev 3853)
@@ -98,6 +98,7 @@
gr_agc2_cc.cc \
gr_agc2_ff.cc \
gr_align_on_samplenumbers_ss.cc \
+ gr_bin_statistics_f.cc \
gr_binary_slicer_fb.cc \
gr_bytes_to_syms.cc \
gr_char_to_float.cc \
@@ -219,6 +220,7 @@
gr_agc2_cc.h \
gr_agc2_ff.h \
gr_align_on_samplenumbers_ss.h \
+ gr_bin_statistics_f.h \
gr_binary_slicer_fb.h \
gr_bytes_to_syms.h \
gr_char_to_float.h \
Copied:
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/gr_bin_statistics_f.cc
(from rev 3851,
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/gr_peak_detector_f.cc)
===================================================================
---
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/gr_bin_statistics_f.cc
(rev 0)
+++
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/gr_bin_statistics_f.cc
2006-10-24 23:48:42 UTC (rev 3853)
@@ -0,0 +1,167 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_bin_statistics_f.h>
+#include <gr_io_signature.h>
+
+gr_bin_statistics_f_sptr
+gr_make_bin_statistics_f(unsigned int vlen,
+ gr_msg_queue_sptr msgq,
+ gr_feval_dd *tune,
+ size_t tune_delay,
+ size_t dwell_delay)
+{
+ return gr_bin_statistics_f_sptr(new gr_bin_statistics_f(vlen,
+ msgq,
+ tune,
+ tune_delay,
+ dwell_delay));
+}
+
+gr_bin_statistics_f::gr_bin_statistics_f(unsigned int vlen,
+ gr_msg_queue_sptr msgq,
+ gr_feval_dd *tune,
+ size_t tune_delay,
+ size_t dwell_delay)
+ : gr_sync_block("bin_statistics_f",
+ gr_make_io_signature(1, 1, sizeof(float) * vlen),
+ gr_make_io_signature(0, 0, 0)),
+ d_vlen(vlen), d_msgq(msgq), d_tune(tune),
+ d_tune_delay(tune_delay), d_dwell_delay(dwell_delay),
+ d_center_freq(0), d_delay(0),
+ d_max(vlen)
+{
+}
+
+gr_bin_statistics_f::~gr_bin_statistics_f()
+{
+ // NOP
+}
+
+void
+gr_bin_statistics_f::enter_init()
+{
+ d_state = ST_INIT;
+ d_delay = 0;
+}
+
+void
+gr_bin_statistics_f::enter_tune_delay()
+{
+ d_state = ST_TUNE_DELAY;
+ d_delay = d_tune_delay;
+ d_center_freq = d_tune->eval(0);
+}
+
+void
+gr_bin_statistics_f::enter_dwell_delay()
+{
+ d_state = ST_DWELL_DELAY;
+ d_delay = d_dwell_delay;
+ reset_stats();
+}
+
+void
+gr_bin_statistics_f::leave_dwell_delay()
+{
+ send_stats();
+ enter_tune_delay();
+}
+
+int
+gr_bin_statistics_f::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const float *input = (const float *) input_items[0];
+ size_t vlen = d_max.size();
+
+ int n = 0;
+ int t;
+
+ while (n < noutput_items){
+ switch (d_state){
+
+ case ST_INIT:
+ enter_tune_delay();
+ break;
+
+ case ST_TUNE_DELAY:
+ t = std::min(noutput_items - n, int(d_delay));
+ n += t;
+ d_delay -= t;
+ assert(d_delay >= 0);
+ if (d_delay == 0)
+ enter_dwell_delay();
+ break;
+
+ case ST_DWELL_DELAY:
+ t = std::min(noutput_items - n, int(d_delay));
+ for (int i = 0; i < t; i++){
+ accrue_stats(&input[n * vlen]);
+ n++;
+ }
+ d_delay -= t;
+ assert(d_delay >= 0);
+ if (d_delay == 0){
+ leave_dwell_delay();
+ enter_tune_delay();
+ }
+ break;
+
+ default:
+ assert(0);
+ }
+ }
+
+ return noutput_items;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// virtual methods for gathering stats
+//////////////////////////////////////////////////////////////////////////
+
+void
+gr_bin_statistics_f::reset_stats()
+{
+ for (size_t i = 0; i < vlen(); i++){
+ d_max[i] = 0;
+ }
+}
+
+void
+gr_bin_statistics_f::accrue_stats(const float *input)
+{
+ for (size_t i = 0; i < vlen(); i++){
+ d_max[i] = std::max(d_max[i], input[i]); // compute per bin maxima
+ }
+}
+
+void
+gr_bin_statistics_f::send_stats()
+{
+ // FIXME build & send a message
+}
Copied:
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/gr_bin_statistics_f.h
(from rev 3851,
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/gr_peak_detector_f.h)
===================================================================
---
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/gr_bin_statistics_f.h
(rev 0)
+++
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/gr_bin_statistics_f.h
2006-10-24 23:48:42 UTC (rev 3853)
@@ -0,0 +1,99 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GR_BIN_STATISTICS_F_H
+#define INCLUDED_GR_BIN_STATISTICS_F_H
+
+
+#include <gr_sync_block.h>
+#include <gr_feval.h>
+#include <gr_message.h>
+#include <gr_msg_queue.h>
+
+class gr_bin_statistics_f;
+typedef boost::shared_ptr<gr_bin_statistics_f> gr_bin_statistics_f_sptr;
+
+
+gr_bin_statistics_f_sptr
+gr_make_bin_statistics_f(unsigned int vlen, // vector length
+ gr_msg_queue_sptr msgq,
+ gr_feval_dd *tune, // callback
+ size_t tune_delay, // samples
+ size_t dwell_delay); // samples
+
+/*!
+ * \brief control scanning and record frequency domain statistics
+ * \ingroup sink
+ */
+class gr_bin_statistics_f : public gr_sync_block
+{
+ friend gr_bin_statistics_f_sptr
+ gr_make_bin_statistics_f(unsigned int vlen, // vector length
+ gr_msg_queue_sptr msgq,
+ gr_feval_dd *tune, // callback
+ size_t tune_delay, // samples
+ size_t dwell_delay); // samples
+
+ enum state_t { ST_INIT, ST_TUNE_DELAY, ST_DWELL_DELAY };
+
+ size_t d_vlen;
+ gr_msg_queue_sptr d_msgq;
+ gr_feval_dd *d_tune;
+ size_t d_tune_delay;
+ size_t d_dwell_delay;
+ double d_center_freq;
+
+ state_t d_state;
+ size_t d_delay; // nsamples remaining to state transition
+
+ gr_bin_statistics_f(unsigned int vlen,
+ gr_msg_queue_sptr msgq,
+ gr_feval_dd *tune,
+ size_t tune_delay,
+ size_t dwell_delay);
+
+ void enter_init();
+ void enter_tune_delay();
+ void enter_dwell_delay();
+ void leave_dwell_delay();
+
+protected:
+ std::vector<float> d_max; // per bin maxima
+
+ size_t vlen() const { return d_vlen; }
+ double center_freq() const { return d_center_freq; }
+ gr_msg_queue_sptr msgq() const { return d_msgq; }
+
+ virtual void reset_stats();
+ virtual void accrue_stats(const float *input);
+ virtual void send_stats();
+
+public:
+ ~gr_bin_statistics_f();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+};
+
+#endif
Deleted:
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/gr_peak_detector_f.cc
Deleted:
gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general/gr_peak_detector_f.h
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r3853 - gnuradio/branches/developers/eb/binstats/gnuradio-core/src/lib/general,
eb <=