From: Johnathan Corgan Date: Thu, 12 Nov 2009 19:26:53 +0000 (-0800) Subject: howto: added howto application X-Git-Url: https://git.gag.com/?p=debian%2Fgnuradio;a=commitdiff_plain;h=6fd6ef30cd1a711cd67b52db75665908534ec31b howto: added howto application --- diff --git a/gr-howto-write-a-block/Makefile.am b/gr-howto-write-a-block/Makefile.am index d5c46498..50551ed5 100644 --- a/gr-howto-write-a-block/Makefile.am +++ b/gr-howto-write-a-block/Makefile.am @@ -31,7 +31,7 @@ EXTRA_DIST = \ Makefile.swig.gen.t \ version.sh -SUBDIRS = config lib swig python grc +SUBDIRS = config lib swig python grc apps pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = diff --git a/gr-howto-write-a-block/apps/.gitignore b/gr-howto-write-a-block/apps/.gitignore new file mode 100644 index 00000000..b336cc7c --- /dev/null +++ b/gr-howto-write-a-block/apps/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-howto-write-a-block/apps/Makefile.am b/gr-howto-write-a-block/apps/Makefile.am new file mode 100644 index 00000000..85ed222c --- /dev/null +++ b/gr-howto-write-a-block/apps/Makefile.am @@ -0,0 +1,32 @@ +# +# Copyright 2009 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 $(top_srcdir)/Makefile.common + +if PYTHON + +dist_bin_SCRIPTS = \ + howto_square.py + +EXTRA_DIST = \ + howto_square.grc + +endif diff --git a/gr-howto-write-a-block/apps/howto_square.grc b/gr-howto-write-a-block/apps/howto_square.grc new file mode 100644 index 00000000..a8563698 --- /dev/null +++ b/gr-howto-write-a-block/apps/howto_square.grc @@ -0,0 +1,325 @@ + + + Thu Nov 12 11:26:07 2009 + + options + + id + howto_square + + + _enabled + True + + + title + + + + author + + + + description + + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + variable + + id + samp_rate + + + _enabled + True + + + value + 10e3 + + + _coordinate + (10, 170) + + + _rotation + 0 + + + + wxgui_scopesink2 + + id + sink + + + _enabled + True + + + type + float + + + title + Input + + + samp_rate + samp_rate + + + v_scale + 20 + + + v_offset + 0 + + + t_scale + 0.002 + + + ac_couple + False + + + xy_mode + False + + + num_inputs + 1 + + + win_size + + + + grid_pos + + + + notebook + + + + _coordinate + (691, 222) + + + _rotation + 0 + + + + howto_square_ff + + id + sqr + + + _enabled + True + + + _coordinate + (709, 344) + + + _rotation + 0 + + + + gr_throttle + + id + thr + + + _enabled + True + + + type + float + + + samples_per_second + samp_rate + + + vlen + 1 + + + _coordinate + (497, 340) + + + _rotation + 0 + + + + gr_vector_source_x + + id + src + + + _enabled + True + + + type + float + + + vector + [float(n)-50 for n in range(100)] + + + repeat + True + + + vlen + 1 + + + _coordinate + (246, 332) + + + _rotation + 0 + + + + wxgui_scopesink2 + + id + sink2 + + + _enabled + True + + + type + float + + + title + Output + + + samp_rate + samp_rate + + + v_scale + 0 + + + v_offset + 0 + + + t_scale + 0.002 + + + ac_couple + False + + + xy_mode + False + + + num_inputs + 1 + + + win_size + + + + grid_pos + + + + notebook + + + + _coordinate + (869, 324) + + + _rotation + 0 + + + + thr + sqr + 0 + 0 + + + src + thr + 0 + 0 + + + thr + sink + 0 + 0 + + + sqr + sink2 + 0 + 0 + + diff --git a/gr-howto-write-a-block/apps/howto_square.py b/gr-howto-write-a-block/apps/howto_square.py new file mode 100755 index 00000000..8d3d870d --- /dev/null +++ b/gr-howto-write-a-block/apps/howto_square.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +################################################## +# Gnuradio Python Flow Graph +# Title: Howto Square +# Generated: Thu Nov 12 11:26:07 2009 +################################################## + +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio import howto +from gnuradio.eng_option import eng_option +from gnuradio.gr import firdes +from gnuradio.wxgui import scopesink2 +from grc_gnuradio import wxgui as grc_wxgui +from optparse import OptionParser +import wx + +class howto_square(grc_wxgui.top_block_gui): + + def __init__(self): + grc_wxgui.top_block_gui.__init__(self, title="Howto Square") + + ################################################## + # Variables + ################################################## + self.samp_rate = samp_rate = 10e3 + + ################################################## + # Blocks + ################################################## + self.sink = scopesink2.scope_sink_f( + self.GetWin(), + title="Input", + sample_rate=samp_rate, + v_scale=20, + v_offset=0, + t_scale=0.002, + ac_couple=False, + xy_mode=False, + num_inputs=1, + ) + self.Add(self.sink.win) + self.sink2 = scopesink2.scope_sink_f( + self.GetWin(), + title="Output", + sample_rate=samp_rate, + v_scale=0, + v_offset=0, + t_scale=0.002, + ac_couple=False, + xy_mode=False, + num_inputs=1, + ) + self.Add(self.sink2.win) + self.sqr = howto.square_ff() + self.src = gr.vector_source_f(([float(n)-50 for n in range(100)]), True, 1) + self.thr = gr.throttle(gr.sizeof_float*1, samp_rate) + + ################################################## + # Connections + ################################################## + self.connect((self.thr, 0), (self.sqr, 0)) + self.connect((self.src, 0), (self.thr, 0)) + self.connect((self.thr, 0), (self.sink, 0)) + self.connect((self.sqr, 0), (self.sink2, 0)) + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.sink.set_sample_rate(self.samp_rate) + self.sink2.set_sample_rate(self.samp_rate) + +if __name__ == '__main__': + parser = OptionParser(option_class=eng_option, usage="%prog: [options]") + (options, args) = parser.parse_args() + tb = howto_square() + tb.Run(True) + diff --git a/gr-howto-write-a-block/configure.ac b/gr-howto-write-a-block/configure.ac index 9525ac0e..52c4639b 100644 --- a/gr-howto-write-a-block/configure.ac +++ b/gr-howto-write-a-block/configure.ac @@ -71,6 +71,7 @@ dnl AX_BOOST_WSERIALIZATION AC_CONFIG_FILES([\ Makefile \ + apps/Makefile \ config/Makefile \ grc/Makefile \ lib/Makefile \