[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 02/04: blocks: adding abs_xx block/template
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 02/04: blocks: adding abs_xx block/template |
Date: |
Sat, 22 Feb 2014 22:27:32 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 9725dae9e2edf02eb508f438137bb9ba92ee09c4
Author: Tim O'Shea <address@hidden>
Date: Thu Feb 20 12:45:56 2014 -0500
blocks: adding abs_xx block/template
---
gr-blocks/grc/blocks_abs_xx.xml | 49 +++++++++++++++++++
gr-blocks/grc/blocks_block_tree.xml | 1 +
gr-blocks/include/gnuradio/blocks/CMakeLists.txt | 1 +
gr-blocks/include/gnuradio/blocks/abs_XX.h.t | 58 ++++++++++++++++++++++
gr-blocks/lib/CMakeLists.txt | 1 +
gr-blocks/lib/abs_XX_impl.cc.t | 62 ++++++++++++++++++++++++
gr-blocks/lib/abs_XX_impl.h.t | 46 ++++++++++++++++++
gr-blocks/swig/blocks_swig2.i | 9 ++++
8 files changed, 227 insertions(+)
diff --git a/gr-blocks/grc/blocks_abs_xx.xml b/gr-blocks/grc/blocks_abs_xx.xml
new file mode 100644
index 0000000..65ef97d
--- /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 bf0c55f..22d0e5c 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 c120242..7b8a0d6 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 0000000..a30e752
--- /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 fba0e4b..0e7aab5 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 0000000..2a701ad
--- /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 <@address@hidden>
+#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 0000000..b31ef5f
--- /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/@address@hidden>
+
+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 f22af80..fddeab4 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);