summaryrefslogtreecommitdiff
path: root/gr-blocks/lib/copy_impl.cc
diff options
context:
space:
mode:
authorTom Rondeau <tom@trondeau.com>2014-06-24 18:37:19 -0400
committerTom Rondeau <tom@trondeau.com>2014-06-24 18:37:19 -0400
commit9d4d472e93aeb77f3e808499215a2f07d563a83c (patch)
tree4a7f1df3640ff15f3f07bbd2cce3572d9f1a2fa7 /gr-blocks/lib/copy_impl.cc
parent9289583ea51b278d3b27ce5aab6384798ac3e02d (diff)
blocks: adding a message port to the copy block to enable/disable copy.
Diffstat (limited to 'gr-blocks/lib/copy_impl.cc')
-rw-r--r--gr-blocks/lib/copy_impl.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/gr-blocks/lib/copy_impl.cc b/gr-blocks/lib/copy_impl.cc
index 564ea09ef4..02848369d1 100644
--- a/gr-blocks/lib/copy_impl.cc
+++ b/gr-blocks/lib/copy_impl.cc
@@ -45,6 +45,9 @@ namespace gr {
d_itemsize(itemsize),
d_enabled(true)
{
+ message_port_register_in(pmt::mp("en"));
+ set_msg_handler(pmt::mp("en"),
+ boost::bind(&copy_impl::handle_enable, this, _1));
}
copy_impl::~copy_impl()
@@ -52,6 +55,15 @@ namespace gr {
}
void
+ copy_impl::handle_enable(pmt::pmt_t msg)
+ {
+ if(pmt::is_bool(msg)) {
+ bool en = pmt::to_bool(msg);
+ d_enabled = en;
+ }
+ }
+
+ void
copy_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required)
{
unsigned ninputs = ninput_items_required.size();