diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2016-04-15 21:02:51 +0200 |
---|---|---|
committer | Sebastian Koslowski <koslowski@kit.edu> | 2016-04-15 21:09:19 +0200 |
commit | 8cfc8b3408916ccb156fc25102bc1d9346bc004b (patch) | |
tree | 5c38adfedca3f4f4073d0621840ea578dd67ed4d /gr-analog/lib/sig_source_X_impl.cc.t | |
parent | 036264ef5c8e2376acd426a99ca42d29390e3e2a (diff) | |
parent | bdf85171b8a35004cdbf634f48ff696787b5fbde (diff) |
Merge remote-tracking branch 'upstream/master' into refactoring
Diffstat (limited to 'gr-analog/lib/sig_source_X_impl.cc.t')
-rw-r--r-- | gr-analog/lib/sig_source_X_impl.cc.t | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/gr-analog/lib/sig_source_X_impl.cc.t b/gr-analog/lib/sig_source_X_impl.cc.t index 227d4ba46e..017177eae0 100644 --- a/gr-analog/lib/sig_source_X_impl.cc.t +++ b/gr-analog/lib/sig_source_X_impl.cc.t @@ -53,7 +53,7 @@ namespace gr { d_frequency(frequency), d_ampl(ampl), d_offset(offset) { set_frequency(frequency); - + message_port_register_in(pmt::mp("freq")); set_msg_handler(pmt::mp("freq"), boost::bind(&@IMPL_NAME@::set_frequency_msg, this, _1)); } @@ -62,6 +62,36 @@ namespace gr { { } + void + @IMPL_NAME@::set_frequency_msg(pmt::pmt_t msg) + { + // Accepts either a number that is assumed to be the new + // frequency or a key:value pair message where the key must be + // "freq" and the value is the new frequency. + + if(pmt::is_number(msg)) { + set_frequency(pmt::to_double(msg)); + } + else if(pmt::is_pair(msg)) { + pmt::pmt_t key = pmt::car(msg); + pmt::pmt_t val = pmt::cdr(msg); + if(pmt::eq(key, pmt::intern("freq"))) { + if(pmt::is_number(val)) { + set_frequency(pmt::to_double(val)); + } + } + else { + GR_LOG_WARN(d_logger, boost::format("Set Frequency Message must have " + "the key = 'freq'; got '%1%'.") \ + % pmt::write_string(key)); + } + } + else { + GR_LOG_WARN(d_logger, "Set Frequency Message must be either a number or a " + "key:value pair where the key is 'freq'."); + } + } + int @IMPL_NAME@::work(int noutput_items, gr_vector_const_void_star &input_items, |