summaryrefslogtreecommitdiff
path: root/gr-scigen
diff options
context:
space:
mode:
authorManoj Gudi2013-10-07 20:19:55 +0530
committerManoj Gudi2013-10-07 20:20:35 +0530
commit1826d0763c8595997f5f4af1fdb0354e9c0998ad (patch)
treeacbd852cd5a1bf17241b1038b5e37a0e72e64612 /gr-scigen
parent452defdb4a78e9e826740ddf4b9673e926c568a4 (diff)
parent24b640997ba7fee0c725e65f401f5cbebdab8d08 (diff)
downloadgnuradio-1826d0763c8595997f5f4af1fdb0354e9c0998ad.tar.gz
gnuradio-1826d0763c8595997f5f4af1fdb0354e9c0998ad.tar.bz2
gnuradio-1826d0763c8595997f5f4af1fdb0354e9c0998ad.zip
README change
Diffstat (limited to 'gr-scigen')
-rw-r--r--gr-scigen/CMakeLists.txt55
-rw-r--r--gr-scigen/doc/CMakeLists.txt23
-rw-r--r--gr-scigen/doc/README.scigen13
-rw-r--r--gr-scigen/doc/scigen.dox29
-rw-r--r--gr-scigen/grc/CMakeLists.txt24
-rw-r--r--gr-scigen/grc/scigen.xml82
-rw-r--r--gr-scigen/python/CMakeLists.txt62
-rw-r--r--gr-scigen/python/__init__.py52
-rw-r--r--gr-scigen/python/generic.py66
-rwxr-xr-xgr-scigen/python/qa_scigen.py58
-rw-r--r--gr-scigen/python/scigen.py1
11 files changed, 465 insertions, 0 deletions
diff --git a/gr-scigen/CMakeLists.txt b/gr-scigen/CMakeLists.txt
new file mode 100644
index 000000000..7eed748c0
--- /dev/null
+++ b/gr-scigen/CMakeLists.txt
@@ -0,0 +1,55 @@
+# 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.
+
+########################################################################
+# Setup dependencies
+########################################################################
+#include(GrBoost)
+
+#find_package(SCIGENW3f)
+
+########################################################################
+# Register component
+########################################################################
+include(GrComponent)
+
+GR_REGISTER_COMPONENT("gr-scigen" ENABLE_GR_SCIGEN
+ ENABLE_GRUEL
+ ENABLE_VOLK
+ Boost_FOUND
+ ENABLE_GR_CORE
+)
+
+########################################################################
+# Begin conditional configuration
+########################################################################
+if(ENABLE_GR_SCIGEN)
+
+########################################################################
+# Add subdirectories
+########################################################################
+if(ENABLE_PYTHON)
+ add_subdirectory(python)
+ add_subdirectory(grc)
+endif(ENABLE_PYTHON)
+#add_subdirectory(examples)
+add_subdirectory(doc)
+
+
+endif(ENABLE_GR_SCIGEN)
diff --git a/gr-scigen/doc/CMakeLists.txt b/gr-scigen/doc/CMakeLists.txt
new file mode 100644
index 000000000..80ce59153
--- /dev/null
+++ b/gr-scigen/doc/CMakeLists.txt
@@ -0,0 +1,23 @@
+# 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.
+
+install(
+ FILES README.scigen
+ DESTINATION ${GR_PKG_DOC_DIR}
+)
diff --git a/gr-scigen/doc/README.scigen b/gr-scigen/doc/README.scigen
new file mode 100644
index 000000000..61e8f6bf8
--- /dev/null
+++ b/gr-scigen/doc/README.scigen
@@ -0,0 +1,13 @@
+This is the gr-scigen package. It contains signal processing blocks to
+perform FFTs and FFT-related functionality.
+
+The Python namespace is in gnuradio.scigen, which would be normally
+imported as:
+
+ from gnuradio import scigen
+
+See the Doxygen documentation for details about the blocks available
+in this package. A quick listing of the details can be found in Python
+after importing by using:
+
+ help(scigen)
diff --git a/gr-scigen/doc/scigen.dox b/gr-scigen/doc/scigen.dox
new file mode 100644
index 000000000..8843d0560
--- /dev/null
+++ b/gr-scigen/doc/scigen.dox
@@ -0,0 +1,29 @@
+/*! \page page_fft FFT Signal Processing Blocks
+
+\section Introduction
+
+This is the gr-scigen package. It contains signal processing blocks to
+perform FFTs and FFT-related functionality.
+
+The Python namespace is in gnuradio.fft, which would be normally
+imported as:
+
+\code
+ from gnuradio import scigen
+\endcode
+
+See the Doxygen documentation for details about the blocks available
+in this package. A quick listing of the details can be found in Python
+after importing by using:
+
+\code
+ help(scigen)
+\endcode
+
+\section Dependencies
+
+The scigen blocks require the following dependencies.
+
+\li fftw3f (>= 3.0) http://www.fftw.org/download.html
+
+*/
diff --git a/gr-scigen/grc/CMakeLists.txt b/gr-scigen/grc/CMakeLists.txt
new file mode 100644
index 000000000..ca8f65d18
--- /dev/null
+++ b/gr-scigen/grc/CMakeLists.txt
@@ -0,0 +1,24 @@
+# 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.
+
+install(FILES
+ scigen.xml
+ DESTINATION ${GRC_BLOCKS_DIR}
+ COMPONENT "scigen_python"
+)
diff --git a/gr-scigen/grc/scigen.xml b/gr-scigen/grc/scigen.xml
new file mode 100644
index 000000000..d8c7a25bf
--- /dev/null
+++ b/gr-scigen/grc/scigen.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Add Block:
+## all types, 1 output, 2 to inf inputs
+###################################################
+ -->
+<block>
+ <name>generic</name>
+ <key>scigen_generic</key>
+ <category>scigen</category>
+
+ <import>import scigen</import>
+ <make>scigen.generic()
+self.$(id).set_parameters($func_name, $window)
+ </make>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option><name>FC32_FC32</name><key>fc32_fc32</key></option>
+ <option><name>F32_F32</name><key>f32_f32</key></option>
+ <option><name>SC32_SC32</name><key>sc32_sc32</key></option>
+ <option><name>S32_S32</name><key>s32_s32</key></option>
+ <option><name>SC16_SC16</name><key>sc16_sc16</key></option>
+ <option><name>S16_S16</name><key>s16_s16</key></option>
+ <option><name>SC8_SC8</name><key>sc8_sc8</key></option>
+ <option><name>S8_S8</name><key>s8_s8</key></option>
+ </param>
+ <param>
+ <name>Num Inputs</name>
+ <key>num_inputs</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+
+ <param>
+ <name>Window</name>
+ <key>window</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+
+ <param>
+ <name>Function Name</name>
+ <key>func_name</key>
+ <value>""</value>
+ <type>string</type>
+ </param>
+
+
+ <!--
+ Check if number of inputs are greater than 0, and if vector length
+ is greater than 0.
+ -->
+ <check>$num_inputs &gt; 0</check>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>$(str($type).split('_')[0])</type>
+ <vlen>$vlen</vlen>
+ <nports>$num_inputs</nports>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$(str($type).split('_')[1])</type>
+ <vlen>$vlen</vlen>
+ </source>
+ <doc>
+Scilab Generic Block
+
+> Check if your scilab function requires multiple inputs
+> Make sure you have same n_input_items when you have multiple inputs
+ </doc>
+</block>
diff --git a/gr-scigen/python/CMakeLists.txt b/gr-scigen/python/CMakeLists.txt
new file mode 100644
index 000000000..ccda0a2ad
--- /dev/null
+++ b/gr-scigen/python/CMakeLists.txt
@@ -0,0 +1,62 @@
+# 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(GrPython)
+
+GR_PYTHON_INSTALL(
+ FILES
+ __init__.py
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio/scigen
+ COMPONENT "scigen_python"
+)
+
+GR_PYTHON_INSTALL(
+ FILES
+ scigen.py
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio/scigen
+ COMPONENT "scigen_python"
+)
+
+
+GR_PYTHON_INSTALL(
+ FILES
+ generic.py
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio/scigen
+ COMPONENT "scigen_python"
+)
+
+
+########################################################################
+# Handle the unit tests
+########################################################################
+if(ENABLE_TESTING)
+
+list(APPEND GR_TEST_PYTHON_DIRS
+ ${CMAKE_BINARY_DIR}/gr-scigen/python
+)
+list(APPEND GR_TEST_TARGET_DEPS gnuradio-scigen)
+
+include(GrTest)
+file(GLOB py_qa_test_files "qa_*.py")
+foreach(py_qa_test_file ${py_qa_test_files})
+ get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
+ GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file})
+endforeach(py_qa_test_file)
+endif(ENABLE_TESTING)
diff --git a/gr-scigen/python/__init__.py b/gr-scigen/python/__init__.py
new file mode 100644
index 000000000..11a291ae4
--- /dev/null
+++ b/gr-scigen/python/__init__.py
@@ -0,0 +1,52 @@
+#
+# Copyright 2008,2009 Free Software Foundation, Inc.
+#
+# This application 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.
+#
+# This application 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+# The presence of this file turns this directory into a Python package
+
+'''
+This is the GNU Radio SCIGEN module. Place your Python package
+description here (python/__init__.py).
+'''
+
+# ----------------------------------------------------------------
+# Temporary workaround for ticket:181 (swig+python problem)
+import sys
+_RTLD_GLOBAL = 0
+try:
+ from dl import RTLD_GLOBAL as _RTLD_GLOBAL
+except ImportError:
+ try:
+ from DLFCN import RTLD_GLOBAL as _RTLD_GLOBAL
+ except ImportError:
+ pass
+
+if _RTLD_GLOBAL != 0:
+ _dlopenflags = sys.getdlopenflags()
+ sys.setdlopenflags(_dlopenflags|_RTLD_GLOBAL)
+# ----------------------------------------------------------------
+
+
+# import any pure python here
+from generic import *
+#
+
+# ----------------------------------------------------------------
+# Tail of workaround
+if _RTLD_GLOBAL != 0:
+ sys.setdlopenflags(_dlopenflags) # Restore original flags
+# ----------------------------------------------------------------
diff --git a/gr-scigen/python/generic.py b/gr-scigen/python/generic.py
new file mode 100644
index 000000000..f7807fdbc
--- /dev/null
+++ b/gr-scigen/python/generic.py
@@ -0,0 +1,66 @@
+import gras
+import numpy
+
+class generic(gras.Block):
+
+ def __init__(self):
+ gras.Block.__init__(self,
+ name="generic",
+ in_sig=[numpy.float32],
+ out_sig=[numpy.float32])
+
+ def set_parameters(self,func_name,window):
+ self.n = window
+ self.func_name = func_name
+
+ # Check if value of window is integral of length of input source vector
+ # For cases like -> input = [3 , 4, 5 ,6] & window = 3
+ def isIntegralWin(self, input_item, window):
+ if (len(input_item) % window ):
+ raise Exception("Value of Window should be an integral value of length of input items")
+
+
+ def work(self, input_items, output_items):
+
+ # Limit output_items to just the size of window
+ output_items[0] = output_items[0][:self.n]
+ from scilab import Scilab
+ Sci = Scilab()
+
+ # Check number of input_instances
+ n_input_items = len(input_items)
+
+ # Create output string instance which will be evaluated
+ out_eval_string = 'eval("Sci.'+self.func_name+'('
+
+ # Iterate for n_input_items
+ for i in range(n_input_items):
+
+ # Check window condition
+ self.isIntegralWin(input_items[i][:], self.n)
+
+ # If the window is greater than 1, input_items[i][:self.n] looks like [1 2 3 4 5] which is err for python since it requires comma as delimiters
+ if self.n == 1:
+ out_eval_string = out_eval_string + str(input_items[i][:self.n]) + ","
+ else:
+ print 'IN',str(input_items[i][:self.n])
+ out_eval_string = out_eval_string + (str(input_items[i][:self.n].tolist())) + "," # Replace 10spaces with a singe comma
+
+ out_eval_string = out_eval_string.rstrip(",") + ')")'
+ print "STRING ",str(out_eval_string)
+
+ # for functions like sin
+ if n_input_items == 1 and self.n == 1:
+ output_items[0][:self.n] = eval(out_eval_string)
+ else:
+ output_items[0] = eval(out_eval_string)
+
+ print "OUT",output_items[0]
+ #print 'SIZE,', output_items[0].size
+
+ #Write a for loop for n_inputs
+ for i in range(n_input_items):
+ self.consume(i,self.n) # Consume from port 0 input_items
+
+ self.produce(0,self.n) # Produce from port 0 output_items
+
diff --git a/gr-scigen/python/qa_scigen.py b/gr-scigen/python/qa_scigen.py
new file mode 100755
index 000000000..f06dc8b5d
--- /dev/null
+++ b/gr-scigen/python/qa_scigen.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 <+YOU OR YOUR COMPANY+>.
+#
+# This 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.
+#
+# This software 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 this software; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, gr_unittest
+#import mymod_swig as mymod
+from generic import *
+
+
+class qa_generic (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001_t (self):
+
+ src0 = numpy.arange(0,3.1416,1)
+
+ src0 = gr.vector_source_f(src0)
+ expected_result = (0.0, 0.8414709568023682, 0.9092974066734314, 0.14112000167369843)
+
+ sqr = generic()
+ sqr.set_parameters("sin",1)
+
+ dst = gr.vector_sink_f()
+
+ self.tb.connect(src0, (sqr,0)) # src0(vector_source) -> sqr_input_0
+ self.tb.connect(sqr,dst) # sqr_output_0 -> dst (vector_source)
+
+ self.tb.run()
+
+ result_data = dst.data()
+ print result_data, "Result data"
+
+ self.assertFloatTuplesAlmostEqual(expected_result, result_data, 6)
+
+
+if __name__ == '__main__':
+ gr_unittest.main()
diff --git a/gr-scigen/python/scigen.py b/gr-scigen/python/scigen.py
new file mode 100644
index 000000000..ca5556bc8
--- /dev/null
+++ b/gr-scigen/python/scigen.py
@@ -0,0 +1 @@
+from generic import *