commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r6569 - in grc/trunk: examples/audio src src/Graphics


From: jblum
Subject: [Commit-gnuradio] r6569 - in grc/trunk: examples/audio src src/Graphics
Date: Mon, 1 Oct 2007 23:16:22 -0600 (MDT)

Author: jblum
Date: 2007-10-01 23:16:19 -0600 (Mon, 01 Oct 2007)
New Revision: 6569

Modified:
   grc/trunk/examples/audio/b_flat_scale.grc.xml
   grc/trunk/src/ActionHandler.py
   grc/trunk/src/Graphics/MainWindow.py
   grc/trunk/src/Messages.py
   grc/trunk/src/Preferences.py
Log:
code cleanup, concise messages, fixed bug with 1st page display

Modified: grc/trunk/examples/audio/b_flat_scale.grc.xml
===================================================================
--- grc/trunk/examples/audio/b_flat_scale.grc.xml       2007-10-01 22:51:52 UTC 
(rev 6568)
+++ grc/trunk/examples/audio/b_flat_scale.grc.xml       2007-10-02 05:16:19 UTC 
(rev 6569)
@@ -1,116 +1,214 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <flow_graph>
-  <timestamp>1179256591.06</timestamp>
-  <hostname>bowlcut</hostname>
-  <version>0.70 alpha</version>
+  <timestamp>1191300000.78</timestamp>
+  <hostname>tiggle</hostname>
+  <version>0.69</version>
   <valid>True</valid>
-  <window_width>800</window_width>
-  <window_height>600</window_height>
+  <window_width>1200</window_width>
+  <window_height>800</window_height>
   <vars>
     <var>
       <key>samp_rate</key>
-      <value>32000</value>
+      <value>32e3</value>
       <min/>
       <max/>
       <step/>
     </var>
     <var>
-      <key>A</key>
-      <value>440</value>
-      <min/>
-      <max/>
-      <step/>
-    </var>
-    <var>
-      <key>n</key>
-      <value>0</value>
-      <min>-4</min>
-      <max>8</max>
-      <step>1</step>
-    </var>
-    <var>
       <key>volume</key>
       <value>.1</value>
       <min>0</min>
       <max>.5</max>
       <step>0.005</step>
     </var>
+    <var>
+      <key>noise</key>
+      <value>.01</value>
+      <min>0</min>
+      <max>.1</max>
+      <step>0.001</step>
+    </var>
   </vars>
   <signal_blocks>
     <signal_block>
-      <tag>About</tag>
-      <id>About0</id>
-      <x_coordinate>91</x_coordinate>
-      <y_coordinate>41</y_coordinate>
-      <rotation>0</rotation>
+      <tag>Signal Source</tag>
+      <id>Signal Source1</id>
+      <x_coordinate>192</x_coordinate>
+      <y_coordinate>377</y_coordinate>
+      <rotation>90</rotation>
       <params>
-        <param>B flat</param>
-        <param>Josh Blum</param>
+        <param>1</param>
+        <param>$samp_rate</param>
+        <param>1</param>
+        <param>440</param>
+        <param>1</param>
+        <param>0</param>
       </params>
     </signal_block>
     <signal_block>
-      <tag>Note</tag>
-      <id>Note0</id>
-      <x_coordinate>30</x_coordinate>
-      <y_coordinate>136</y_coordinate>
-      <rotation>0</rotation>
+      <tag>Noise Source</tag>
+      <id>Noise Source0</id>
+      <x_coordinate>335</x_coordinate>
+      <y_coordinate>364</y_coordinate>
+      <rotation>90</rotation>
       <params>
-        <param>Generate pure musical tones.</param>
+        <param>1</param>
+        <param>1</param>
+        <param>$noise</param>
+        <param>71</param>
       </params>
     </signal_block>
     <signal_block>
+      <tag>FFT Sink</tag>
+      <id>FFT Sink0</id>
+      <x_coordinate>856</x_coordinate>
+      <y_coordinate>366</y_coordinate>
+      <rotation>270</rotation>
+      <params>
+        <param>1</param>
+        <param>FFT</param>
+        <param>$samp_rate</param>
+        <param>20</param>
+        <param>20</param>
+        <param>512</param>
+        <param>15</param>
+        <param>0</param>
+      </params>
+    </signal_block>
+    <signal_block>
+      <tag>Signal Source</tag>
+      <id>Signal Source0</id>
+      <x_coordinate>34</x_coordinate>
+      <y_coordinate>366</y_coordinate>
+      <rotation>90</rotation>
+      <params>
+        <param>1</param>
+        <param>$samp_rate</param>
+        <param>1</param>
+        <param>350</param>
+        <param>1</param>
+        <param>0</param>
+      </params>
+    </signal_block>
+    <signal_block>
       <tag>Scope Sink</tag>
       <id>Scope Sink0</id>
-      <x_coordinate>31</x_coordinate>
-      <y_coordinate>251</y_coordinate>
-      <rotation>180</rotation>
+      <x_coordinate>562</x_coordinate>
+      <y_coordinate>387</y_coordinate>
+      <rotation>270</rotation>
       <params>
         <param>1</param>
         <param>Scope</param>
         <param>$samp_rate</param>
         <param>1</param>
-        <param>.1</param>
-        <param>.001</param>
+        <param>0</param>
+        <param>0.001</param>
+        <param>2</param>
+        <param>1</param>
       </params>
     </signal_block>
     <signal_block>
-      <tag>Audio Sink</tag>
-      <id>Audio Sink0</id>
-      <x_coordinate>27</x_coordinate>
-      <y_coordinate>429</y_coordinate>
-      <rotation>180</rotation>
+      <tag>Add</tag>
+      <id>Add0</id>
+      <x_coordinate>420</x_coordinate>
+      <y_coordinate>133</y_coordinate>
+      <rotation>0</rotation>
       <params>
+        <param>1</param>
         <param>3</param>
       </params>
     </signal_block>
     <signal_block>
-      <tag>Signal Source</tag>
-      <id>Signal Source0</id>
-      <x_coordinate>411</x_coordinate>
-      <y_coordinate>344</y_coordinate>
-      <rotation>180</rotation>
+      <tag>Note</tag>
+      <id>Note0</id>
+      <x_coordinate>362</x_coordinate>
+      <y_coordinate>58</y_coordinate>
+      <rotation>0</rotation>
       <params>
+        <param>350 hz + 440 hz + AWGN</param>
+      </params>
+    </signal_block>
+    <signal_block>
+      <tag>About</tag>
+      <id>About0</id>
+      <x_coordinate>71</x_coordinate>
+      <y_coordinate>48</y_coordinate>
+      <rotation>0</rotation>
+      <params>
+        <param>The Famous Phone Tones</param>
+        <param>Josh Blum</param>
+      </params>
+    </signal_block>
+    <signal_block>
+      <tag>Multiply Constant</tag>
+      <id>Multiply Constant0</id>
+      <x_coordinate>594</x_coordinate>
+      <y_coordinate>221</y_coordinate>
+      <rotation>0</rotation>
+      <params>
         <param>1</param>
-        <param>$samp_rate</param>
-        <param>1</param>
-        <param>$A*2^($n/12)</param>
         <param>$volume</param>
-        <param>0</param>
       </params>
     </signal_block>
+    <signal_block>
+      <tag>Audio Sink</tag>
+      <id>Audio Sink0</id>
+      <x_coordinate>742</x_coordinate>
+      <y_coordinate>409</y_coordinate>
+      <rotation>270</rotation>
+      <params>
+        <param>3</param>
+      </params>
+    </signal_block>
   </signal_blocks>
   <connections>
     <connection>
-      <input_signal_block_id>Audio Sink0</input_signal_block_id>
+      <input_signal_block_id>Add0</input_signal_block_id>
       <input_socket_index>0</input_socket_index>
       <output_signal_block_id>Signal Source0</output_signal_block_id>
       <output_socket_index>0</output_socket_index>
     </connection>
     <connection>
+      <input_signal_block_id>Add0</input_signal_block_id>
+      <input_socket_index>1</input_socket_index>
+      <output_signal_block_id>Signal Source1</output_signal_block_id>
+      <output_socket_index>0</output_socket_index>
+    </connection>
+    <connection>
+      <input_signal_block_id>Multiply Constant0</input_signal_block_id>
+      <input_socket_index>0</input_socket_index>
+      <output_signal_block_id>Add0</output_signal_block_id>
+      <output_socket_index>0</output_socket_index>
+    </connection>
+    <connection>
+      <input_signal_block_id>Audio Sink0</input_signal_block_id>
+      <input_socket_index>0</input_socket_index>
+      <output_signal_block_id>Multiply Constant0</output_signal_block_id>
+      <output_socket_index>0</output_socket_index>
+    </connection>
+    <connection>
+      <input_signal_block_id>Add0</input_signal_block_id>
+      <input_socket_index>2</input_socket_index>
+      <output_signal_block_id>Noise Source0</output_signal_block_id>
+      <output_socket_index>0</output_socket_index>
+    </connection>
+    <connection>
+      <input_signal_block_id>FFT Sink0</input_signal_block_id>
+      <input_socket_index>0</input_socket_index>
+      <output_signal_block_id>Multiply Constant0</output_signal_block_id>
+      <output_socket_index>0</output_socket_index>
+    </connection>
+    <connection>
       <input_signal_block_id>Scope Sink0</input_signal_block_id>
       <input_socket_index>0</input_socket_index>
-      <output_signal_block_id>Signal Source0</output_signal_block_id>
+      <output_signal_block_id>Multiply Constant0</output_signal_block_id>
       <output_socket_index>0</output_socket_index>
     </connection>
+    <connection>
+      <input_signal_block_id>Audio Sink0</input_signal_block_id>
+      <input_socket_index>1</input_socket_index>
+      <output_signal_block_id>Multiply Constant0</output_signal_block_id>
+      <output_socket_index>0</output_socket_index>
+    </connection>
   </connections>
 </flow_graph>

Modified: grc/trunk/src/ActionHandler.py
===================================================================
--- grc/trunk/src/ActionHandler.py      2007-10-01 22:51:52 UTC (rev 6568)
+++ grc/trunk/src/ActionHandler.py      2007-10-02 05:16:19 UTC (rev 6569)
@@ -48,20 +48,21 @@
                """                             
                if PY_GTK_ICON: 
gtk.window_set_default_icon_from_file(PY_GTK_ICON)
                for action in ACTIONS_LIST: action.connect('activate', 
self._handle_actions)
-               ### create the main window and setup the Messages       ###
+               #setup the main window
                self.main_window = Graphics.MainWindow(self.handle_states)
-               Preferences.load(self.main_window)
+               self.main_window.connect('delete_event', self._quit)
+               self.main_window.connect('key_press_event', 
self._handle_key_press)
                self.get_flow_graph = self.main_window.get_flow_graph
                self.get_page = self.main_window.get_page
+               #setup the messages
                Messages.register_messenger(self.main_window.add_report_line)
                Messages.register_messenger(sys.stdout.write)
                Messages.send_init()
-               self.main_window.connect('delete_event', self._quit)
-               self.main_window.connect('key_press_event', 
self._handle_key_press)
-               #flow graph settings            
+               #flow graph settings    
+               Preferences.load(self.main_window)      
                self.init_file_paths = file_paths
                self.handle_states(APPLICATION_INITIALIZE)
-               # enter the mainloop            
+               #enter the mainloop             
                gtk.gdk.threads_init()
                gtk.gdk.threads_enter()
                gtk.main()
@@ -279,7 +280,7 @@
                        self.main_window.new_page()
                elif state == FLOW_GRAPH_OPEN:
                        file_path = 
Graphics.OpenFlowGraphFileDialog(self.get_flow_graph() and 
self.get_page().get_file_path() or '').run()
-                       if file_path != None: 
self.main_window.new_page(file_path)
+                       if file_path != None: 
self.main_window.new_page(file_path, manual_open=True)
                elif state == FLOW_GRAPH_CLOSE:
                        self.main_window.close_page()           
                elif state == FLOW_GRAPH_SAVE:

Modified: grc/trunk/src/Graphics/MainWindow.py
===================================================================
--- grc/trunk/src/Graphics/MainWindow.py        2007-10-01 22:51:52 UTC (rev 
6568)
+++ grc/trunk/src/Graphics/MainWindow.py        2007-10-02 05:16:19 UTC (rev 
6569)
@@ -52,12 +52,11 @@
                #import the file
                self.main_window = main_window
                initial_state = ParseXML.from_xml(ParseXML.from_file(file_path 
or INITIAL_FLOW_GRAPH_FILE))
-               
self.main_window.get_flow_graph().from_nested_data(initial_state)
-               self.state_cache = 
StateCache(self.main_window.get_flow_graph().to_nested_data())
+               self.state_cache = StateCache(initial_state)
                self.set_pid_file('')
                self.set_file_path(file_path)           
                self.set_saved(True)    
-               #import success, initialize page                
+               #parse xml success, initialize page             
                gtk.HBox.__init__(self, False, 0)
                self.show()             
                #tab box to hold label and close button
@@ -211,7 +210,7 @@
                fg_and_report_box.pack_end(self.reports_scrolled_window, False) 
#dont allow resize, fg should get all the space
                # show all but the main window container and the reports window 
                vbox.show_all()                 
-               self.show_reports_window(False) 
+               self._show_reports_window(False) 
                # load preferences and show the main window 
                Preferences.load(self)
                self.show()#show after resize in preferences
@@ -240,6 +239,7 @@
                @param page_num new page number
                """             
                self.current_page = self.notebook.get_nth_page(page_num)
+               Messages.send_page_switch(self.current_page.get_file_path())
                state = self.get_page().get_state_cache().get_current_state()
                self.get_flow_graph().from_nested_data(state)
                self.handle_states(NOTHING_SELECT) 
@@ -250,14 +250,14 @@
        
        def add_report_line(self, line):
                """!
-               Place line plus a newline at the end of the text buffer, then 
scroll its window all the way down.
+               Place line at the end of the text buffer, then scroll its 
window all the way down.
                @param line the new text
                """
                self.text_display.insert(line)          
                vadj = self.reports_scrolled_window.get_vadjustment()
                vadj.set_value(vadj.upper)
                                                
-       def show_reports_window(self, show):
+       def _show_reports_window(self, show):
                """!
                Show the reports window when show is True.
                Hide the reports window when show is False.
@@ -270,12 +270,14 @@
        ##      Pages: create and close
        ############################################################
        
-       def new_page(self, file_path=''):
+       def new_page(self, file_path='', manual_open=False):
                """!
                Create a new notebook page.
                Set the tab to be selected.
                @param file_path optional file to load into the flow graph
+               @param manual_open true if the user initiated this open from 
dialog
                """
+               #if the file is already open, show the open page and return
                if file_path and file_path in self._get_files(): #already open
                        page = 
self.notebook.get_nth_page(self._get_files().index(file_path))
                        self._set_page(page)
@@ -284,14 +286,16 @@
                        if file_path: Messages.send_start_load(file_path)
                        page = Page(self, file_path)
                        if file_path: Messages.send_end_load()
-               except Exception, e: 
+               except Exception, e: #return on failure
                        Messages.send_fail_load(e)
                        return  
+               #add this page to the notebook
                self.notebook.append_page(page, page.get_tab())
                try: self.notebook.set_tab_reorderable(page, True)
                except: pass #gtk too old
                self.notebook.set_tab_label_packing(page, False, False, 
gtk.PACK_START)
-               if not file_path: self._set_page(page) #only show if blank
+               #only show if blank or manual 
+               if not file_path or manual_open: self._set_page(page) 
                
        def close_pages(self):
                """
@@ -361,7 +365,7 @@
                                )
                        )
                #reports window
-               Preferences.show_reports_window(self)
+               self._show_reports_window(Preferences.show_reports_window())
                        
        def get_flow_graph(self):
                """
@@ -382,7 +386,7 @@
        ############################################################
 
        def _set_page(self, page):
-               """
+               """!
                Set the current page.
                @param page the page widget
                """

Modified: grc/trunk/src/Messages.py
===================================================================
--- grc/trunk/src/Messages.py   2007-10-01 22:51:52 UTC (rev 6568)
+++ grc/trunk/src/Messages.py   2007-10-02 05:16:19 UTC (rev 6569)
@@ -23,7 +23,7 @@
 from Constants import VERSION,PREFERENCES_FILE_PATH
 import traceback
 
-##     A list of methods that can receive a message.   
+##     A list of functions that can receive a message. 
 MESSENGERS_LIST = list()
 
 def register_messenger(messenger):
@@ -41,17 +41,17 @@
        for messenger in MESSENGERS_LIST: messenger(message)
        
 ###########################################################################
-#      Special methods for specific program functionalities
+#      Special functions for specific program functionalities
 ###########################################################################
 def send_init():
-       send("""\
-                                       ---------------------------   Welcome 
to GRC %s   ---------------------------\n"""%VERSION)
+       send("""<<< Welcome to GRC %s >>>\n"""%VERSION)
+                                       
+def send_page_switch(file_path):
+       send('\nShowing: "%s"\n'%file_path)
 
-#################      methods for loading flow graphs 
########################################                                        
+#################      functions for loading flow graphs       
########################################                                        
 def send_start_load(file_path):
-       send("""\
-                                                       ------------------   
Loading Flow Graph   ------------------\n""")      
-       send('Trying to load: "%s"'%file_path + '\n')
+       send('\nLoading: "%s"'%file_path + '\n')
                                                        
 def send_error_load(error):
        send('>>> Error: %s\n'%error)
@@ -65,11 +65,9 @@
        send(">>> Failue\n")            
        traceback.print_exc()
 
-#################      methods for executing flow graphs       
########################################        
+#################      functions for executing flow graphs     
########################################        
 def send_start_exec(file_path):
-       send("""\
-                                                       ------------------   
Running Flow Graph   ------------------\n""")
-       send('Trying to execute: "%s"'%file_path + '\n')
+       send('\nExecuting: "%s"'%file_path + '\n')
 
 def send_end_exec(verbose):
        if verbose: 
@@ -78,15 +76,15 @@
                send("\n")
        send(">>> Done\n")
        
-#################      methods for saving flow graphs  
########################################                
+#################      functions for saving flow graphs        
########################################                
 def send_fail_save(file_path):
        send('>>> Error: Cannot save: %s\n'%file_path)
                                        
-#################      methods for connections 
########################################                                        
+#################      functions for connections       
########################################                                        
 def send_fail_connection():
        send('>>> Warning: A connection can only be created between an output 
socket and an unconnected input socket.\n')                                     
  
 
-#################      methods for preferences 
########################################
+#################      functions for preferences       
########################################
 def send_fail_load_preferences():
        send('>>> Error: Cannot load preferences file: 
"%s"\n'%PREFERENCES_FILE_PATH)
        

Modified: grc/trunk/src/Preferences.py
===================================================================
--- grc/trunk/src/Preferences.py        2007-10-01 22:51:52 UTC (rev 6568)
+++ grc/trunk/src/Preferences.py        2007-10-02 05:16:19 UTC (rev 6569)
@@ -27,6 +27,8 @@
 import ParseXML
 import Messages
 
+FILE_DELIMITER = '\n'
+
 PARAM_CHECKING_PREF = GraphicalParam('Parameter Checking', Bool(true='Verify 
Parameters', false='Ignore Invalid Params', default=True))
 CONNECTION_CHECKING_PREF = GraphicalParam('Connection Checking', 
Bool(true='Match Data Types', false='Ignore Data Types', default=True))
 SOCKET_CHECKING_PREF = GraphicalParam('Socket Checking', Bool(true='Require 
Connections', false='Allow Open Sockets', default=True))
@@ -165,10 +167,10 @@
        return _get_value(RESTORE_FILES_PREF)   
        
 def files_open():
-       return _get_value(FILES_OPEN_PREF).split('\n')
+       return _get_value(FILES_OPEN_PREF).split(FILE_DELIMITER)
        
 def save_files_open(files):
-       FILES_OPEN_PREF.get_data_type().set_data('\n'.join(files))
+       FILES_OPEN_PREF.get_data_type().set_data(FILE_DELIMITER.join(files))
        
 def check_connections():
        return _get_value(CONNECTION_CHECKING_PREF)
@@ -179,8 +181,8 @@
 def check_params():
        return _get_value(PARAM_CHECKING_PREF)
        
-def show_reports_window(window):
-       return window.show_reports_window(_get_value(REPORTS_WIN_SHOW_PREF))
+def show_reports_window():
+       return _get_value(REPORTS_WIN_SHOW_PREF)
        
 def get_grid_size():
        return _get_value(GRID_SIZE_PREF)       





reply via email to

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