diff options
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, |