commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r5173 - in gnuradio/branches/developers/jcorgan/hb: gn


From: jcorgan
Subject: [Commit-gnuradio] r5173 - in gnuradio/branches/developers/jcorgan/hb: gnuradio-examples/python/hier/usrp gr-wxgui/src/python
Date: Fri, 27 Apr 2007 19:39:28 -0600 (MDT)

Author: jcorgan
Date: 2007-04-27 19:39:28 -0600 (Fri, 27 Apr 2007)
New Revision: 5173

Modified:
   
gnuradio/branches/developers/jcorgan/hb/gnuradio-examples/python/hier/usrp/usrp_fft.py
   
gnuradio/branches/developers/jcorgan/hb/gnuradio-examples/python/hier/usrp/usrp_siggen.py
   gnuradio/branches/developers/jcorgan/hb/gr-wxgui/src/python/fftsink2.py
   gnuradio/branches/developers/jcorgan/hb/gr-wxgui/src/python/scopesink2.py
   gnuradio/branches/developers/jcorgan/hb/gr-wxgui/src/python/stdgui2.py
   gnuradio/branches/developers/jcorgan/hb/gr-wxgui/src/python/waterfallsink2.py
Log:
Converted hier2 USRP examples and gr-wxgui to new API.

Modified: 
gnuradio/branches/developers/jcorgan/hb/gnuradio-examples/python/hier/usrp/usrp_fft.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/hb/gnuradio-examples/python/hier/usrp/usrp_fft.py
      2007-04-28 01:05:47 UTC (rev 5172)
+++ 
gnuradio/branches/developers/jcorgan/hb/gnuradio-examples/python/hier/usrp/usrp_fft.py
      2007-04-28 01:39:28 UTC (rev 5173)
@@ -74,7 +74,6 @@
         self.show_debug_info = True
         
         self.u = usrp.source_c(decim_rate=options.decim)
-        self.define_component("usrp", self.u)
         if options.rx_subdev_spec is None:
             options.rx_subdev_spec = pick_subdevice(self.u)
         self.u.set_mux(usrp.determine_rx_mux_value(self.u, 
options.rx_subdev_spec))
@@ -99,11 +98,8 @@
             self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate)
         else:
            self.scope = fftsink2.fft_sink_c (panel, fft_size=1024, 
sample_rate=input_rate)
-        self.define_component("scope", self.scope)
 
-        # Ultimately this will be
-        # self.connect("usrp scope")
-        self.connect("usrp", 0, "scope", 0)
+        self.connect(self.u, self.scope)
 
         self._build_gui(vbox)
 

Modified: 
gnuradio/branches/developers/jcorgan/hb/gnuradio-examples/python/hier/usrp/usrp_siggen.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/hb/gnuradio-examples/python/hier/usrp/usrp_siggen.py
   2007-04-28 01:05:47 UTC (rev 5172)
+++ 
gnuradio/branches/developers/jcorgan/hb/gnuradio-examples/python/hier/usrp/usrp_siggen.py
   2007-04-28 01:39:28 UTC (rev 5173)
@@ -7,15 +7,9 @@
 from optparse import OptionParser
 import sys
 
-
-class my_graph(gr.hier_block2):
+class my_graph(gr.top_block):
     def __init__ (self, type, ampl, wfreq, offset, subdev_spec, interp, 
rf_freq):
-        # Call hierarchical block constructor
-        # Top-level blocks have no inputs or outputs
-        gr.hier_block2.__init__(self, 
-                                "usrp_siggen",         # Block type 
-                                gr.io_signature(0,0,0), # Input signature
-                                gr.io_signature(0,0,0)) # Output signature
+        gr.top_block.__init__(self, "usrp_siggen")
         
         # controllable values
         self.interp = interp
@@ -40,30 +34,23 @@
             sys.stderr.write('Failed to set RF frequency\n')
             raise SystemExit
 
-        self.define_component("usrp", self.u)
-
         if type == gr.GR_SIN_WAVE or type == gr.GR_CONST_WAVE:
             self.src = gr.sig_source_c (self.usb_freq (),
                                         gr.GR_SIN_WAVE,
                                         self.waveform_freq,
                                         self.waveform_ampl,
                                         self.waveform_offset)
-            self.define_component("src", self.src)
 
         elif type == gr.GR_UNIFORM or type == gr.GR_GAUSSIAN:
             self.src = gr.noise_source_c (gr.GR_UNIFORM,
                                           self.waveform_ampl)
-            self.define_component("src", self.src)
-        
+
         else:
             raise ValueError, type
 
-        # self.file_sink = gr.file_sink (gr.sizeof_gr_complex, "siggen.dat")
-        # self.define_component("file_sink", self.file_sink)
+        self.connect (self.src, self.u)
 
-        self.connect ("src", 0, "usrp", 0)
 
-
     def usb_freq (self):
         return self.u.dac_freq() / self.interp
 

Modified: 
gnuradio/branches/developers/jcorgan/hb/gr-wxgui/src/python/fftsink2.py
===================================================================
--- gnuradio/branches/developers/jcorgan/hb/gr-wxgui/src/python/fftsink2.py     
2007-04-28 01:05:47 UTC (rev 5172)
+++ gnuradio/branches/developers/jcorgan/hb/gr-wxgui/src/python/fftsink2.py     
2007-04-28 01:39:28 UTC (rev 5173)
@@ -106,37 +106,25 @@
                                average=average, avg_alpha=avg_alpha, 
title=title,
                                peak_hold=peak_hold)
                                
-        self.define_component("s2p", gr.stream_to_vector(gr.sizeof_float, 
self.fft_size))
+        self.s2p = gr.stream_to_vector(gr.sizeof_float, self.fft_size)
         self.one_in_n = gr.keep_one_in_n(gr.sizeof_float * self.fft_size,
                                          max(1, 
int(self.sample_rate/self.fft_size/self.fft_rate)))
-        self.define_component("one_in_n", self.one_in_n)
         
         mywindow = window.blackmanharris(self.fft_size)
-        self.define_component("fft", gr.fft_vfc(self.fft_size, True, mywindow))
+        self.fft = gr.fft_vfc(self.fft_size, True, mywindow)
         power = 0
         for tap in mywindow:
             power += tap*tap
             
-        self.define_component("c2mag", gr.complex_to_mag(self.fft_size))
+        self.c2mag = gr.complex_to_mag(self.fft_size)
         self.avg = gr.single_pole_iir_filter_ff(1.0, self.fft_size)
-        self.define_component("avg", self.avg)
 
         # FIXME  We need to add 3dB to all bins but the DC bin
-        self.define_component("log", gr.nlog10_ff(20, self.fft_size,
-                                     
-20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size)))
-        self.define_component("sink", gr.message_sink(gr.sizeof_float * 
self.fft_size, self.msgq, True))
+        self.log = gr.nlog10_ff(20, self.fft_size,
+                               
-20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size))
+        self.sink = gr.message_sink(gr.sizeof_float * self.fft_size, 
self.msgq, True)
+       self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, 
self.avg, self.log, self.sink)
 
-
-        # Ultimately this will be
-        # self.connect("self s2p one_in_n fft c2mag avg log sink")
-        self.connect("self", 0, "s2p", 0)
-        self.connect("s2p", 0, "one_in_n", 0)
-        self.connect("one_in_n", 0, "fft", 0)
-        self.connect("fft", 0, "c2mag", 0)
-        self.connect("c2mag", 0, "avg", 0)
-        self.connect("avg", 0, "log", 0)
-        self.connect("log", 0, "sink", 0)
-                              
         self.win = fft_window(self, parent, size=size)
         self.set_average(self.average)
 
@@ -158,36 +146,25 @@
                                average=average, avg_alpha=avg_alpha, 
title=title,
                                peak_hold=peak_hold)
 
-        self.define_component("s2p", gr.stream_to_vector(gr.sizeof_gr_complex, 
self.fft_size))
+        self.s2p = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)
         self.one_in_n = gr.keep_one_in_n(gr.sizeof_gr_complex * self.fft_size,
                                          max(1, 
int(self.sample_rate/self.fft_size/self.fft_rate)))
-        self.define_component("one_in_n", self.one_in_n)
         
         mywindow = window.blackmanharris(self.fft_size)
-        self.define_component("fft", gr.fft_vcc(self.fft_size, True, mywindow))
+        self.fft = gr.fft_vcc(self.fft_size, True, mywindow)
         power = 0
         for tap in mywindow:
             power += tap*tap
             
-        self.define_component("c2mag", gr.complex_to_mag(self.fft_size))
+        self.c2mag = gr.complex_to_mag(self.fft_size)
         self.avg = gr.single_pole_iir_filter_ff(1.0, self.fft_size)
-        self.define_component("avg", self.avg)
 
         # FIXME  We need to add 3dB to all bins but the DC bin
-        self.define_component("log", gr.nlog10_ff(20, self.fft_size,
-                                     
-20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size)))
-        self.define_component("sink", gr.message_sink(gr.sizeof_float * 
self.fft_size, self.msgq, True))
+        self.log = gr.nlog10_ff(20, self.fft_size,
+                                
-20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size))
+        self.sink = gr.message_sink(gr.sizeof_float * self.fft_size, 
self.msgq, True)
+       self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, 
self.avg, self.log, self.sink)
 
-        # Ultimately this will be
-        # self.connect("self s2p one_in_n fft c2mag avg log sink")
-        self.connect("self", 0, "s2p", 0)
-        self.connect("s2p", 0, "one_in_n", 0)
-        self.connect("one_in_n", 0, "fft", 0)
-        self.connect("fft", 0, "c2mag", 0)
-        self.connect("c2mag", 0, "avg", 0)
-        self.connect("avg", 0, "log", 0)
-        self.connect("log", 0, "sink", 0)
-
         self.win = fft_window(self, parent, size=size)
         self.set_average(self.average)
 
@@ -475,13 +452,8 @@
                             ref_level=0, y_per_div=20)
         vbox.Add (sink1.win, 1, wx.EXPAND)
 
-        self.define_component("src1", src1)
-        self.define_component("thr1", thr1)
-        self.define_component("sink1", sink1)
+       self.connect(src1, thr1, sink1)
 
-        self.connect ("src1", 0, "thr1", 0)
-        self.connect ("thr1", 0, "sink1", 0)
-
         #src2 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 2e3, 1)
         src2 = gr.sig_source_f (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1)
         thr2 = gr.throttle(gr.sizeof_float, input_rate)
@@ -490,16 +462,10 @@
                             ref_level=0, y_per_div=20)
         vbox.Add (sink2.win, 1, wx.EXPAND)
 
-        self.define_component("src2", src2)
-        self.define_component("thr2", thr2)
-        self.define_component("sink2", sink2)
-        
-        self.connect ("src2", 0, "thr2", 0)
-        self.connect ("thr2", 0, "sink2", 0)
+       self.connect(src2, thr2, sink2)
 
 def main ():
-    app = stdgui2.stdapp (test_app_block,
-                         "FFT Sink Test App")
+    app = stdgui2.stdapp (test_app_block, "FFT Sink Test App")
     app.MainLoop ()
 
 if __name__ == '__main__':

Modified: 
gnuradio/branches/developers/jcorgan/hb/gr-wxgui/src/python/scopesink2.py
===================================================================
--- gnuradio/branches/developers/jcorgan/hb/gr-wxgui/src/python/scopesink2.py   
2007-04-28 01:05:47 UTC (rev 5172)
+++ gnuradio/branches/developers/jcorgan/hb/gr-wxgui/src/python/scopesink2.py   
2007-04-28 01:39:28 UTC (rev 5173)
@@ -43,10 +43,8 @@
 
         msgq = gr.msg_queue(2)         # message queue that holds at most 2 
messages
         self.guts = gr.oscope_sink_f(sample_rate, msgq)
-        self.define_component("guts", self.guts)
+        self.connect(self, self.guts)
 
-        self.connect("self", 0, "guts", 0)
-
         self.win = scope_window(win_info (msgq, sample_rate, frame_decim,
                                           v_scale, t_scale, self.guts, title), 
parent)
 
@@ -64,13 +62,11 @@
                                 gr.io_signature(0,0,0))
 
         msgq = gr.msg_queue(2)         # message queue that holds at most 2 
messages
-        self.define_component("c2f", gr.complex_to_float())
+        self.c2f = gr.complex_to_float()
         self.guts = gr.oscope_sink_f(sample_rate, msgq)
-        self.define_component("guts", self.guts)
-
-        self.connect("self", 0, "c2f", 0)
-        self.connect("c2f", 0, "guts", 0)
-        self.connect("c2f", 1, "guts", 1)
+       self.connect(self, self.c2f)
+       self.connect((self.c2f, 0), (self.guts, 0))
+       self.connect((self.c2f, 1), (self.guts, 1))
         
         self.win = scope_window(win_info(msgq, sample_rate, frame_decim,
                                          v_scale, t_scale, self.guts, title), 
parent)
@@ -631,24 +627,21 @@
         input_rate = 1e6
 
         # Generate a complex sinusoid
-        self.define_component("src0", gr.sig_source_c (input_rate, 
gr.GR_SIN_WAVE, 25.1e3, 1e3))
+        self.src0 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 25.1e3, 1e3)
 
         # We add this throttle block so that this demo doesn't suck down
         # all the CPU available.  You normally wouldn't use it...
-        self.define_component("throttle", gr.throttle(gr.sizeof_gr_complex, 
input_rate))
+        self.thr = gr.throttle(gr.sizeof_gr_complex, input_rate)
 
         scope = scope_sink_c (panel,"Secret Data",sample_rate=input_rate,
                               frame_decim=frame_decim,
                               v_scale=v_scale, t_scale=t_scale)
-        self.define_component("scope", scope)
         vbox.Add (scope.win, 1, wx.EXPAND)
 
         # Ultimately this will be
         # self.connect("src0 throttle scope")
-        self.connect("src0", 0, "throttle", 0)
-        self.connect("throttle", 0, "scope", 0)
+       self.connect(self.src0, self.thr, scope) 
 
-
 def main ():
     app = stdgui2.stdapp (test_top_block, "O'Scope Test App")
     app.MainLoop ()

Modified: gnuradio/branches/developers/jcorgan/hb/gr-wxgui/src/python/stdgui2.py
===================================================================
--- gnuradio/branches/developers/jcorgan/hb/gr-wxgui/src/python/stdgui2.py      
2007-04-28 01:05:47 UTC (rev 5172)
+++ gnuradio/branches/developers/jcorgan/hb/gr-wxgui/src/python/stdgui2.py      
2007-04-28 01:39:28 UTC (rev 5173)
@@ -86,10 +86,8 @@
         self.runtime = gr.runtime(self.top_block)
         self.runtime.start ()
 
-class std_top_block (gr.hier_block2):
+class std_top_block (gr.top_block):
     def __init__ (self, parent, panel, vbox, argv):
         # Call the hier_block2 constructor
         # Top blocks have no inputs and outputs
-        gr.hier_block2.__init__(self, "std_top_block",
-                                gr.io_signature(0,0,0),
-                                gr.io_signature(0,0,0))
+        gr.top_block.__init__(self, "std_top_block")

Modified: 
gnuradio/branches/developers/jcorgan/hb/gr-wxgui/src/python/waterfallsink2.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/hb/gr-wxgui/src/python/waterfallsink2.py   
    2007-04-28 01:05:47 UTC (rev 5172)
+++ 
gnuradio/branches/developers/jcorgan/hb/gr-wxgui/src/python/waterfallsink2.py   
    2007-04-28 01:39:28 UTC (rev 5173)
@@ -87,29 +87,18 @@
                                fft_rate=fft_rate,
                                average=average, avg_alpha=avg_alpha, 
title=title)
                                
-        self.define_component("s2p", gr.serial_to_parallel(gr.sizeof_float, 
self.fft_size))
+        self.s2p = gr.serial_to_parallel(gr.sizeof_float, self.fft_size)
         self.one_in_n = gr.keep_one_in_n(gr.sizeof_float * self.fft_size,
                                          max(1, 
int(self.sample_rate/self.fft_size/self.fft_rate)))
-        self.define_component("one_in_n", self.one_in_n)
         
         mywindow = window.blackmanharris(self.fft_size)
-        self.define_component("fft", gr.fft_vfc(self.fft_size, True, mywindow))
-        self.define_component("c2mag", gr.complex_to_mag(self.fft_size))
+        self.fft = gr.fft_vfc(self.fft_size, True, mywindow)
+        self.c2mag = gr.complex_to_mag(self.fft_size)
         self.avg = gr.single_pole_iir_filter_ff(1.0, self.fft_size)
-        self.define_component("avg", self.avg)
-        self.define_component("log", gr.nlog10_ff(20, self.fft_size, 
-20*math.log10(self.fft_size)))
-        self.define_component("sink", gr.message_sink(gr.sizeof_float * 
self.fft_size, self.msgq, True))
+        self.log = gr.nlog10_ff(20, self.fft_size, 
-20*math.log10(self.fft_size))
+        self.sink = gr.message_sink(gr.sizeof_float * self.fft_size, 
self.msgq, True)
+       self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, 
self.avg, self.log, self.sink)
 
-        # Ultimately this will be
-        # self.connect("self s2p one_in_n fft c2mag avg log sink")
-        self.connect("self", 0, "s2p", 0)
-        self.connect("s2p", 0, "one_in_n", 0)
-        self.connect("one_in_n", 0, "fft", 0)
-        self.connect("fft", 0, "c2mag", 0)
-        self.connect("c2mag", 0, "avg", 0)
-        self.connect("avg", 0, "log", 0)
-        self.connect("log", 0, "sink", 0)
-
         self.win = waterfall_window(self, parent, size=size)
         self.set_average(self.average)
 
@@ -129,29 +118,18 @@
                                      fft_rate=fft_rate,
                                      average=average, avg_alpha=avg_alpha, 
title=title)
 
-        self.define_component("s2p", 
gr.serial_to_parallel(gr.sizeof_gr_complex, self.fft_size))
+        self.s2p = gr.serial_to_parallel(gr.sizeof_gr_complex, self.fft_size)
         self.one_in_n = gr.keep_one_in_n(gr.sizeof_gr_complex * self.fft_size,
                                          max(1, 
int(self.sample_rate/self.fft_size/self.fft_rate)))
-        self.define_component("one_in_n", self.one_in_n)
         
         mywindow = window.blackmanharris(self.fft_size)
-        self.define_component("fft", gr.fft_vcc(self.fft_size, True, mywindow))
-        self.define_component("c2mag", gr.complex_to_mag(self.fft_size))
+        self.fft = gr.fft_vcc(self.fft_size, True, mywindow)
+        self.c2mag = gr.complex_to_mag(self.fft_size)
         self.avg = gr.single_pole_iir_filter_ff(1.0, self.fft_size)
-        self.define_component("avg", self.avg)
-        self.define_component("log", gr.nlog10_ff(20, self.fft_size, 
-20*math.log10(self.fft_size)))
-        self.define_component("sink", gr.message_sink(gr.sizeof_float * 
self.fft_size, self.msgq, True))
+        self.log = gr.nlog10_ff(20, self.fft_size, 
-20*math.log10(self.fft_size))
+        self.sink = gr.message_sink(gr.sizeof_float * self.fft_size, 
self.msgq, True)
+       self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, 
self.avg, self.log, self.sink)
 
-        # Ultimately this will be
-        # self.connect("self s2p one_in_n fft c2mag avg log sink")
-        self.connect("self", 0, "s2p", 0)
-        self.connect("s2p", 0, "one_in_n", 0)
-        self.connect("one_in_n", 0, "fft", 0)
-        self.connect("fft", 0, "c2mag", 0)
-        self.connect("c2mag", 0, "avg", 0)
-        self.connect("avg", 0, "log", 0)
-        self.connect("log", 0, "sink", 0)
-
         self.win = waterfall_window(self, parent, size=size)
         self.set_average(self.average)
 
@@ -448,41 +426,29 @@
         input_rate = 20.000e3
 
         # Generate a complex sinusoid
-        self.define_component("src1", gr.sig_source_c (input_rate, 
gr.GR_SIN_WAVE, 5.75e3, 1000))
+        self.src1 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 5.75e3, 1000)
         #src1 = gr.sig_source_c (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1000)
 
         # We add these throttle blocks so that this demo doesn't
         # suck down all the CPU available.  Normally you wouldn't use these.
-        self.define_component("thr1", gr.throttle(gr.sizeof_gr_complex, 
input_rate))
+        self.thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate)
 
-        sink1 = waterfall_sink_c (self, panel, title="Complex Data", 
fft_size=fft_size,
+        sink1 = waterfall_sink_c (panel, title="Complex Data", 
fft_size=fft_size,
                                   sample_rate=input_rate, baseband_freq=100e3)
-        self.define_component("sink1", sink1)
-
+       self.connect(self.src1, self.thr1, sink1)
         vbox.Add (sink1.win, 1, wx.EXPAND)
 
-        # Ultimately this will be
-        # self.connect("src1 thr1 sink1")
-        self.connect("src1", 0, "thr1", 0)
-        self.connect("thr1", 0, "sink1", 0)
-
         # generate a real sinusoid
-        self.define_component("src2", gr.sig_source_f (input_rate, 
gr.GR_SIN_WAVE, 5.75e3, 1000))
-        #src2 = gr.sig_source_f (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1000)
-        self.define_component("thr2", gr.throttle(gr.sizeof_float, input_rate))
-        sink2 = waterfall_sink_f (self, panel, title="Real Data", 
fft_size=fft_size,
+        self.src2 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 5.75e3, 1000)
+        self.thr2 = gr.throttle(gr.sizeof_float, input_rate)
+        sink2 = waterfall_sink_f (panel, title="Real Data", fft_size=fft_size,
                                   sample_rate=input_rate, baseband_freq=100e3)
-        self.define_component("sink2", sink2)
+       self.connect(self.src2, self.thr2, sink2)
         vbox.Add (sink2.win, 1, wx.EXPAND)
 
-        # Ultimately this will be
-        # self.connect("src2 thr2 sink2")
-        self.connect("src2", 0, "thr2", 0)
-        self.connect("thr2", 0, "sink2", 0)
 
 def main ():
-    app = stdgui2.stdapp (test_top_block,
-                         "Waterfall Sink Test App")
+    app = stdgui2.stdapp (test_top_block, "Waterfall Sink Test App")
     app.MainLoop ()
 
 if __name__ == '__main__':





reply via email to

[Prev in Thread] Current Thread [Next in Thread]