Skip to content

Commit

Permalink
Merge pull request #316 from anarkiwi/get
Browse files Browse the repository at this point in the history
get helpers.
  • Loading branch information
anarkiwi authored Sep 14, 2024
2 parents 2b69212 + 5148389 commit 955b643
Show file tree
Hide file tree
Showing 10 changed files with 159 additions and 9 deletions.
4 changes: 4 additions & 0 deletions include/gnuradio/iqtlabs/retune_fft.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ class IQTLABS_API retune_fft : virtual public gr::block {
const std::string &description, uint64_t rotate_secs,
bool pre_fft, bool tag_now, bool low_power_hold_down,
bool slew_rx_time, uint64_t peak_fft_range);
virtual double get_freq_start(void) = 0;
virtual double get_freq_end(void) = 0;
virtual double get_tune_freq(void) = 0;
virtual bool get_stare_mode(void) = 0;
};

} // namespace iqtlabs
Expand Down
4 changes: 4 additions & 0 deletions include/gnuradio/iqtlabs/retune_pre_fft.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ class IQTLABS_API retune_pre_fft : virtual public gr::block {
uint64_t skip_tune_step_fft,
const std::string &tuning_ranges, bool tag_now,
bool low_power_hold_down, bool slew_rx_time);
virtual double get_freq_start(void) = 0;
virtual double get_freq_end(void) = 0;
virtual double get_tune_freq(void) = 0;
virtual bool get_stare_mode(void) = 0;
};

} // namespace iqtlabs
Expand Down
4 changes: 4 additions & 0 deletions lib/retune_fft_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ class retune_fft_impl : public retune_fft, base_impl, retuner_impl {
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
bool stop();
double get_freq_start(void) override { return freq_start_; };
double get_freq_end(void) override { return freq_end_; };
double get_tune_freq(void) override { return tune_freq_; };
bool get_stare_mode(void) override { return stare_mode_; };
};

} // namespace iqtlabs
Expand Down
4 changes: 4 additions & 0 deletions lib/retune_pre_fft_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ class retune_pre_fft_impl : public retune_pre_fft, base_impl, retuner_impl {
int general_work(int noutput_items, gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
double get_freq_start(void) override { return freq_start_; };
double get_freq_end(void) override { return freq_end_; };
double get_tune_freq(void) override { return tune_freq_; };
bool get_stare_mode(void) override { return stare_mode_; };
};

} // namespace iqtlabs
Expand Down
15 changes: 10 additions & 5 deletions lib/retuner_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,16 @@ retuner_impl::retuner_impl(COUNT_T samp_rate, COUNT_T tune_jitter_hz,
void retuner_impl::add_range_(COUNT_T freq_start, COUNT_T freq_end) {
// TODO: this could be a vector of steps that could be retuned to
// in random order each time, to implement a frequency hopping scanner.
COUNT_T steps = (freq_end - freq_start) / tune_step_hz_ + 1;
if (steps > 1) {
++steps;
if (freq_end == 0) {
freq_end = freq_start + tune_step_hz_;
tuning_ranges_.push_back({freq_start, freq_end, 1});
} else {
COUNT_T steps = (freq_end - freq_start) / tune_step_hz_ + 1;
if (steps > 1) {
++steps;
}
tuning_ranges_.push_back({freq_start, freq_end, steps});
}
tuning_ranges_.push_back({freq_start, freq_end, steps});
}

std::string retuner_impl::describe_ranges_() {
Expand All @@ -267,7 +272,7 @@ bool retuner_impl::need_retune_(COUNT_T n) {

void retuner_impl::parse_tuning_ranges_(const std::string &tuning_ranges) {
if (tuning_ranges.length() == 0) {
if (freq_end_ <= freq_start_) {
if (freq_end_ && freq_end_ <= freq_start_) {
throw std::invalid_argument(
"invalid freq_start/freq_end (end must be greater than start)");
}
Expand Down
17 changes: 16 additions & 1 deletion python/iqtlabs/bindings/docstrings/retune_fft_pydoc_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,24 @@
static const char *__doc_gr_iqtlabs_retune_fft = R"doc()doc";


static const char *__doc_gr_iqtlabs_retune_fft_retune_fft = R"doc()doc";
static const char *__doc_gr_iqtlabs_retune_fft_retune_fft_0 = R"doc()doc";


static const char *__doc_gr_iqtlabs_retune_fft_retune_fft_1 = R"doc()doc";


static const char *__doc_gr_iqtlabs_retune_fft_make = R"doc()doc";


static const char *__doc_gr_iqtlabs_retune_fft_get_freq_start = R"doc()doc";


static const char *__doc_gr_iqtlabs_retune_fft_get_freq_end = R"doc()doc";


static const char *__doc_gr_iqtlabs_retune_fft_get_tune_freq = R"doc()doc";


static const char *__doc_gr_iqtlabs_retune_fft_get_stare_mode = R"doc()doc";


Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,24 @@
static const char *__doc_gr_iqtlabs_retune_pre_fft = R"doc()doc";


static const char *__doc_gr_iqtlabs_retune_pre_fft_retune_pre_fft = R"doc()doc";
static const char *__doc_gr_iqtlabs_retune_pre_fft_retune_pre_fft_0 = R"doc()doc";


static const char *__doc_gr_iqtlabs_retune_pre_fft_retune_pre_fft_1 = R"doc()doc";


static const char *__doc_gr_iqtlabs_retune_pre_fft_make = R"doc()doc";


static const char *__doc_gr_iqtlabs_retune_pre_fft_get_freq_start = R"doc()doc";


static const char *__doc_gr_iqtlabs_retune_pre_fft_get_freq_end = R"doc()doc";


static const char *__doc_gr_iqtlabs_retune_pre_fft_get_tune_freq = R"doc()doc";


static const char *__doc_gr_iqtlabs_retune_pre_fft_get_stare_mode = R"doc()doc";


26 changes: 25 additions & 1 deletion python/iqtlabs/bindings/retune_fft_python.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(retune_fft.h) */
/* BINDTOOL_HEADER_FILE_HASH(cff45390851d866fe94d901964d4c8e3) */
/* BINDTOOL_HEADER_FILE_HASH(43b2cd7ea0524e4efbb2e67aec9f6453) */
/***********************************************************************************/

#include <pybind11/complex.h>
Expand Down Expand Up @@ -65,6 +65,30 @@ void bind_retune_fft(py::module& m)





.def("get_freq_start",&retune_fft::get_freq_start,
D(retune_fft,get_freq_start)
)



.def("get_freq_end",&retune_fft::get_freq_end,
D(retune_fft,get_freq_end)
)



.def("get_tune_freq",&retune_fft::get_tune_freq,
D(retune_fft,get_tune_freq)
)



.def("get_stare_mode",&retune_fft::get_stare_mode,
D(retune_fft,get_stare_mode)
)

;


Expand Down
26 changes: 25 additions & 1 deletion python/iqtlabs/bindings/retune_pre_fft_python.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(retune_pre_fft.h) */
/* BINDTOOL_HEADER_FILE_HASH(d9cffb6f149f14f3c3f25e4ffbc910db) */
/* BINDTOOL_HEADER_FILE_HASH(265b0d93aae52b3c826e485fd6b36c16) */
/***********************************************************************************/

#include <pybind11/complex.h>
Expand Down Expand Up @@ -57,6 +57,30 @@ void bind_retune_pre_fft(py::module& m)





.def("get_freq_start",&retune_pre_fft::get_freq_start,
D(retune_pre_fft,get_freq_start)
)



.def("get_freq_end",&retune_pre_fft::get_freq_end,
D(retune_pre_fft,get_freq_end)
)



.def("get_tune_freq",&retune_pre_fft::get_tune_freq,
D(retune_pre_fft,get_tune_freq)
)



.def("get_stare_mode",&retune_pre_fft::get_stare_mode,
D(retune_pre_fft,get_stare_mode)
)

;


Expand Down
51 changes: 51 additions & 0 deletions python/iqtlabs/qa_retune_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,57 @@ def test_retune_fft_roll(self):
self.retune_fft(fft_roll=True, stare=True)


class qa_getters(gr_unittest.TestCase):
def test_pre_getter(self):
iqtlabs_retune_pre_fft_0 = retune_pre_fft(
nfft=1024,
samp_rate=int(1e6),
tune_jitter_hz=0,
fft_batch_size=1,
tag="rx_freq",
freq_start=int(1e6),
freq_end=0,
tune_step_hz=int(1e6),
tune_step_fft=256,
skip_tune_step_fft=0,
tuning_ranges="",
tag_now=False,
low_power_hold_down=False,
slew_rx_time=False,
)
self.assertTrue(iqtlabs_retune_pre_fft_0.get_stare_mode())
self.assertEqual(1.5e6, iqtlabs_retune_pre_fft_0.get_tune_freq())

def test_getter(self):
iqtlabs_retune_fft_0 = retune_fft(
tag="rx_freq",
nfft=1024,
samp_rate=int(1e6),
tune_jitter_hz=0,
freq_start=int(1e6),
freq_end=0,
tune_step_hz=int(1e6),
tune_step_fft=256,
skip_tune_step_fft=0,
fft_min=0,
fft_max=1e9,
sdir="",
write_step_fft=0,
bucket_range=1,
tuning_ranges="",
description="a text description",
rotate_secs=3600,
pre_fft=True,
tag_now=False,
low_power_hold_down=False,
slew_rx_time=False,
peak_fft_range=0,
)
self.assertTrue(iqtlabs_retune_fft_0.get_stare_mode())
self.assertEqual(1.5e6, iqtlabs_retune_fft_0.get_tune_freq())


if __name__ == "__main__":
gr_unittest.run(qa_retune_fft_no_roll)
gr_unittest.run(qa_retune_fft_roll)
gr_unittest.run(qa_getters)

0 comments on commit 955b643

Please sign in to comment.