diff options
-rw-r--r-- | gr-blocks/grc/blocks_block_tree.xml | 1 | ||||
-rw-r--r-- | gr-blocks/grc/blocks_streams_to_vector.xml | 67 | ||||
-rw-r--r-- | gr-blocks/include/blocks/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-blocks/include/blocks/streams_to_vector.h | 49 | ||||
-rw-r--r-- | gr-blocks/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-blocks/lib/streams_to_vector_impl.cc | 68 | ||||
-rw-r--r-- | gr-blocks/lib/streams_to_vector_impl.h | 44 | ||||
-rw-r--r-- | gr-blocks/swig/blocks_swig.i | 3 |
8 files changed, 234 insertions, 0 deletions
diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml index 1bcf672b9..6be3a21ef 100644 --- a/gr-blocks/grc/blocks_block_tree.xml +++ b/gr-blocks/grc/blocks_block_tree.xml @@ -82,5 +82,6 @@ <block>stream_to_streams.xml</block> <block>stream_to_vector.xml</block> <block>streams_to_stream.xml</block> + <block>streams_to_vector.xml</block> </cat> </cat> diff --git a/gr-blocks/grc/blocks_streams_to_vector.xml b/gr-blocks/grc/blocks_streams_to_vector.xml new file mode 100644 index 000000000..dc371f021 --- /dev/null +++ b/gr-blocks/grc/blocks_streams_to_vector.xml @@ -0,0 +1,67 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Streams to Vector +################################################### + --> +<block> + <name>Streams to Vector</name> + <key>blocks_streams_to_vector</key> + <import>from gnuradio import blocks</import> + <make>blocks.streams_to_vector($type.size*$vlen, $num_streams)</make> + <param> + <name>IO Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Num Streams</name> + <key>num_streams</key> + <value>2</value> + <type>int</type> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$num_streams > 0</check> + <check>$vlen >= 1</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + <nports>$num_streams</nports> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>$vlen*$num_streams</vlen> + </source> +</block> diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt index d7d13c4e0..fbd47aceb 100644 --- a/gr-blocks/include/blocks/CMakeLists.txt +++ b/gr-blocks/include/blocks/CMakeLists.txt @@ -124,6 +124,7 @@ install(FILES stream_to_streams.h stream_to_vector.h streams_to_stream.h + streams_to_vector.h uchar_to_float.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio/blocks COMPONENT "blocks_devel" diff --git a/gr-blocks/include/blocks/streams_to_vector.h b/gr-blocks/include/blocks/streams_to_vector.h new file mode 100644 index 000000000..ad55ac31f --- /dev/null +++ b/gr-blocks/include/blocks/streams_to_vector.h @@ -0,0 +1,49 @@ +/* -*- c++ -*- */ +/* + * 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_BLOCKS_STREAMS_TO_VECTOR_H +#define INCLUDED_BLOCKS_STREAMS_TO_VECTOR_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief convert N streams of items to 1 stream of vector length N + * \ingroup slicedice_blk + */ + class BLOCKS_API streams_to_vector : virtual public gr_sync_block + { + public: + + // gr::blocks::streams_to_vector::sptr + typedef boost::shared_ptr<streams_to_vector> sptr; + + static sptr make(size_t itemsize, size_t nstreams); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_STREAMS_TO_VECTOR_H */ diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index 504aafaa2..64436c07f 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -161,6 +161,7 @@ list(APPEND gr_blocks_sources stream_to_streams_impl.cc stream_to_vector_impl.cc streams_to_stream_impl.cc + streams_to_vector_impl.cc uchar_array_to_float.cc uchar_to_float_impl.cc ) diff --git a/gr-blocks/lib/streams_to_vector_impl.cc b/gr-blocks/lib/streams_to_vector_impl.cc new file mode 100644 index 000000000..c524a78e4 --- /dev/null +++ b/gr-blocks/lib/streams_to_vector_impl.cc @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "streams_to_vector_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + streams_to_vector::sptr streams_to_vector::make(size_t itemsize, size_t nstreams) + { + return gnuradio::get_initial_sptr(new streams_to_vector_impl(itemsize, nstreams)); + } + + streams_to_vector_impl::streams_to_vector_impl(size_t itemsize, size_t nstreams) + : gr_sync_block ("streams_to_vector", + gr_make_io_signature (nstreams, nstreams, itemsize), + gr_make_io_signature (1, 1, nstreams * itemsize)) + { + } + + int + streams_to_vector_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + size_t itemsize = input_signature()->sizeof_stream_item(0); + int nstreams = input_items.size(); + + const char **inv = (const char **) &input_items[0]; + char *out = (char *) output_items[0]; + + for (int i = 0; i < noutput_items; i++){ + for (int j = 0; j < nstreams; j++){ + memcpy(out, inv[j], itemsize); + inv[j] += itemsize; + out += itemsize; + } + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/streams_to_vector_impl.h b/gr-blocks/lib/streams_to_vector_impl.h new file mode 100644 index 000000000..4a14e9d4f --- /dev/null +++ b/gr-blocks/lib/streams_to_vector_impl.h @@ -0,0 +1,44 @@ +/* -*- c++ -*- */ +/* + * 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_STREAMS_TO_VECTOR_IMPL_H +#define INCLUDED_STREAMS_TO_VECTOR_IMPL_H + +#include <blocks/streams_to_vector.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API streams_to_vector_impl : public streams_to_vector + { + public: + streams_to_vector_impl(size_t itemsize, size_t nstreams); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_STREAMS_TO_VECTOR_IMPL_H */ diff --git a/gr-blocks/swig/blocks_swig.i b/gr-blocks/swig/blocks_swig.i index d0c97a2d1..69374e19d 100644 --- a/gr-blocks/swig/blocks_swig.i +++ b/gr-blocks/swig/blocks_swig.i @@ -102,6 +102,7 @@ #include "blocks/stream_to_streams.h" #include "blocks/stream_to_vector.h" #include "blocks/streams_to_stream.h" +#include "blocks/streams_to_vector.h" #include "blocks/sub_ff.h" #include "blocks/sub_ss.h" #include "blocks/sub_ii.h" @@ -186,6 +187,7 @@ %include "blocks/stream_to_streams.h" %include "blocks/stream_to_vector.h" %include "blocks/streams_to_stream.h" +%include "blocks/streams_to_vector.h" %include "blocks/sub_ff.h" %include "blocks/sub_ss.h" %include "blocks/sub_ii.h" @@ -269,6 +271,7 @@ GR_SWIG_BLOCK_MAGIC2(blocks, stream_mux); GR_SWIG_BLOCK_MAGIC2(blocks, stream_to_streams); GR_SWIG_BLOCK_MAGIC2(blocks, stream_to_vector); GR_SWIG_BLOCK_MAGIC2(blocks, streams_to_stream); +GR_SWIG_BLOCK_MAGIC2(blocks, streams_to_vector); GR_SWIG_BLOCK_MAGIC2(blocks, sub_ff); GR_SWIG_BLOCK_MAGIC2(blocks, sub_ss); GR_SWIG_BLOCK_MAGIC2(blocks, sub_ii); |