summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/hier
diff options
context:
space:
mode:
authorManoj Gudi2013-10-07 20:19:55 +0530
committerManoj Gudi2013-10-07 20:20:35 +0530
commit1826d0763c8595997f5f4af1fdb0354e9c0998ad (patch)
treeacbd852cd5a1bf17241b1038b5e37a0e72e64612 /gnuradio-core/src/lib/hier
parent452defdb4a78e9e826740ddf4b9673e926c568a4 (diff)
parent24b640997ba7fee0c725e65f401f5cbebdab8d08 (diff)
downloadgnuradio-1826d0763c8595997f5f4af1fdb0354e9c0998ad.tar.gz
gnuradio-1826d0763c8595997f5f4af1fdb0354e9c0998ad.tar.bz2
gnuradio-1826d0763c8595997f5f4af1fdb0354e9c0998ad.zip
README change
Diffstat (limited to 'gnuradio-core/src/lib/hier')
-rw-r--r--gnuradio-core/src/lib/hier/CMakeLists.txt42
-rw-r--r--gnuradio-core/src/lib/hier/gr_channel_model.cc126
-rw-r--r--gnuradio-core/src/lib/hier/gr_channel_model.h79
-rw-r--r--gnuradio-core/src/lib/hier/gr_channel_model.i50
-rw-r--r--gnuradio-core/src/lib/hier/hier.i32
5 files changed, 329 insertions, 0 deletions
diff --git a/gnuradio-core/src/lib/hier/CMakeLists.txt b/gnuradio-core/src/lib/hier/CMakeLists.txt
new file mode 100644
index 000000000..192dd5939
--- /dev/null
+++ b/gnuradio-core/src/lib/hier/CMakeLists.txt
@@ -0,0 +1,42 @@
+# Copyright 2010-2011 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.
+
+########################################################################
+# This file included, use CMake directory variables
+########################################################################
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+list(APPEND gnuradio_core_sources
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr_channel_model.cc
+)
+
+install(FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr_channel_model.h
+ DESTINATION ${GR_INCLUDE_DIR}/gnuradio
+ COMPONENT "core_devel"
+)
+
+if(ENABLE_PYTHON)
+ install(FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/hier.i
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr_channel_model.i
+ DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig
+ COMPONENT "core_swig"
+ )
+endif(ENABLE_PYTHON)
diff --git a/gnuradio-core/src/lib/hier/gr_channel_model.cc b/gnuradio-core/src/lib/hier/gr_channel_model.cc
new file mode 100644
index 000000000..7da357809
--- /dev/null
+++ b/gnuradio-core/src/lib/hier/gr_channel_model.cc
@@ -0,0 +1,126 @@
+/*
+ * 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
+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_fastnoise_source_c(GR_GAUSSIAN, noise_voltage, noise_seed, 1024*8);
+ 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);
+}
+
+
+double
+gr_channel_model::noise_voltage() const
+{
+ return d_noise->amplitude();
+}
+
+double
+gr_channel_model::frequency_offset() const
+{
+ return d_freq_offset->frequency();
+}
+
+std::vector<gr_complex>
+gr_channel_model::taps() const
+{
+ return d_multipath->taps();
+}
+
+double
+gr_channel_model::timing_offset() const
+{
+ return d_timing_offset->interp_ratio();
+}
diff --git a/gnuradio-core/src/lib/hier/gr_channel_model.h b/gnuradio-core/src/lib/hier/gr_channel_model.h
new file mode 100644
index 000000000..5796a6db2
--- /dev/null
+++ b/gnuradio-core/src/lib/hier/gr_channel_model.h
@@ -0,0 +1,79 @@
+/*
+ * 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_core_api.h>
+#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_fastnoise_source_c.h>
+#include <gr_multiply_cc.h>
+
+class gr_channel_model;
+typedef boost::shared_ptr<gr_channel_model> gr_channel_model_sptr;
+
+
+GR_CORE_API 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=0);
+
+/*!
+ * \brief channel simulator
+ * \ingroup misc_blk
+ */
+class GR_CORE_API 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_CORE_API 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_fastnoise_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);
+
+ double noise_voltage() const;
+ double frequency_offset() const;
+ std::vector<gr_complex> taps() const;
+ double timing_offset() const;
+};
diff --git a/gnuradio-core/src/lib/hier/gr_channel_model.i b/gnuradio-core/src/lib/hier/gr_channel_model.i
new file mode 100644
index 000000000..9aa6ebf5b
--- /dev/null
+++ b/gnuradio-core/src/lib/hier/gr_channel_model.i
@@ -0,0 +1,50 @@
+/* -*- c++ -*- */
+/*
+ * 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,channel_model)
+
+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=0);
+
+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);
+
+ 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);
+
+ double noise_voltage() const;
+ double frequency_offset() const;
+ std::vector<gr_complex> taps() const;
+ double timing_offset() const;
+};
diff --git a/gnuradio-core/src/lib/hier/hier.i b/gnuradio-core/src/lib/hier/hier.i
new file mode 100644
index 000000000..82044415e
--- /dev/null
+++ b/gnuradio-core/src/lib/hier/hier.i
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/*
+ * 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.
+ */
+
+%{
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_channel_model.h>
+%}
+
+%include "gr_channel_model.i"
+