summaryrefslogtreecommitdiff
path: root/gnuradio-core/src
diff options
context:
space:
mode:
authorjcorgan2009-04-30 19:57:02 +0000
committerjcorgan2009-04-30 19:57:02 +0000
commit6ce881caaacdd60a8bea37584c7286e08bea97a7 (patch)
treeeee98aa1e0c997abcbfe2f203566b286a3824269 /gnuradio-core/src
parent81b56015743219c78c896ac0d870a5fa6b642cd5 (diff)
downloadgnuradio-6ce881caaacdd60a8bea37584c7286e08bea97a7.tar.gz
gnuradio-6ce881caaacdd60a8bea37584c7286e08bea97a7.tar.bz2
gnuradio-6ce881caaacdd60a8bea37584c7286e08bea97a7.zip
Adds dynamic setters/getters for moving average filters.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10932 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r--gnuradio-core/src/lib/gengen/gr_moving_average_XX.cc.t25
-rw-r--r--gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t9
-rw-r--r--gnuradio-core/src/lib/gengen/gr_moving_average_XX.i.t5
3 files changed, 36 insertions, 3 deletions
diff --git a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.cc.t
index e5e985235..33a0acf9c 100644
--- a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.cc.t
+++ b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.cc.t
@@ -39,9 +39,12 @@ gr_make_@BASE_NAME@ (int length, @O_TYPE@ scale, int max_iter)
: gr_sync_block ("@BASE_NAME@",
gr_make_io_signature (1, 1, sizeof (@I_TYPE@)),
gr_make_io_signature (1, 1, sizeof (@O_TYPE@))),
- d_length(length),
- d_scale(scale),
- d_max_iter(max_iter)
+ d_length(length),
+ d_scale(scale),
+ d_max_iter(max_iter),
+ d_new_length(length),
+ d_new_scale(scale),
+ d_updated(false)
{
set_history(length);
}
@@ -50,11 +53,27 @@ gr_make_@BASE_NAME@ (int length, @O_TYPE@ scale, int max_iter)
{
}
+void
+@NAME@::set_length_and_scale(int length, @O_TYPE@ scale)
+{
+ d_new_length = length;
+ d_new_scale = scale;
+ d_updated = true;
+}
+
int
@NAME@::work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
+ if (d_updated) {
+ d_length = d_new_length;
+ d_scale = d_new_scale;
+ set_history(d_length);
+ d_updated = false;
+ return 0; // history requirements might have changed
+ }
+
const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0];
@O_TYPE@ *out = (@O_TYPE@ *) output_items[0];
diff --git a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t
index 3121e3bfd..ee61808f2 100644
--- a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t
+++ b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t
@@ -50,12 +50,21 @@ private:
@O_TYPE@ d_scale;
int d_max_iter;
+ int d_new_length;
+ @O_TYPE@ d_new_scale;
+ bool d_updated;
+
public:
~@NAME@ ();
int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
+
+ int length() const { return d_new_length; }
+ @O_TYPE@ scale() const { return d_new_scale; }
+
+ void set_length_and_scale(int length, @O_TYPE@ scale);
};
#endif /* @GUARD_NAME@ */
diff --git a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.i.t b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.i.t
index c7da8d94e..855be90b0 100644
--- a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.i.t
+++ b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.i.t
@@ -30,4 +30,9 @@ class @NAME@ : public gr_sync_block
{
private:
@NAME@ ();
+
+ public:
+ int length() const;
+ @O_TYPE@ scale() const;
+ void set_length_and_scale(int length, @O_TYPE@ scale);
};