commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r10819 - gnuradio/branches/developers/jcorgan/cpphier/


From: jcorgan
Subject: [Commit-gnuradio] r10819 - gnuradio/branches/developers/jcorgan/cpphier/gnuradio-core/src/lib/hier
Date: Mon, 13 Apr 2009 13:21:53 -0600 (MDT)

Author: jcorgan
Date: 2009-04-13 13:21:52 -0600 (Mon, 13 Apr 2009)
New Revision: 10819

Added:
   
gnuradio/branches/developers/jcorgan/cpphier/gnuradio-core/src/lib/hier/gr_channel_model.cc
   
gnuradio/branches/developers/jcorgan/cpphier/gnuradio-core/src/lib/hier/gr_channel_model.h
Modified:
   gnuradio/branches/developers/jcorgan/cpphier/gnuradio-core/src/lib/hier/
   
gnuradio/branches/developers/jcorgan/cpphier/gnuradio-core/src/lib/hier/Makefile.am
Log:
Added gr_channel_model hierarchical block


Property changes on: 
gnuradio/branches/developers/jcorgan/cpphier/gnuradio-core/src/lib/hier
___________________________________________________________________
Modified: svn:ignore
   - Makefile
Makefile.in

   + Makefile
Makefile.in
.libs
.deps


Modified: 
gnuradio/branches/developers/jcorgan/cpphier/gnuradio-core/src/lib/hier/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/jcorgan/cpphier/gnuradio-core/src/lib/hier/Makefile.am
 2009-04-13 18:56:33 UTC (rev 10818)
+++ 
gnuradio/branches/developers/jcorgan/cpphier/gnuradio-core/src/lib/hier/Makefile.am
 2009-04-13 19:21:52 UTC (rev 10819)
@@ -26,8 +26,8 @@
 
 noinst_LTLIBRARIES = libhier.la
 
-libhier_la_SOURCES =                   
+libhier_la_SOURCES = \
+       gr_channel_model.cc
 
-grinclude_HEADERS =
-
-
+grinclude_HEADERS = \
+       gr_channel_model.h

Added: 
gnuradio/branches/developers/jcorgan/cpphier/gnuradio-core/src/lib/hier/gr_channel_model.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/cpphier/gnuradio-core/src/lib/hier/gr_channel_model.cc
                         (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/cpphier/gnuradio-core/src/lib/hier/gr_channel_model.cc
 2009-04-13 19:21:52 UTC (rev 10819)
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2009 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 3, 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.
+ */
+
+#include <gr_channel_model.h>
+#include <gr_io_signature.h>
+#include <gr_sig_source_f.h>
+#include <iostream>
+
+// Shared pointer constructor
+gr_channel_model_sptr
+gr_make_channel_model(double noise_voltage,
+                     double frequency_offset,
+                     double epsilon,
+                     const std::vector<gr_complex> &taps,
+                     double noise_seed)
+{
+  return gnuradio::get_initial_sptr(new gr_channel_model(noise_voltage,
+                                                        frequency_offset,
+                                                        epsilon,
+                                                        taps,
+                                                        noise_seed));
+}
+
+// Hierarchical block constructor, with no inputs or outputs
+gr_channel_model::gr_channel_model(double noise_voltage,
+                                  double frequency_offset,
+                                  double epsilon,
+                                  const std::vector<gr_complex> &taps,
+                                  double noise_seed)
+  : gr_hier_block2("gr_channel_model",
+                  gr_make_io_signature(1, 1, sizeof(gr_complex)), 
+                  gr_make_io_signature(1, 1, sizeof(gr_complex)))
+{
+  d_taps = taps;
+  while(d_taps.size() < 2) {
+    d_taps.push_back(0);
+  }
+  
+  d_timing_offset = gr_make_fractional_interpolator_cc(0, epsilon);
+  
+  d_multipath = gr_make_fir_filter_ccc(1, d_taps);
+  
+  d_noise_adder = gr_make_add_cc();
+  d_noise = gr_make_noise_source_c(GR_GAUSSIAN, noise_voltage, noise_seed);
+  d_freq_offset = gr_make_sig_source_c(1, GR_SIN_WAVE, frequency_offset, 1.0, 
0.0);
+  d_mixer_offset = gr_make_multiply_cc();
+  
+  connect(self(), 0, d_timing_offset, 0);
+  connect(d_timing_offset, 0, d_multipath, 0);
+  connect(d_multipath, 0, d_mixer_offset, 0);
+  connect(d_freq_offset, 0, d_mixer_offset, 1);
+  connect(d_mixer_offset, 0, d_noise_adder, 1);
+  connect(d_noise, 0, d_noise_adder, 0);
+  connect(d_noise_adder, 0, self(), 0);
+}
+
+void
+gr_channel_model::set_noise_voltage(double noise_voltage)
+{
+  d_noise->set_amplitude(noise_voltage);
+}
+   
+void
+gr_channel_model::set_frequency_offset(double frequency_offset)
+{
+  d_freq_offset->set_frequency(frequency_offset);
+}
+     
+void
+gr_channel_model::set_taps(const std::vector<gr_complex> &taps)
+{
+  d_taps = taps;
+  while(d_taps.size() < 2) {
+    d_taps.push_back(0);
+  }
+  d_multipath->set_taps(d_taps);
+}
+
+void
+gr_channel_model::set_timing_offset(double epsilon)
+{
+  d_timing_offset->set_interp_ratio(epsilon);
+}

Added: 
gnuradio/branches/developers/jcorgan/cpphier/gnuradio-core/src/lib/hier/gr_channel_model.h
===================================================================
--- 
gnuradio/branches/developers/jcorgan/cpphier/gnuradio-core/src/lib/hier/gr_channel_model.h
                          (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/cpphier/gnuradio-core/src/lib/hier/gr_channel_model.h
  2009-04-13 19:21:52 UTC (rev 10819)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2009 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 3, 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.
+ */
+
+#include <gr_top_block.h>
+#include <gr_fractional_interpolator_cc.h>
+#include <gr_sig_source_c.h>
+#include <gr_fir_filter_ccc.h>
+#include <gr_add_cc.h>
+#include <gr_noise_source_c.h>
+#include <gr_multiply_cc.h>
+
+class gr_channel_model;
+typedef boost::shared_ptr<gr_channel_model> gr_channel_model_sptr;
+
+
+gr_channel_model_sptr gr_make_channel_model(double noise_voltage=0.0,
+                                           double frequency_offset=0.0,
+                                           double epsilon=1.0,
+                                           const std::vector<gr_complex> 
&taps=std::vector<gr_complex>(1, 1),
+                                           double noise_seed=3021);
+
+class gr_channel_model : public gr_hier_block2
+{
+ private:
+  gr_channel_model(double noise_voltage,
+                  double frequency_offset,
+                  double epsilon,
+                  const std::vector<gr_complex> &taps,
+                  double noise_seed);
+  friend gr_channel_model_sptr gr_make_channel_model(double noise_voltage,
+                                                    double frequency_offset,
+                                                    double epsilon,
+                                                    const 
std::vector<gr_complex> &taps,
+                                                    double noise_seed);
+  
+  gr_fractional_interpolator_cc_sptr d_timing_offset;
+  gr_sig_source_c_sptr d_freq_offset;
+  gr_fir_filter_ccc_sptr d_multipath;
+  gr_add_cc_sptr d_noise_adder;
+  gr_noise_source_c_sptr d_noise;
+  gr_multiply_cc_sptr d_mixer_offset;
+  
+  std::vector<gr_complex> d_taps;
+  
+ public:
+  void set_noise_voltage(double noise_voltage);
+  void set_frequency_offset(double frequency_offset);
+  void set_taps(const std::vector<gr_complex> &taps);
+  void set_timing_offset(double epsilon);
+};





reply via email to

[Prev in Thread] Current Thread [Next in Thread]