summaryrefslogtreecommitdiff
path: root/gr-analog
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2013-05-23 11:21:42 -0400
committerTom Rondeau <trondeau@vt.edu>2013-05-23 11:21:42 -0400
commitc2bab9d97890df334ffdf4d8c3b14db42187c96b (patch)
tree4b00c3b12a2af5eba264ad8e3f9ab959e8c98238 /gr-analog
parentdc578ff0900cf0bfc4ebcc8585f85672b63735cd (diff)
analog: fixing agc3 for new 3.7 style/structure. Added QA.
Diffstat (limited to 'gr-analog')
-rw-r--r--gr-analog/include/gnuradio/analog/agc3_cc.h9
-rw-r--r--gr-analog/lib/agc3_cc_impl.cc15
-rw-r--r--gr-analog/lib/agc3_cc_impl.h2
-rwxr-xr-xgr-analog/python/qa_agc.py37
4 files changed, 52 insertions, 11 deletions
diff --git a/gr-analog/include/gnuradio/analog/agc3_cc.h b/gr-analog/include/gnuradio/analog/agc3_cc.h
index 9ce2c0c18f..033caf3efe 100644
--- a/gr-analog/include/gnuradio/analog/agc3_cc.h
+++ b/gr-analog/include/gnuradio/analog/agc3_cc.h
@@ -23,8 +23,8 @@
#ifndef INCLUDED_ANALOG_AGC3_CC_H
#define INCLUDED_ANALOG_AGC3_CC_H
-#include <analog/api.h>
-#include <gr_sync_block.h>
+#include <gnuradio/analog/api.h>
+#include <gnuradio/sync_block.h>
namespace gr {
namespace analog {
@@ -37,7 +37,7 @@ namespace gr {
* \details
* For Power the absolute value of the complex number is used.
*/
- class ANALOG_API agc3_cc : virtual public gr_sync_block
+ class ANALOG_API agc3_cc : virtual public sync_block
{
public:
// gr::analog::agc3_cc::sptr
@@ -52,7 +52,8 @@ namespace gr {
* \param gain initial gain value.
* \param max_gain maximum gain value (0 for unlimited).
*/
- static sptr make(float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0);
+ static sptr make(float attack_rate = 1e-1, float decay_rate = 1e-2,
+ float reference = 1.0);
virtual float attack_rate() const = 0;
virtual float decay_rate() const = 0;
diff --git a/gr-analog/lib/agc3_cc_impl.cc b/gr-analog/lib/agc3_cc_impl.cc
index 26dd91e518..286c6be2a2 100644
--- a/gr-analog/lib/agc3_cc_impl.cc
+++ b/gr-analog/lib/agc3_cc_impl.cc
@@ -25,7 +25,7 @@
#endif
#include "agc3_cc_impl.h"
-#include <gr_io_signature.h>
+#include <gnuradio/io_signature.h>
#include <volk/volk.h>
namespace gr {
@@ -34,18 +34,21 @@ namespace gr {
agc3_cc::sptr
agc3_cc::make(float attack_rate, float decay_rate, float reference)
{
- return gnuradio::get_initial_sptr (new agc3_cc_impl(attack_rate, decay_rate, reference));
+ return gnuradio::get_initial_sptr
+ (new agc3_cc_impl(attack_rate, decay_rate, reference));
}
agc3_cc_impl::agc3_cc_impl(float attack_rate, float decay_rate, float reference)
- : gr_sync_block("agc3_cc",
- gr_make_io_signature(1, 1, sizeof(gr_complex)),
- gr_make_io_signature(1, 1, sizeof(gr_complex))),
+ : sync_block("agc3_cc",
+ io_signature::make(1, 1, sizeof(gr_complex)),
+ io_signature::make(1, 1, sizeof(gr_complex))),
d_attack(attack_rate), d_decay(decay_rate),
d_reference(reference), d_gain(1.0),
d_reset(true)
{
- set_alignment(volk_get_alignment());
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1, alignment_multiple));
}
agc3_cc_impl::~agc3_cc_impl()
diff --git a/gr-analog/lib/agc3_cc_impl.h b/gr-analog/lib/agc3_cc_impl.h
index 0913243fd6..28136ac6a2 100644
--- a/gr-analog/lib/agc3_cc_impl.h
+++ b/gr-analog/lib/agc3_cc_impl.h
@@ -23,7 +23,7 @@
#ifndef INCLUDED_ANALOG_AGC3_IMPL_CC_H
#define INCLUDED_ANALOG_AGC3_IMPL_CC_H
-#include <analog/agc3_cc.h>
+#include <gnuradio/analog/agc3_cc.h>
namespace gr {
namespace analog {
diff --git a/gr-analog/python/qa_agc.py b/gr-analog/python/qa_agc.py
index 0d8a7bfb5d..fc88b6acb0 100755
--- a/gr-analog/python/qa_agc.py
+++ b/gr-analog/python/qa_agc.py
@@ -451,6 +451,43 @@ class test_agc(gr_unittest.TestCase):
dst_data = dst1.data()
self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 4)
+ def test_006_sets(self):
+ agc = analog.agc3_cc(1e-3, 1e-1, 1)
+
+ agc.set_attack_rate(1)
+ agc.set_decay_rate(2)
+ agc.set_reference(1.1)
+ agc.set_gain(1.1)
+
+ self.assertAlmostEqual(agc.attack_rate(), 1)
+ self.assertAlmostEqual(agc.decay_rate(), 2)
+ self.assertAlmostEqual(agc.reference(), 1.1)
+ self.assertAlmostEqual(agc.gain(), 1.1)
+
+ def test_006(self):
+ ''' Test the complex AGC loop (attack and decay rate inputs) '''
+ tb = self.tb
+
+ sampling_freq = 100
+ N = int(5*sampling_freq)
+ src1 = analog.sig_source_c(sampling_freq, analog.GR_SIN_WAVE,
+ sampling_freq * 0.10, 100)
+ dst1 = blocks.vector_sink_c()
+ head = blocks.head(gr.sizeof_gr_complex, N)
+
+ ref = 1
+ agc = analog.agc3_cc(1e-2, 1e-3, ref)
+
+ tb.connect(src1, head)
+ tb.connect(head, agc)
+ tb.connect(agc, dst1)
+
+ tb.run()
+ dst_data = dst1.data()
+ M = 100
+ result = map(lambda x: abs(x), dst_data[N-M:])
+ self.assertFloatTuplesAlmostEqual(result, M*[ref,], 4)
+
def test_100(self):
''' Test complex feedforward agc with constant input '''