commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8048 - gnuradio/branches/developers/michaelld/wxgui/g


From: michaelld
Subject: [Commit-gnuradio] r8048 - gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python
Date: Wed, 19 Mar 2008 10:28:25 -0600 (MDT)

Author: michaelld
Date: 2008-03-19 10:28:24 -0600 (Wed, 19 Mar 2008)
New Revision: 8048

Modified:
   gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/fftsink2.py
   
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/numbersink2.py
   
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/scopesink2.py
   gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/stdgui2.py
   
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/waterfallsink2.py
Log:
Added "DoClose()" methods to sinks and examples.  Now stops the
input_watcher thread correctly for the examples; users will need to
implement a "DoClose" command to their apps ... but in the mean time,
the thread will eventually close cleanly without waiting for it (just
as it has until now).



Modified: 
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/fftsink2.py
===================================================================
--- 
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/fftsink2.py    
    2008-03-19 15:55:03 UTC (rev 8047)
+++ 
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/fftsink2.py    
    2008-03-19 16:28:24 UTC (rev 8048)
@@ -134,6 +134,9 @@
     def _set_n(self):
         self.one_in_n.set_n(max(1, 
int(self.sample_rate/self.fft_size/self.fft_rate)))
         
+    def DoClose (self):
+        # on close, tell the created window to close itself
+        self.win.DoClose ()
 
 class fft_sink_f (fft_sink_base):
     def __init__ (self, parent, baseband_freq=0, ref_scale=2.0,
@@ -184,8 +187,6 @@
         self.Bind(wx.EVT_RIGHT_UP, self.on_right_click)
         self.Bind(wx.EVT_MOTION, self.evt_motion)
 
-        wx.EVT_CLOSE (self, self.on_close_window)
-
         self.data_event = gr_window_data_event (self, self.set_data)
         self.input_watcher = gr_input_watcher (fftsink.msgq, self,
                                                self.data_event,
@@ -226,11 +227,11 @@
            self.peak_vals = None
        self.set_scale(baseband_freq)
        self.fftsink.set_baseband_freq(baseband_freq)
-       
-    def on_close_window (self, event):
-#        print "fft_window:on_close_window"
-        self.keep_running = False
 
+    def DoClose (self):
+        # on close, stop the input_watcher
+        self.input_watcher.stop ()
+
     def set_data (self, evt):
         dB = evt.data
         L = len (dB)
@@ -441,23 +442,32 @@
         # suck down all the CPU available.  Normally you wouldn't use these.
         thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate)
 
-        sink1 = fft_sink_c (panel, title="Complex Data", fft_size=fft_size,
-                            sample_rate=input_rate, baseband_freq=100e3,
-                            ref_level=0, y_per_div=20)
-        vbox.Add (sink1.win, 1, wx.EXPAND)
+        self.sink1 = fft_sink_c (panel, title="Complex Data",
+                                 fft_size=fft_size,
+                                 sample_rate=input_rate,
+                                 baseband_freq=100e3,
+                                 ref_level=0, y_per_div=20)
+        vbox.Add (self.sink1.win, 1, wx.EXPAND)
 
-       self.connect(src1, thr1, sink1)
+       self.connect(src1, thr1, self.sink1)
 
         #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)
-        sink2 = fft_sink_f (panel, title="Real Data", fft_size=fft_size*2,
-                            sample_rate=input_rate, baseband_freq=100e3,
-                            ref_level=0, y_per_div=20)
-        vbox.Add (sink2.win, 1, wx.EXPAND)
+        self.sink2 = fft_sink_f (panel, title="Real Data",
+                                 fft_size=fft_size*2,
+                                 sample_rate=input_rate,
+                                 baseband_freq=100e3,
+                                 ref_level=0, y_per_div=20)
+        vbox.Add (self.sink2.win, 1, wx.EXPAND)
 
-       self.connect(src2, thr2, sink2)
+       self.connect(src2, thr2, self.sink2)
 
+    def DoClose (self):
+        # on close, tell the created sinks to close themselves
+        self.sink1.DoClose ()
+        self.sink2.DoClose ()
+
 def main ():
     app = stdgui2.stdapp (test_app_block, "FFT Sink Test App")
     app.MainLoop ()

Modified: 
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/numbersink2.py
===================================================================
--- 
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/numbersink2.py 
    2008-03-19 15:55:03 UTC (rev 8047)
+++ 
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/numbersink2.py 
    2008-03-19 16:28:24 UTC (rev 8048)
@@ -118,6 +118,10 @@
     def set_base_value(self, base_value):
         self.base_value = base_value
 
+    def DoClose (self):
+        # on close, tell the created window to close itself
+        self.win.DoClose ()
+
 class number_sink_f (number_sink_base):
     def __init__ (self, parent, unit='', base_value=0, minval=-100.0,
                   maxval=100.0, factor=1.0, decimal_places=10, ref_level=50,
@@ -336,8 +340,6 @@
         self.peak_hold = False
         self.peak_vals = None
 
-        wx.EVT_CLOSE (self, self.on_close_window)
-
         self.data_event = gr_window_data_event (self, self.set_data)
         self.input_watcher = gr_input_watcher (numbersink.msgq, self,
                                                self.data_event,
@@ -358,9 +360,9 @@
 
         return numpy.fromstring (s, numpy.float32)
 
-    def on_close_window (self, event):
-        # print "number_window:on_close_window"
-        self.keep_running = False
+    def DoClose (self):
+        # on close, stop the input_watcher
+        self.input_watcher.stop ()
 
     def set_show_gauge(self, enable):
         self.show_gauge = enable
@@ -455,18 +457,25 @@
         thr1 = gr.throttle(gr.sizeof_float, input_rate)
         thr2 = gr.throttle(gr.sizeof_gr_complex, input_rate)
 
-        sink1 = number_sink_f (panel, unit='Hz',label="Real Data", 
avg_alpha=0.001,
-                            sample_rate=input_rate, base_value=100e3,
-                            ref_level=0, decimal_places=3)
-        vbox.Add (sink1.win, 1, wx.EXPAND)
-        sink2 = number_sink_c (panel, unit='V',label="Complex Data", 
avg_alpha=0.001,
-                            sample_rate=input_rate, base_value=0,
-                            ref_level=0, decimal_places=3)
-        vbox.Add (sink2.win, 1, wx.EXPAND)
+        self.sink1 = number_sink_f (panel, unit='Hz',label="Real Data",
+                                    avg_alpha=0.001,
+                                    sample_rate=input_rate, base_value=100e3,
+                                    ref_level=0, decimal_places=3)
+        vbox.Add (self.sink1.win, 1, wx.EXPAND)
+        self.sink2 = number_sink_c (panel, unit='V',label="Complex Data",
+                                    avg_alpha=0.001,
+                                    sample_rate=input_rate, base_value=0,
+                                    ref_level=0, decimal_places=3)
+        vbox.Add (self.sink2.win, 1, wx.EXPAND)
 
-        self.connect (src1, thr1, sink1)
-        self.connect (src2, thr2, sink2)
+        self.connect (src1, thr1, self.sink1)
+        self.connect (src2, thr2, self.sink2)
 
+    def DoClose (self):
+        # on close, tell the created sinks to close themselves
+        self.sink1.DoClose ()
+        self.sink2.DoClose ()
+
 def main ():
     app = stdgui2.stdapp (test_app_flow_graph, "Number Sink Test App")
     app.MainLoop ()

Modified: 
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/scopesink2.py
===================================================================
--- 
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/scopesink2.py  
    2008-03-19 15:55:03 UTC (rev 8047)
+++ 
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/scopesink2.py  
    2008-03-19 16:28:24 UTC (rev 8048)
@@ -69,6 +69,10 @@
         self.guts.set_sample_rate (sample_rate)
         self.win.info.set_sample_rate (sample_rate)
 
+    def DoClose (self):
+        # on close, tell the created window to close itself
+        self.win.DoClose ()
+
 class scope_sink_f (scope_sink_base):
     def __init__ (self, parent, title='', sample_rate=1,
                   size=default_scopesink_size,
@@ -212,7 +216,6 @@
         self.sizer.Fit (self)
         self.set_autorange(self.info.autorange)
         
-
     # second row of control buttons etc. appears BELOW control_box
     def make_control2_box (self):
         ctrlbox = wx.BoxSizer (wx.HORIZONTAL)
@@ -398,8 +401,11 @@
 
     def run_stop (self, evt):
         self.info.running = not self.info.running
-        
 
+    def DoClose (self):
+        # on close, tell the created graph to close itself
+        self.graph.DoClose ()
+
 class graph_window (plot.PlotCanvas):
 
     channel_colors = ['BLUE', 'RED',
@@ -464,6 +470,10 @@
         self.iscan -= 1
         return records
 
+    def DoClose (self):
+        # on close, stop the input_watcher
+        self.input_watcher.stop ()
+
     def channel_color (self, ch):
         return self.channel_colors[ch % len(self.channel_colors)]
        
@@ -630,15 +640,19 @@
         # all the CPU available.  You normally wouldn't use it...
         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)
-        vbox.Add (scope.win, 1, wx.EXPAND)
+        self.scope = scope_sink_c (panel,"Secret Data",sample_rate=input_rate,
+                                   frame_decim=frame_decim,
+                                   v_scale=v_scale, t_scale=t_scale)
+        vbox.Add (self.scope.win, 1, wx.EXPAND)
 
         # Ultimately this will be
         # self.connect("src0 throttle scope")
-       self.connect(self.src0, self.thr, scope) 
+       self.connect(self.src0, self.thr, self.scope) 
 
+    def DoClose (self):
+        # on close, tell the created scope to close itself
+        self.scope.DoClose ()
+
 def main ():
     app = stdgui2.stdapp (test_top_block, "O'Scope Test App")
     app.MainLoop ()

Modified: 
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/stdgui2.py
===================================================================
--- gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/stdgui2.py 
2008-03-19 15:55:03 UTC (rev 8047)
+++ gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/stdgui2.py 
2008-03-19 16:28:24 UTC (rev 8048)
@@ -27,7 +27,7 @@
 class stdapp (wx.App):
     def __init__ (self, top_block_maker, title="GNU Radio", nstatus=2,
                   pos=wx.DefaultPosition, size=wx.DefaultSize, usage=None,
-                  do_menu_bar=False, debug=False):
+                  do_menu_bar=True, debug=False):
         # Save inputs, to be used in the 'OnInit' method, which is
         # called from somewhere in the guts of wx.App.__init__ .
         self._top_block_maker = top_block_maker
@@ -175,7 +175,7 @@
         except:
             # try the "old" method second
             self.top_block = top_block_maker (parent, self, vbox, sys.argv)
-            
+
         self.SetSizer (vbox)
         self.SetAutoLayout (True)
         vbox.Fit (self)
@@ -227,11 +227,11 @@
         self._debug = debug
 
     def DoClose (self):
-        # empty for standard GNU Radio apps
+        # overload for the specific user's app
         pass
 
     def DoSetup (self):
-        # empty for standard GNU Radio apps
+        # overload for the specific user's app
         pass
 
     def set_status_text (self, text, which=0):

Modified: 
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/waterfallsink2.py
===================================================================
--- 
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/waterfallsink2.py
  2008-03-19 15:55:03 UTC (rev 8047)
+++ 
gnuradio/branches/developers/michaelld/wxgui/gr-wxgui/src/python/waterfallsink2.py
  2008-03-19 16:28:24 UTC (rev 8048)
@@ -107,6 +107,10 @@
     def _set_n(self):
         self.one_in_n.set_n(max(1, 
int(self.sample_rate/self.fft_size/self.fft_rate)))
 
+    def DoClose (self):
+        # on close, tell the created window to close itself
+        self.win.DoClose ()
+
 class waterfall_sink_f (waterfall_sink_base):
     def __init__ (self, parent, baseband_freq=0,
                   y_per_div=10, ref_level=50, sample_rate=1, fft_size=512,
@@ -150,7 +154,6 @@
         self.build_popup_menu()
 
         wx.EVT_PAINT (self, self.OnPaint)
-        wx.EVT_CLOSE (self, self.on_close_window)
         self.Bind(wx.EVT_RIGHT_UP, self.on_right_click)
 
         self.data_event = gr_window_data_event (self, self.set_data)
@@ -173,9 +176,9 @@
 
         return numpy.fromstring (s, numpy.float32)
 
-    def on_close_window (self, event):
-        print "waterfall_window: on_close_window"
-        self.keep_running = False
+    def DoClose (self):
+        # on close, stop the input_watcher
+        self.input_watcher.stop ()
 
     def const_list(self,const,len):
         return [const] * len
@@ -379,19 +382,27 @@
         # suck down all the CPU available.  Normally you wouldn't use these.
         self.thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate)
 
-        sink1 = waterfall_sink_c (panel, title="Complex Data", 
fft_size=fft_size,
-                                  sample_rate=input_rate, baseband_freq=100e3)
-       self.connect(self.src1, self.thr1, sink1)
-        vbox.Add (sink1.win, 1, wx.EXPAND)
+        self.sink1 = waterfall_sink_c (panel, title="Complex Data",
+                                       fft_size=fft_size,
+                                       sample_rate=input_rate,
+                                       baseband_freq=100e3)
+       self.connect(self.src1, self.thr1, self.sink1)
+        vbox.Add (self.sink1.win, 1, wx.EXPAND)
 
         # generate a real sinusoid
         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.connect(self.src2, self.thr2, sink2)
-        vbox.Add (sink2.win, 1, wx.EXPAND)
+        self.sink2 = waterfall_sink_f (panel, title="Real Data",
+                                       fft_size=fft_size,
+                                       sample_rate=input_rate,
+                                       baseband_freq=100e3)
+       self.connect(self.src2, self.thr2, self.sink2)
+        vbox.Add (self.sink2.win, 1, wx.EXPAND)
 
+    def DoClose (self):
+        # on close, tell the created sinks to close themselves
+        self.sink1.DoClose ()
+        self.sink2.DoClose ()
 
 def main ():
     app = stdgui2.stdapp (test_top_block, "Waterfall Sink Test App")





reply via email to

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