Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added msg many to one to combine msg ports
- Loading branch information
1 parent
8c6b7ea
commit 122fbb0
Showing
8 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,25 @@ | |||
<?xml version="1.0"?> | |||
<block> | |||
<name>Extras: Msg M21</name> | |||
<key>extras_msg_many_to_one</key> | |||
<import>import gnuradio.extras as gr_extras</import> | |||
<make>gr_extras.msg_many_to_one($num_inputs)</make> | |||
<param> | |||
<name>Num Inputs</name> | |||
<key>num_inputs</key> | |||
<value>2</value> | |||
<type>int</type> | |||
</param> | |||
<sink> | |||
<name>in</name> | |||
<type></type> | |||
<nports>$num_inputs</nports> | |||
</sink> | |||
<source> | |||
<name>out</name> | |||
<type></type> | |||
</source> | |||
<doc> | |||
The message many to one block combines messages from several inputs. | |||
</doc> | |||
</block> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,39 @@ | |||
/* | |||
* Copyright 2012 Free Software Foundation, Inc. | |||
* | |||
* This file is part of GNU Radio | |||
* | |||
* GNU Radio is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation; either version 3, or (at your option) | |||
* any later version. | |||
* | |||
* GNU Radio is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with GNU Radio; see the file COPYING. If not, write to | |||
* the Free Software Foundation, Inc., 51 Franklin Street, | |||
* Boston, MA 02110-1301, USA. | |||
*/ | |||
|
|||
#ifndef INCLUDED_GR_EXTRAS_MSG_MANY_TO_ONE_H | |||
#define INCLUDED_GR_EXTRAS_MSG_MANY_TO_ONE_H | |||
|
|||
#include <gnuradio/extras/api.h> | |||
#include <gnuradio/block.h> | |||
|
|||
namespace gnuradio{ namespace extras{ | |||
|
|||
class GR_EXTRAS_API msg_many_to_one : virtual public block{ | |||
public: | |||
typedef boost::shared_ptr<msg_many_to_one> sptr; | |||
|
|||
static sptr make(const size_t num_inputs); | |||
}; | |||
|
|||
}} | |||
|
|||
#endif /* INCLUDED_GR_EXTRAS_MSG_MANY_TO_ONE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,68 @@ | |||
/* | |||
* Copyright 2012 Free Software Foundation, Inc. | |||
* | |||
* This file is part of GNU Radio | |||
* | |||
* GNU Radio is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation; either version 3, or (at your option) | |||
* any later version. | |||
* | |||
* GNU Radio is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with GNU Radio; see the file COPYING. If not, write to | |||
* the Free Software Foundation, Inc., 51 Franklin Street, | |||
* Boston, MA 02110-1301, USA. | |||
*/ | |||
|
|||
#include <gnuradio/extras/msg_many_to_one.h> | |||
#include <gr_io_signature.h> | |||
#include <boost/foreach.hpp> | |||
|
|||
using namespace gnuradio::extras; | |||
|
|||
class msg_many_to_one_impl : public msg_many_to_one | |||
{ | |||
public: | |||
msg_many_to_one_impl(const size_t num_inputs): | |||
block( | |||
"message many to one", | |||
gr_make_io_signature(num_inputs, num_inputs, 1), | |||
gr_make_io_signature(1, 1, 1) | |||
) | |||
{ | |||
_tags.reserve(1024); //something reasonably large so we dont malloc | |||
} | |||
|
|||
int work( | |||
const InputItems &input_items, | |||
const OutputItems &output_items | |||
){ | |||
std::vector<gr_tag_t> tags; | |||
for (size_t i = 0; i < input_items.size(); i++) | |||
{ | |||
const uint64_t nread = this->nitems_read(i); //number of items read on port i | |||
|
|||
//read all tags associated with port i for items in this work function | |||
this->get_tags_in_range(_tags, i, nread, nread+input_items[i].size()); | |||
|
|||
BOOST_FOREACH(const gr_tag_t &tag, _tags) | |||
{ | |||
this->add_item_tag(0, tag); | |||
} | |||
} | |||
|
|||
return output_items[0].size(); | |||
} | |||
|
|||
std::vector<gr_tag_t> _tags; | |||
}; | |||
|
|||
msg_many_to_one::sptr msg_many_to_one::make(const size_t num_inputs) | |||
{ | |||
return gnuradio::get_initial_sptr(new msg_many_to_one_impl(num_inputs)); | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters