[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/01: digital: adds callbacks to corr_est_
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/01: digital: adds callbacks to corr_est_cc block. |
Date: |
Mon, 27 Apr 2015 01:38:19 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 1425e4828ab61d0579d39e8e6b6f362cba1017d8
Author: Tom Rondeau <address@hidden>
Date: Tue Apr 21 16:20:45 2015 -0400
digital: adds callbacks to corr_est_cc block.
Can set mark_delay and threshold while running.
---
gr-digital/grc/digital_corr_est_cc.xml | 9 +++
gr-digital/include/gnuradio/digital/corr_est_cc.h | 6 ++
gr-digital/lib/corr_est_cc_impl.cc | 73 +++++++++++++++++++----
gr-digital/lib/corr_est_cc_impl.h | 13 +++-
4 files changed, 87 insertions(+), 14 deletions(-)
diff --git a/gr-digital/grc/digital_corr_est_cc.xml
b/gr-digital/grc/digital_corr_est_cc.xml
index d687cef..cb345e9 100644
--- a/gr-digital/grc/digital_corr_est_cc.xml
+++ b/gr-digital/grc/digital_corr_est_cc.xml
@@ -4,35 +4,44 @@
<key>digital_corr_est_cc</key>
<import>from gnuradio import digital</import>
<make>digital.corr_est_cc($symbols, $sps, $mark_delay, $threshold)</make>
+ <callback>set_mark_delay($mark_delay)</callback>
+ <callback>set_theshold($threshold)</callback>
+
<param>
<name>Symbols</name>
<key>symbols</key>
<type>complex_vector</type>
</param>
+
<param>
<name>Samples per Symbol</name>
<key>sps</key>
<type>float</type>
</param>
+
<param>
<name>Tag marking delay</name>
<key>mark_delay</key>
<type>int</type>
</param>
+
<param>
<name>Threshold</name>
<key>threshold</key>
<value>0.9</value>
<type>float</type>
</param>
+
<sink>
<name>in</name>
<type>complex</type>
</sink>
+
<source>
<name>out</name>
<type>complex</type>
</source>
+
<source>
<name>corr</name>
<type>complex</type>
diff --git a/gr-digital/include/gnuradio/digital/corr_est_cc.h
b/gr-digital/include/gnuradio/digital/corr_est_cc.h
index 0d432ba..e8211cf 100644
--- a/gr-digital/include/gnuradio/digital/corr_est_cc.h
+++ b/gr-digital/include/gnuradio/digital/corr_est_cc.h
@@ -104,6 +104,12 @@ namespace gr {
virtual std::vector<gr_complex> symbols() const = 0;
virtual void set_symbols(const std::vector<gr_complex> &symbols) = 0;
+
+ virtual unsigned int mark_delay() const = 0;
+ virtual void set_mark_delay(unsigned int mark_delay) = 0;
+
+ virtual float threshold() const = 0;
+ virtual void set_threshold(float threshold) = 0;
};
} // namespace digital
diff --git a/gr-digital/lib/corr_est_cc_impl.cc
b/gr-digital/lib/corr_est_cc_impl.cc
index 0d2470b..ac753fb 100644
--- a/gr-digital/lib/corr_est_cc_impl.cc
+++ b/gr-digital/lib/corr_est_cc_impl.cc
@@ -62,16 +62,8 @@ namespace gr {
}
std::reverse(d_symbols.begin(), d_symbols.end());
- d_mark_delay = mark_delay >= d_symbols.size() ? d_symbols.size() - 1
- : mark_delay;
-
- // Compute a correlation threshold.
- // Compute the value of the discrete autocorrelation of the matched
- // filter with offset 0 (aka the autocorrelation peak).
- float corr = 0;
- for(size_t i = 0; i < d_symbols.size(); i++)
- corr += abs(d_symbols[i]*conj(d_symbols[i]));
- d_thresh = threshold*corr*corr;
+ set_mark_delay(mark_delay);
+ set_threshold(threshold);
// Correlation filter
d_filter = new kernel::fft_filter_ccc(1, d_symbols);
@@ -157,8 +149,65 @@ namespace gr {
declare_sample_delay(1, 0);
declare_sample_delay(0, d_symbols.size());
- d_mark_delay = d_mark_delay >= d_symbols.size() ? d_symbols.size()-1
- : d_mark_delay;
+ _set_mark_delay(d_stashed_mark_delay);
+ _set_threshold(d_stashed_threshold);
+ }
+
+ unsigned int
+ corr_est_cc_impl::mark_delay() const
+ {
+ return d_mark_delay;
+ }
+
+ void
+ corr_est_cc_impl::_set_mark_delay(unsigned int mark_delay)
+ {
+ d_stashed_mark_delay = mark_delay;
+
+ if(mark_delay >= d_symbols.size()) {
+ d_mark_delay = d_symbols.size()-1;
+ GR_LOG_WARN(d_logger, boost::format("set_mark_delay: asked for %1% but
due "
+ "to the symbol size constraints, "
+ "mark delay set to %2%.") \
+ % mark_delay % d_mark_delay);
+ }
+ else {
+ d_mark_delay = mark_delay;
+ }
+ }
+
+ void
+ corr_est_cc_impl::set_mark_delay(unsigned int mark_delay)
+ {
+ gr::thread::scoped_lock lock(d_setlock);
+ _set_mark_delay(mark_delay);
+ }
+
+ float
+ corr_est_cc_impl::threshold() const
+ {
+ return d_thresh;
+ }
+
+ void
+ corr_est_cc_impl::_set_threshold(float threshold)
+ {
+ d_stashed_threshold = threshold;
+
+ // Compute a correlation threshold.
+ // Compute the value of the discrete autocorrelation of the matched
+ // filter with offset 0 (aka the autocorrelation peak).
+ float corr = 0;
+ for(size_t i = 0; i < d_symbols.size(); i++)
+ corr += abs(d_symbols[i]*conj(d_symbols[i]));
+ d_thresh = threshold*corr*corr;
+ }
+
+ void
+ corr_est_cc_impl::set_threshold(float threshold)
+ {
+ gr::thread::scoped_lock lock(d_setlock);
+ _set_threshold(threshold);
}
int
diff --git a/gr-digital/lib/corr_est_cc_impl.h
b/gr-digital/lib/corr_est_cc_impl.h
index 83b5db6..6e8dd17 100644
--- a/gr-digital/lib/corr_est_cc_impl.h
+++ b/gr-digital/lib/corr_est_cc_impl.h
@@ -37,13 +37,16 @@ namespace gr {
pmt::pmt_t d_src_id;
std::vector<gr_complex> d_symbols;
float d_sps;
- unsigned int d_mark_delay;
- float d_thresh;
+ unsigned int d_mark_delay, d_stashed_mark_delay;
+ float d_thresh, d_stashed_threshold;
kernel::fft_filter_ccc *d_filter;
gr_complex *d_corr;
float *d_corr_mag;
+ void _set_mark_delay(unsigned int mark_delay);
+ void _set_threshold(float threshold);
+
public:
corr_est_cc_impl(const std::vector<gr_complex> &symbols,
float sps, unsigned int mark_delay,
@@ -53,6 +56,12 @@ namespace gr {
std::vector<gr_complex> symbols() const;
void set_symbols(const std::vector<gr_complex> &symbols);
+ unsigned int mark_delay() const;
+ void set_mark_delay(unsigned int mark_delay);
+
+ float threshold() const;
+ void set_threshold(float threshold);
+
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);