diff options
-rw-r--r-- | gr-blocks/grc/blocks_abs_xx.xml | 49 | ||||
-rw-r--r-- | gr-blocks/grc/blocks_block_tree.xml | 1 | ||||
-rw-r--r-- | gr-blocks/include/gnuradio/blocks/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-blocks/include/gnuradio/blocks/abs_XX.h.t | 58 | ||||
-rw-r--r-- | gr-blocks/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-blocks/lib/abs_XX_impl.cc.t | 62 | ||||
-rw-r--r-- | gr-blocks/lib/abs_XX_impl.h.t | 46 | ||||
-rw-r--r-- | gr-blocks/swig/blocks_swig2.i | 9 |
8 files changed, 227 insertions, 0 deletions
diff --git a/gr-blocks/grc/blocks_abs_xx.xml b/gr-blocks/grc/blocks_abs_xx.xml new file mode 100644 index 0000000000..65ef97ddff --- /dev/null +++ b/gr-blocks/grc/blocks_abs_xx.xml @@ -0,0 +1,49 @@ +<?xml version="1.0"?> +<!-- +################################################### +## Abs Block +################################################### + --> +<block> + <name>Abs</name> + <key>blocks_abs_xx</key> + <import>from gnuradio import blocks</import> + <make>blocks.abs_$(type.fcn)()</make> + <param> + <name>IO Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:ii</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:ss</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:ff</opt> + </option> + </param> + <param> + <name>Num Inputs</name> + <key>num_inputs</key> + <value>1</value> + <type>int</type> + </param> + <check>$num_inputs >= 1</check> + <sink> + <name>in</name> + <type>$type</type> + <nports>$num_inputs</nports> + </sink> + <source> + <name>out</name> + <type>$type</type> + <nports>$num_inputs</nports> + </source> +</block> diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml index bf0c55ff2e..22d0e5c7c8 100644 --- a/gr-blocks/grc/blocks_block_tree.xml +++ b/gr-blocks/grc/blocks_block_tree.xml @@ -87,6 +87,7 @@ </cat> <cat> <name>Math Operators</name> + <block>blocks_abs_xx</block> <block>blocks_add_xx</block> <block>blocks_add_const_vxx</block> <block>blocks_divide_xx</block> diff --git a/gr-blocks/include/gnuradio/blocks/CMakeLists.txt b/gr-blocks/include/gnuradio/blocks/CMakeLists.txt index c120242c01..7b8a0d6dc4 100644 --- a/gr-blocks/include/gnuradio/blocks/CMakeLists.txt +++ b/gr-blocks/include/gnuradio/blocks/CMakeLists.txt @@ -64,6 +64,7 @@ endmacro(expand_h) ######################################################################## # Invoke macro to generate various sources ######################################################################## +expand_h(abs_XX ss ii ff) expand_h(add_XX ss ii cc) expand_h(add_const_XX bb ss ii ff cc) expand_h(add_const_vXX bb ss ii ff cc) diff --git a/gr-blocks/include/gnuradio/blocks/abs_XX.h.t b/gr-blocks/include/gnuradio/blocks/abs_XX.h.t new file mode 100644 index 0000000000..a30e752b4b --- /dev/null +++ b/gr-blocks/include/gnuradio/blocks/abs_XX.h.t @@ -0,0 +1,58 @@ +/* -*- 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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <gnuradio/blocks/api.h> +#include <gnuradio/sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief output[m] = abs(input[m]) for all M streams. + * \ingroup boolean_operators_blk + * + * \details + * absolute value of data stream (Strip sign) + */ + class BLOCKS_API @NAME@ : virtual public sync_block + { + + public: + + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + /*! + * \brief Create an instance of @NAME@ + */ + static sptr make(); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index fba0e4b771..0e7aab5e7c 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -90,6 +90,7 @@ endmacro(expand_cc_h_impl) ######################################################################## # Invoke macro to generate various sources ######################################################################## +expand_cc_h_impl(abs_XX ss ii ff) expand_cc_h_impl(add_XX ss ii cc) expand_cc_h_impl(add_const_XX bb ss ii ff cc) expand_cc_h_impl(add_const_vXX bb ss ii ff cc) diff --git a/gr-blocks/lib/abs_XX_impl.cc.t b/gr-blocks/lib/abs_XX_impl.cc.t new file mode 100644 index 0000000000..2a701add19 --- /dev/null +++ b/gr-blocks/lib/abs_XX_impl.cc.t @@ -0,0 +1,62 @@ +/* -*- 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. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <@NAME_IMPL@.h> +#include <gnuradio/io_signature.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr @NAME@::make() + { + return gnuradio::get_initial_sptr(new @NAME_IMPL@()); + } + + @NAME_IMPL@::@NAME_IMPL@() + : sync_block ("@NAME@", + io_signature::make (1, 1, sizeof (@I_TYPE@)), + io_signature::make (1, 1, sizeof (@O_TYPE@))) + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @I_TYPE@ *iptr = (@I_TYPE@ *) input_items[0]; + @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; + + for(int i=0; i<noutput_items; i++) + optr[i] = abs(iptr[i]); + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/abs_XX_impl.h.t b/gr-blocks/lib/abs_XX_impl.h.t new file mode 100644 index 0000000000..b31ef5fb31 --- /dev/null +++ b/gr-blocks/lib/abs_XX_impl.h.t @@ -0,0 +1,46 @@ +/* -*- 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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <gnuradio/blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API @NAME_IMPL@ : public @NAME@ + { + public: + @NAME_IMPL@(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/swig/blocks_swig2.i b/gr-blocks/swig/blocks_swig2.i index f22af806e6..fddeab401d 100644 --- a/gr-blocks/swig/blocks_swig2.i +++ b/gr-blocks/swig/blocks_swig2.i @@ -31,6 +31,9 @@ %include "feval.i" %{ +#include "gnuradio/blocks/abs_ff.h" +#include "gnuradio/blocks/abs_ss.h" +#include "gnuradio/blocks/abs_ii.h" #include "gnuradio/blocks/add_ff.h" #include "gnuradio/blocks/add_ss.h" #include "gnuradio/blocks/add_ii.h" @@ -74,6 +77,9 @@ #include "gnuradio/blocks/divide_cc.h" %} +%include "gnuradio/blocks/abs_ff.h" +%include "gnuradio/blocks/abs_ss.h" +%include "gnuradio/blocks/abs_ii.h" %include "gnuradio/blocks/add_ff.h" %include "gnuradio/blocks/add_ss.h" %include "gnuradio/blocks/add_ii.h" @@ -116,6 +122,9 @@ %include "gnuradio/blocks/divide_ii.h" %include "gnuradio/blocks/divide_cc.h" +GR_SWIG_BLOCK_MAGIC2(blocks, abs_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, abs_ss); +GR_SWIG_BLOCK_MAGIC2(blocks, abs_ii); GR_SWIG_BLOCK_MAGIC2(blocks, add_ff); GR_SWIG_BLOCK_MAGIC2(blocks, add_ss); GR_SWIG_BLOCK_MAGIC2(blocks, add_ii); |