summaryrefslogtreecommitdiff
path: root/gr-analog/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gr-analog/lib')
-rw-r--r--gr-analog/lib/sig_source_X_impl.cc.t32
-rw-r--r--gr-analog/lib/sig_source_X_impl.h.t2
2 files changed, 32 insertions, 2 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,
diff --git a/gr-analog/lib/sig_source_X_impl.h.t b/gr-analog/lib/sig_source_X_impl.h.t
index bd3609df16..f5dfd5c4f6 100644
--- a/gr-analog/lib/sig_source_X_impl.h.t
+++ b/gr-analog/lib/sig_source_X_impl.h.t
@@ -59,7 +59,7 @@ namespace gr {
void set_sampling_freq(double sampling_freq);
void set_waveform(gr_waveform_t waveform);
- void set_frequency_msg(pmt::pmt_t msg){ set_frequency(pmt::to_double(msg)); };
+ void set_frequency_msg(pmt::pmt_t msg);
void set_frequency(double frequency);
void set_amplitude(double ampl);
void set_offset(@TYPE@ offset);