summaryrefslogtreecommitdiff
path: root/gnuradio-examples/python/hier/digital
diff options
context:
space:
mode:
authorjcorgan2007-04-28 02:20:28 +0000
committerjcorgan2007-04-28 02:20:28 +0000
commitb26ea69676c09f5366a9e2f33b11ae5a7521ffe5 (patch)
tree0641c1c25d6e827f70941e07f4611d0a2b6b83cd /gnuradio-examples/python/hier/digital
parent00696b9f754338de9362932c1ecfb1e144a38786 (diff)
downloadgnuradio-b26ea69676c09f5366a9e2f33b11ae5a7521ffe5.tar.gz
gnuradio-b26ea69676c09f5366a9e2f33b11ae5a7521ffe5.tar.bz2
gnuradio-b26ea69676c09f5366a9e2f33b11ae5a7521ffe5.zip
Merged -r 5137:5174 from developer branch jcorgan/hb. Trunk passes distcheck. Converts gr.hier_block2 API to not use 'define_component' methodology anymore.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@5177 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-examples/python/hier/digital')
-rw-r--r--gnuradio-examples/python/hier/digital/Makefile.am2
-rwxr-xr-xgnuradio-examples/python/hier/digital/benchmark_loopback.py48
-rwxr-xr-xgnuradio-examples/python/hier/digital/benchmark_rx.py14
-rwxr-xr-xgnuradio-examples/python/hier/digital/benchmark_tx.py15
-rw-r--r--gnuradio-examples/python/hier/digital/receive_path.py20
-rw-r--r--gnuradio-examples/python/hier/digital/receive_path_lb.py10
-rw-r--r--gnuradio-examples/python/hier/digital/transmit_path.py18
-rw-r--r--gnuradio-examples/python/hier/digital/transmit_path_lb.py11
8 files changed, 36 insertions, 102 deletions
diff --git a/gnuradio-examples/python/hier/digital/Makefile.am b/gnuradio-examples/python/hier/digital/Makefile.am
index 9cdbc7121..5a098eea7 100644
--- a/gnuradio-examples/python/hier/digital/Makefile.am
+++ b/gnuradio-examples/python/hier/digital/Makefile.am
@@ -33,3 +33,5 @@ EXTRA_DIST = \
transmit_path_lb.py \
tunnel.py \
tx_voice.py
+
+MOSTLYCLEANFILES = *~ *.pyc *.dat
diff --git a/gnuradio-examples/python/hier/digital/benchmark_loopback.py b/gnuradio-examples/python/hier/digital/benchmark_loopback.py
index 92a7bb072..f560468d7 100755
--- a/gnuradio-examples/python/hier/digital/benchmark_loopback.py
+++ b/gnuradio-examples/python/hier/digital/benchmark_loopback.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
#!/usr/bin/env python
#
-# Copyright 2005, 2006 Free Software Foundation, Inc.
+# Copyright 2005, 2006,2007 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -45,27 +45,23 @@ class awgn_channel(gr.hier_block2):
else:
rseed = int(time.time())
self.noise = gr.noise_source_c(gr.GR_GAUSSIAN, noise_voltage, rseed)
- self.define_component("noise", self.noise)
- self.define_component("adder", gr.add_cc())
+ self.adder = gr.add_cc()
# Create the frequency offset
- self.define_component("offset", gr.sig_source_c((sample_rate*1.0), gr.GR_SIN_WAVE,
- frequency_offset, 1.0, 0.0))
- self.define_component("mixer", gr.multiply_cc())
+ self.offset = gr.sig_source_c((sample_rate*1.0), gr.GR_SIN_WAVE, frequency_offset, 1.0, 0.0)
+ self.mixer = gr.multiply_cc()
# Connect the components
- self.connect("self", 0, "mixer", 0)
- self.connect("offset", 0, "mixer", 1)
- self.connect("mixer", 0, "adder", 0)
- self.connect("noise", 0, "adder", 1)
- self.connect("adder", 0, "self", 0)
+ self.connect(self, (self.mixer, 0))
+ self.connect(self.offset, (self.mixer, 1))
+ self.connect(self.mixer, (self.adder, 0))
+ self.connect(self.noise, (self.adder, 1))
+ self.connect(self.adder, self)
-class my_graph(gr.hier_block2):
+class my_graph(gr.top_block):
def __init__(self, mod_class, demod_class, rx_callback, options):
- gr.hier_block2.__init__(self, "my_graph",
- gr.io_signature(0,0,0), # Input signature
- gr.io_signature(0,0,0)) # Output signature
+ gr.top_block.__init__(self, "my_graph")
channelon = True;
@@ -82,27 +78,9 @@ class my_graph(gr.hier_block2):
if channelon:
self.channel = awgn_channel(options.sample_rate, noise_voltage, frequency_offset, options.seed)
-
- # Define the components
- self.define_component("txpath", self.txpath)
- self.define_component("throttle", self.throttle)
- self.define_component("channel", self.channel)
- self.define_component("rxpath", self.rxpath)
-
- # Connect components
- self.connect("txpath", 0, "throttle", 0)
- self.connect("throttle", 0, "channel", 0)
- self.connect("channel", 0, "rxpath", 0)
+ self.connect(self.txpath, self.throttle, self.channel, self.rxpath)
else:
- # Define the components
- self.define_component("txpath", self.txpath)
- self.define_component("throttle", self.throttle)
- self.define_component("rxpath", self.rxpath)
-
- # Connect components
- self.connect("txpath", 0, "throttle", 0)
- self.connect("throttle", 0, "rxpath", 0)
-
+ self.connect(self.txpath, self.throttle, self.rxpath)
# /////////////////////////////////////////////////////////////////////////////
# main
diff --git a/gnuradio-examples/python/hier/digital/benchmark_rx.py b/gnuradio-examples/python/hier/digital/benchmark_rx.py
index f65a634a3..3de328a3d 100755
--- a/gnuradio-examples/python/hier/digital/benchmark_rx.py
+++ b/gnuradio-examples/python/hier/digital/benchmark_rx.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005,2006 Free Software Foundation, Inc.
+# Copyright 2005,2006,2007 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -38,16 +38,6 @@ import fusb_options
#print os.getpid()
#raw_input('Attach and press enter: ')
-
-class my_graph(gr.hier_block2):
- def __init__(self, demod_class, rx_callback, options):
- gr.hier_block2.__init__(self, "my_graph",
- gr.io_signature(0,0,0), # Input signature
- gr.io_signature(0,0,0)) # Output signature
- self.rxpath = receive_path(demod_class, rx_callback, options)
- self.define_component("rxpath", self.rxpath)
-
-
# /////////////////////////////////////////////////////////////////////////////
# main
# /////////////////////////////////////////////////////////////////////////////
@@ -104,7 +94,7 @@ def main():
print "Warning: Failed to enable realtime scheduling."
# Create an instance of a hierarchical block
- top_block = my_graph(demods[options.modulation], rx_callback, options)
+ top_block = receive_path(demods[options.modulation], rx_callback, options)
# Create an instance of a runtime, passing it the top block
runtime = gr.runtime(top_block)
diff --git a/gnuradio-examples/python/hier/digital/benchmark_tx.py b/gnuradio-examples/python/hier/digital/benchmark_tx.py
index 627c92b3a..df4a2005d 100755
--- a/gnuradio-examples/python/hier/digital/benchmark_tx.py
+++ b/gnuradio-examples/python/hier/digital/benchmark_tx.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005, 2006 Free Software Foundation, Inc.
+# Copyright 2005, 2006,2007 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -36,15 +36,6 @@ import fusb_options
#print os.getpid()
#raw_input('Attach and press enter')
-class my_graph(gr.hier_block2):
- def __init__(self, mod_class, options):
- gr.hier_block2.__init__(self, "my_graph",
- gr.io_signature(0,0,0), # Input signature
- gr.io_signature(0,0,0)) # Output signature
- self.txpath = transmit_path(mod_class, options)
- self.define_component("txpath", self.txpath)
-
-
# /////////////////////////////////////////////////////////////////////////////
# main
# /////////////////////////////////////////////////////////////////////////////
@@ -52,7 +43,7 @@ class my_graph(gr.hier_block2):
def main():
def send_pkt(payload='', eof=False):
- return top_block.txpath.send_pkt(payload, eof)
+ return top_block.send_pkt(payload, eof)
def rx_callback(ok, payload):
print "ok = %r, payload = '%s'" % (ok, payload)
@@ -96,7 +87,7 @@ def main():
print "Warning: failed to enable realtime scheduling"
# Create an instance of a hierarchical block
- top_block = my_graph(mods[options.modulation], options)
+ top_block = transmit_path(mods[options.modulation], options)
# Create an instance of a runtime, passing it the top block
runtime = gr.runtime(top_block)
diff --git a/gnuradio-examples/python/hier/digital/receive_path.py b/gnuradio-examples/python/hier/digital/receive_path.py
index 64a547dce..fce7db162 100644
--- a/gnuradio-examples/python/hier/digital/receive_path.py
+++ b/gnuradio-examples/python/hier/digital/receive_path.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005,2006 Free Software Foundation, Inc.
+# Copyright 2005,2006,2007 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -33,12 +33,9 @@ from pick_bitrate import pick_rx_bitrate
# receive path
# /////////////////////////////////////////////////////////////////////////////
-class receive_path(gr.hier_block2):
+class receive_path(gr.top_block):
def __init__(self, demod_class, rx_callback, options):
- gr.hier_block2.__init__(self, "receive_path",
- gr.io_signature(0,0,0), # Input signature
- gr.io_signature(0,0,0)) # Output signature
-
+ gr.top_block.__init__(self, "receive_path")
options = copy.copy(options) # make a copy so we can destructively modify
self._verbose = options.verbose
@@ -112,18 +109,13 @@ class receive_path(gr.hier_block2):
if self._verbose:
self._print_verbage()
- # Define the components
- self.define_component("usrp", self.u)
- self.define_component("channel_filter", gr.fft_filter_ccc(sw_decim, chan_coeffs))
- self.define_component("channel_probe", self.probe)
- self.define_component("packet_receiver", self.packet_receiver)
+ self.channel_filter = gr.fft_filter_ccc(sw_decim, chan_coeffs)
# connect the channel input filter to the carrier power detector
- self.connect("usrp", 0, "channel_filter", 0)
- self.connect("channel_filter", 0, "channel_probe", 0)
+ self.connect(self.u, self.channel_filter, self.probe)
# connect channel filter to the packet receiver
- self.connect("channel_filter", 0, "packet_receiver", 0)
+ self.connect(self.channel_filter, self.packet_receiver)
def _setup_usrp_source(self):
diff --git a/gnuradio-examples/python/hier/digital/receive_path_lb.py b/gnuradio-examples/python/hier/digital/receive_path_lb.py
index fada441ff..69d721df3 100644
--- a/gnuradio-examples/python/hier/digital/receive_path_lb.py
+++ b/gnuradio-examples/python/hier/digital/receive_path_lb.py
@@ -71,17 +71,13 @@ class receive_path(gr.hier_block2):
if self._verbose:
self._print_verbage()
- # Define the components
- self.define_component("channel_filter", gr.fft_filter_ccc(sw_decim, chan_coeffs))
- self.define_component("channel_probe", self.probe)
- self.define_component("packet_receiver", self.packet_receiver)
+ self.channel_filter = gr.fft_filter_ccc(sw_decim, chan_coeffs)
# connect the channel input filter to the carrier power detector
- self.connect("self", 0, "channel_filter", 0)
- self.connect("channel_filter", 0, "channel_probe", 0)
+ self.connect(self, self.channel_filter, self.probe)
# connect channel filter to the packet receiver
- self.connect("channel_filter", 0, "packet_receiver", 0)
+ self.connect(self.channel_filter, self.packet_receiver)
def bitrate(self):
return self._bitrate
diff --git a/gnuradio-examples/python/hier/digital/transmit_path.py b/gnuradio-examples/python/hier/digital/transmit_path.py
index c517210ae..4ed477ea1 100644
--- a/gnuradio-examples/python/hier/digital/transmit_path.py
+++ b/gnuradio-examples/python/hier/digital/transmit_path.py
@@ -1,5 +1,5 @@
#
-# Copyright 2005,2006 Free Software Foundation, Inc.
+# Copyright 2005,2006,2007 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -33,16 +33,13 @@ from pick_bitrate import pick_tx_bitrate
# transmit path
# /////////////////////////////////////////////////////////////////////////////
-class transmit_path(gr.hier_block2):
+class transmit_path(gr.top_block):
def __init__(self, modulator_class, options):
'''
See below for what options should hold
'''
- gr.hier_block2.__init__(self, "transmit_path",
- gr.io_signature(0,0,0), # Input signature
- gr.io_signature(0,0,0)) # Output signature
-
+ gr.top_block.__init__(self, "transmit_path")
options = copy.copy(options) # make a copy so we can destructively modify
self._verbose = options.verbose
@@ -99,14 +96,7 @@ class transmit_path(gr.hier_block2):
if self._verbose:
self._print_verbage()
- # Define the components
- self.define_component("packet_transmitter", self.packet_transmitter)
- self.define_component("amp", self.amp)
- self.define_component("usrp", self.u)
-
- # Connect components in the flowgraph; set amp component to the output of this block
- self.connect("packet_transmitter", 0, "amp", 0)
- self.connect("amp", 0, "usrp", 0)
+ self.connect(self.packet_transmitter, self.amp, self.u)
def _setup_usrp_sink(self):
"""
diff --git a/gnuradio-examples/python/hier/digital/transmit_path_lb.py b/gnuradio-examples/python/hier/digital/transmit_path_lb.py
index 7bf4b6057..424eafdee 100644
--- a/gnuradio-examples/python/hier/digital/transmit_path_lb.py
+++ b/gnuradio-examples/python/hier/digital/transmit_path_lb.py
@@ -1,5 +1,5 @@
#
-# Copyright 2005,2006 Free Software Foundation, Inc.
+# Copyright 2005,2006,2007 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -65,13 +65,8 @@ class transmit_path(gr.hier_block2):
if self._verbose:
self._print_verbage()
- # Define the components
- self.define_component("packet_transmitter", self.packet_transmitter)
- self.define_component("amp", self.amp)
-
- # Connect components in the flowgraph; set amp component to the output of this block
- self.connect("packet_transmitter", 0, "amp", 0)
- self.connect("amp", 0, "self", 0)
+ # Connect blocks in the flowgraph; set amp component to the output of this block
+ self.connect(self.packet_transmitter, self.amp, self)
def set_tx_amplitude(self, ampl):
"""