[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r4997 - in gnuradio/branches/developers/jcorgan/hier2:
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r4997 - in gnuradio/branches/developers/jcorgan/hier2: gnuradio-core/src/python/gnuradio/gr gnuradio-examples/python/hier/audio |
Date: |
Fri, 13 Apr 2007 14:32:19 -0600 (MDT) |
Author: jcorgan
Date: 2007-04-13 14:32:19 -0600 (Fri, 13 Apr 2007)
New Revision: 4997
Modified:
gnuradio/branches/developers/jcorgan/hier2/gnuradio-core/src/python/gnuradio/gr/hier_block2.py
gnuradio/branches/developers/jcorgan/hier2/gnuradio-examples/python/hier/audio/dial_tone2.py
Log:
Converted dial_tone2.py to new hier_block2 API.
Modified:
gnuradio/branches/developers/jcorgan/hier2/gnuradio-core/src/python/gnuradio/gr/hier_block2.py
===================================================================
---
gnuradio/branches/developers/jcorgan/hier2/gnuradio-core/src/python/gnuradio/gr/hier_block2.py
2007-04-13 20:02:46 UTC (rev 4996)
+++
gnuradio/branches/developers/jcorgan/hier2/gnuradio-core/src/python/gnuradio/gr/hier_block2.py
2007-04-13 20:32:19 UTC (rev 4997)
@@ -21,7 +21,7 @@
from gnuradio_swig_python import hier_block2_swig, gr_make_runtime, \
runtime_run_unlocked, runtime_start_unlocked, runtime_stop_unlocked, \
- runtime_wait_unlocked, runtime_restart_unlocked
+ runtime_wait_unlocked, runtime_restart_unlocked, io_signature
#
# This hack forces a 'has-a' relationship to look like an 'is-a' one.
@@ -46,6 +46,10 @@
return self._hb.disconnect(src.basic_block(), src_port,
dst.basic_block(), dst_port)
+# Convenience class to create a no input, no output block for runtime top block
+class top_block(hier_block2):
+ def __init__(self, name):
+ hier_block2.__init__(self, name, io_signature(0,0,0),
io_signature(0,0,0))
# This allows the 'run_locked' methods, which are defined in gr_runtime.i,
# to release the Python global interpreter lock before calling the actual
Modified:
gnuradio/branches/developers/jcorgan/hier2/gnuradio-examples/python/hier/audio/dial_tone2.py
===================================================================
---
gnuradio/branches/developers/jcorgan/hier2/gnuradio-examples/python/hier/audio/dial_tone2.py
2007-04-13 20:02:46 UTC (rev 4996)
+++
gnuradio/branches/developers/jcorgan/hier2/gnuradio-examples/python/hier/audio/dial_tone2.py
2007-04-13 20:32:19 UTC (rev 4997)
@@ -27,32 +27,20 @@
# Top-level block creating a dial tone
# Derives from new class gr.hier_block2
-class dial_tone(gr.hier_block2):
+class dial_tone(gr.top_block):
def __init__(self,
sample_rate, # Audio output sample rate (int)
audio_output, # Audio output device
amplitude): # Output volume (0.0-1.0)
- # Call hierarchical block constructor
- # Top-level blocks have no inputs or outputs
- gr.hier_block2.__init__(self,
- "dial_tone", # Block type
- gr.io_signature(0,0,0), # Input
signature
- gr.io_signature(0,0,0)) # Output
signature
+ gr.top_block.__init__(self, "dial_tone")
- # Hierarchical blocks have a set of 'components' (which may
- # be themselves hierarchical blocks), mapped to names.
- # 'define_component' takes a string and either a hierarchical
- # block or an instance of a 'leaf node' (gr_block) block
+ src0 = gr.sig_source_f(sample_rate, gr.GR_SIN_WAVE, 350,
amplitude)
+ src1 = gr.sig_source_f(sample_rate, gr.GR_SIN_WAVE, 440,
amplitude)
+ dst = audio.sink(sample_rate, audio_output)
- # Give names to two sine wave sources and an audio sink
- self.define_component("src0", gr.sig_source_f (sample_rate,
gr.GR_SIN_WAVE, 350, amplitude))
- self.define_component("src1", gr.sig_source_f (sample_rate,
gr.GR_SIN_WAVE, 440, amplitude))
- self.define_component("dst", audio.sink(sample_rate,
audio_output))
-
- # Wire up outputs to inputs. (TODO: convenience functions)
- self.connect("src0", 0, "dst", 0)
- self.connect("src1", 0, "dst", 1)
+ self.connect(src0, 0, dst, 0)
+ self.connect(src1, 0, dst, 1)
if __name__ == '__main__':
parser = OptionParser(option_class=eng_option)
@@ -68,13 +56,13 @@
raise SystemExit, 1
# Create an instance of a hierarchical block
- top_block = dial_tone(int(options.sample_rate),
- options.audio_output,
- options.amplitude)
+ top = dial_tone(int(options.sample_rate),
+ options.audio_output,
+ options.amplitude)
# Create an instance of a runtime, passing it the top block
# to process
- runtime = gr.runtime(top_block)
+ runtime = gr.runtime(top)
try:
# Run forever
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r4997 - in gnuradio/branches/developers/jcorgan/hier2: gnuradio-core/src/python/gnuradio/gr gnuradio-examples/python/hier/audio,
jcorgan <=