commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8562 - in grc/trunk: examples/simple src/grc src/grc/


From: jblum
Subject: [Commit-gnuradio] r8562 - in grc/trunk: examples/simple src/grc src/grc/gui
Date: Sat, 7 Jun 2008 15:42:06 -0600 (MDT)

Author: jblum
Date: 2008-06-07 15:42:05 -0600 (Sat, 07 Jun 2008)
New Revision: 8562

Added:
   grc/trunk/examples/simple/ber_simulation.grc.xml
Modified:
   grc/trunk/src/grc/ActionHandler.py
   grc/trunk/src/grc/gui/MainWindow.py
   grc/trunk/src/grc/gui/NotebookPage.py
Log:
ber example, hide notebook tabs, renamed pid_file to pid

Added: grc/trunk/examples/simple/ber_simulation.grc.xml
===================================================================
--- grc/trunk/examples/simple/ber_simulation.grc.xml                            
(rev 0)
+++ grc/trunk/examples/simple/ber_simulation.grc.xml    2008-06-07 21:42:05 UTC 
(rev 8562)
@@ -0,0 +1,480 @@
+<?xml version='1.0' encoding='ASCII'?>
+<flow_graph>
+  <timestamp>Fri Jun  6 12:15:48 2008</timestamp>
+  <block>
+    <key>options</key>
+    <param>
+      <key>id</key>
+      <value>options</value>
+    </param>
+    <param>
+      <key>title</key>
+      <value>BER Simulation</value>
+    </param>
+    <param>
+      <key>author</key>
+      <value>Example</value>
+    </param>
+    <param>
+      <key>description</key>
+      <value>Adjust the noise and constellation... see what happens!</value>
+    </param>
+    <param>
+      <key>window_size</key>
+      <value>1280, 1024</value>
+    </param>
+    <param>
+      <key>generate_options</key>
+      <value>wx_gui</value>
+    </param>
+    <param>
+      <key>gui_coordinate</key>
+      <value>(16, 10)</value>
+    </param>
+    <param>
+      <key>gui_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>import</key>
+    <param>
+      <key>id</key>
+      <value>import</value>
+    </param>
+    <param>
+      <key>import</key>
+      <value>import math</value>
+    </param>
+    <param>
+      <key>gui_coordinate</key>
+      <value>(142, 152)</value>
+    </param>
+    <param>
+      <key>gui_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_add_vxx</key>
+    <param>
+      <key>id</key>
+      <value>gr_add_vxx</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>num_inputs</key>
+      <value>2</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>gui_coordinate</key>
+      <value>(652, 395)</value>
+    </param>
+    <param>
+      <key>gui_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>wxgui_constellationsink2</key>
+    <param>
+      <key>id</key>
+      <value>wxgui_constellationsink2</value>
+    </param>
+    <param>
+      <key>title</key>
+      <value>"Constellation: "+str(const)</value>
+    </param>
+    <param>
+      <key>samp_rate</key>
+      <value>samp_rate</value>
+    </param>
+    <param>
+      <key>frame_decim</key>
+      <value>15</value>
+    </param>
+    <param>
+      <key>marker</key>
+      <value>set_format_plus</value>
+    </param>
+    <param>
+      <key>grid_pos</key>
+      <value>2, 0, 1, 1</value>
+    </param>
+    <param>
+      <key>gui_coordinate</key>
+      <value>(907, 334)</value>
+    </param>
+    <param>
+      <key>gui_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_noise_source_x</key>
+    <param>
+      <key>id</key>
+      <value>gr_noise_source_x</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>noise_type</key>
+      <value>gr.GR_GAUSSIAN</value>
+    </param>
+    <param>
+      <key>amp</key>
+      <value>noise</value>
+    </param>
+    <param>
+      <key>seed</key>
+      <value>42</value>
+    </param>
+    <param>
+      <key>gui_coordinate</key>
+      <value>(235, 379)</value>
+    </param>
+    <param>
+      <key>gui_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_chunks_to_symbols_xx</key>
+    <param>
+      <key>id</key>
+      <value>gr_chunks_to_symbols_xx</value>
+    </param>
+    <param>
+      <key>in_type</key>
+      <value>byte</value>
+    </param>
+    <param>
+      <key>out_type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>symbol_table</key>
+      <value>const</value>
+    </param>
+    <param>
+      <key>dimension</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>gui_coordinate</key>
+      <value>(360, 237)</value>
+    </param>
+    <param>
+      <key>gui_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>samp_rate</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>50e3</value>
+    </param>
+    <param>
+      <key>gui_coordinate</key>
+      <value>(20, 150)</value>
+    </param>
+    <param>
+      <key>gui_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>random_source_x</key>
+    <param>
+      <key>id</key>
+      <value>random_source_x</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>byte</value>
+    </param>
+    <param>
+      <key>min</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>max</key>
+      <value>len(const)</value>
+    </param>
+    <param>
+      <key>num_samps</key>
+      <value>1000000</value>
+    </param>
+    <param>
+      <key>repeat</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>gui_coordinate</key>
+      <value>(12, 228)</value>
+    </param>
+    <param>
+      <key>gui_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>wxgui_numbersink2</key>
+    <param>
+      <key>id</key>
+      <value>wxgui_numbersink2</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>float</value>
+    </param>
+    <param>
+      <key>title</key>
+      <value>BER</value>
+    </param>
+    <param>
+      <key>units</key>
+      <value>%</value>
+    </param>
+    <param>
+      <key>samp_rate</key>
+      <value>samp_rate</value>
+    </param>
+    <param>
+      <key>base_value</key>
+      <value>0.0</value>
+    </param>
+    <param>
+      <key>min_value</key>
+      <value>0.0</value>
+    </param>
+    <param>
+      <key>max_value</key>
+      <value>1.0</value>
+    </param>
+    <param>
+      <key>factor</key>
+      <value>100</value>
+    </param>
+    <param>
+      <key>decimal_places</key>
+      <value>4</value>
+    </param>
+    <param>
+      <key>ref_level</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>number_rate</key>
+      <value>15</value>
+    </param>
+    <param>
+      <key>avg_alpha</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>options</key>
+      <value>none</value>
+    </param>
+    <param>
+      <key>show_gauge</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>grid_pos</key>
+      <value>1, 0, 1, 1</value>
+    </param>
+    <param>
+      <key>gui_coordinate</key>
+      <value>(1062, 11)</value>
+    </param>
+    <param>
+      <key>gui_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>noise</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>.25</value>
+    </param>
+    <param>
+      <key>gui_coordinate</key>
+      <value>(31, 381)</value>
+    </param>
+    <param>
+      <key>gui_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>const</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>1+1j, 1-1j, -1-1j, -1+1j</value>
+    </param>
+    <param>
+      <key>gui_coordinate</key>
+      <value>(23, 461)</value>
+    </param>
+    <param>
+      <key>gui_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_throttle</key>
+    <param>
+      <key>id</key>
+      <value>gr_throttle</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>byte</value>
+    </param>
+    <param>
+      <key>samples_per_second</key>
+      <value>samp_rate</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>gui_coordinate</key>
+      <value>(397, 27)</value>
+    </param>
+    <param>
+      <key>gui_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>blks2_error_rate</key>
+    <param>
+      <key>id</key>
+      <value>blks2_error_rate</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>"BER"</value>
+    </param>
+    <param>
+      <key>win_size</key>
+      <value>1000000</value>
+    </param>
+    <param>
+      <key>bits_per_symbol</key>
+      <value>int(math.log(len(const))/math.log(2))</value>
+    </param>
+    <param>
+      <key>gui_coordinate</key>
+      <value>(670, 41)</value>
+    </param>
+    <param>
+      <key>gui_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>gr_constellation_decoder_cb</key>
+    <param>
+      <key>id</key>
+      <value>gr_constellation_decoder_cb</value>
+    </param>
+    <param>
+      <key>sym_position</key>
+      <value>const</value>
+    </param>
+    <param>
+      <key>sym_value_out</key>
+      <value>range(len(const))</value>
+    </param>
+    <param>
+      <key>gui_coordinate</key>
+      <value>(708, 224)</value>
+    </param>
+    <param>
+      <key>gui_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <connection>
+    <source_block_id>blks2_error_rate</source_block_id>
+    <sink_block_id>wxgui_numbersink2</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_throttle</source_block_id>
+    <sink_block_id>blks2_error_rate</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_constellation_decoder_cb</source_block_id>
+    <sink_block_id>blks2_error_rate</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>1</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_add_vxx</source_block_id>
+    <sink_block_id>gr_constellation_decoder_cb</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_chunks_to_symbols_xx</source_block_id>
+    <sink_block_id>gr_add_vxx</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_noise_source_x</source_block_id>
+    <sink_block_id>gr_add_vxx</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>1</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>gr_add_vxx</source_block_id>
+    <sink_block_id>wxgui_constellationsink2</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>random_source_x</source_block_id>
+    <sink_block_id>gr_throttle</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>random_source_x</source_block_id>
+    <sink_block_id>gr_chunks_to_symbols_xx</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+</flow_graph>
\ No newline at end of file

Modified: grc/trunk/src/grc/ActionHandler.py
===================================================================
--- grc/trunk/src/grc/ActionHandler.py  2008-06-07 02:43:04 UTC (rev 8561)
+++ grc/trunk/src/grc/ActionHandler.py  2008-06-07 21:42:05 UTC (rev 8562)
@@ -20,7 +20,7 @@
 #ActionHandler builds the interface and handles most of the user inputs.       
        
 address@hidden Josh Blum
 
-import os, sys
+import os, sys, signal
 from Constants import *
 from Actions import *
 import pygtk
@@ -293,7 +293,7 @@
                elif state == FLOW_GRAPH_SCREEN_CAPTURE:
                        file_path = 
gui.SaveImageFileDialog(self.get_page().get_file_path()).run()
                        if file_path != None: 
-                               pixmap = self.main_window.drawing_area.pixmap
+                               pixmap = 
self.get_flow_graph().get_drawing_area().pixmap
                                width, height = pixmap.get_size()
                                pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, 
0, 8, width, height)
                                pixbuf.get_from_drawable(pixmap, 
pixmap.get_colormap(), 0, 0, 0, 0, width, height)
@@ -302,7 +302,7 @@
                #       Gen/Exec/Stop
                
##############################################################################################
          
                elif state == FLOW_GRAPH_GEN:
-                       if not self.get_page().get_pid_file():
+                       if not self.get_page().get_pid():
                                if not self.get_page().get_saved() or not 
self.get_page().get_file_path(): 
                                        self.handle_states(FLOW_GRAPH_SAVE) 
#only save if file path missing or not saved
                                if self.get_page().get_saved() and 
self.get_page().get_file_path(): 
@@ -313,14 +313,14 @@
                                        except Exception,e: 
Messages.send_fail_gen(e)
                                else: self.generator = None                     
                elif state == FLOW_GRAPH_EXEC:
-                       if not self.get_page().get_pid_file():
+                       if not self.get_page().get_pid():
                                self.handle_states(FLOW_GRAPH_GEN)
                                if self.get_page().get_saved() and 
self.get_page().get_file_path():
                                        ExecFlowGraphThread(self)
                elif state == FLOW_GRAPH_KILL:
-                       if self.get_page().get_pid_file(): 
-                               try: os.kill(self.get_page().get_pid_file(), 9)
-                               except: print "could not kill pid file: 
%s"%self.get_page().get_pid_file()
+                       if self.get_page().get_pid(): 
+                               try: os.kill(self.get_page().get_pid(), 
signal.SIGKILL)
+                               except: print "could not kill pid: 
%s"%self.get_page().get_pid()
                elif state == '': #pass and run the global actions
                        pass
                else: print '!!! State "%s" not handled !!!'%state
@@ -338,10 +338,10 @@
                Update the exec and stop buttons.
                Lock and unlock the mutex for race conditions with exec flow 
graph threads.
                """
-               sensitive = self.get_flow_graph().is_valid() and not 
self.get_page().get_pid_file()
+               sensitive = self.get_flow_graph().is_valid() and not 
self.get_page().get_pid()
                get_action_from_name(FLOW_GRAPH_GEN).set_sensitive(sensitive)
                get_action_from_name(FLOW_GRAPH_EXEC).set_sensitive(sensitive)
-               
get_action_from_name(FLOW_GRAPH_KILL).set_sensitive(self.get_page().get_pid_file()
 != '')       
+               
get_action_from_name(FLOW_GRAPH_KILL).set_sensitive(self.get_page().get_pid() 
!= None)  
                        
 class ExecFlowGraphThread(Thread):
        """Execute the flow graph as a new process and wait on it to finish."""
@@ -359,7 +359,7 @@
                #get the popen
                try: 
                        self.p = self.page.get_generator().get_popen()
-                       self.page.set_pid_file(self.p.pid)
+                       self.page.set_pid(self.p.pid)
                        #update
                        self.update_exec_stop()
                        self.start()
@@ -378,7 +378,7 @@
                        r = os.read(self.p.stdout.fileno(), 1024)
                gtk.gdk.threads_enter()         
                Messages.send_end_exec()        
-               self.page.set_pid_file('')
+               self.page.set_pid(None)
                self.update_exec_stop()
                gtk.gdk.threads_leave()
                

Modified: grc/trunk/src/grc/gui/MainWindow.py
===================================================================
--- grc/trunk/src/grc/gui/MainWindow.py 2008-06-07 02:43:04 UTC (rev 8561)
+++ grc/trunk/src/grc/gui/MainWindow.py 2008-06-07 21:42:05 UTC (rev 8562)
@@ -87,7 +87,8 @@
                
self.reports_scrolled_window.add_with_viewport(self.text_display)       
                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()                 
+               vbox.show_all()
+               self.notebook.hide()
                self._show_reports_window(False) 
                # load preferences and show the main window 
                Preferences.load(self)
@@ -208,7 +209,7 @@
                """
                if not self.page_to_be_closed: self.page_to_be_closed = 
self.get_page()
                #show the page if it has an executing flow graph or is unsaved
-               if self.page_to_be_closed.get_pid_file() or not 
self.page_to_be_closed.get_saved():
+               if self.page_to_be_closed.get_pid() or not 
self.page_to_be_closed.get_saved():
                        self._set_page(self.page_to_be_closed)
                #unsaved? ask the user
                if not self.page_to_be_closed.get_saved() and 
self._save_changes(): 
@@ -217,7 +218,7 @@
                                self.page_to_be_closed = None   #set the page 
to be closed back to None
                                return
                #stop the flow graph if executing
-               if self.page_to_be_closed.get_pid_file(): 
self.handle_states(FLOW_GRAPH_KILL)
+               if self.page_to_be_closed.get_pid(): 
self.handle_states(FLOW_GRAPH_KILL)
                #remove the page
                
self.notebook.remove_page(self.notebook.page_num(self.page_to_be_closed))
                if ensure and self.notebook.get_n_pages() == 0: self.new_page() 
#no pages, make a new one
@@ -255,6 +256,9 @@
                        )
                #reports window
                self._show_reports_window(Preferences.show_reports_window())
+               #show/hide notebook tabs 
+               if len(self._get_pages()) > 1: self.notebook.show()
+               else: self.notebook.hide()
                
        def get_page(self):
                """!

Modified: grc/trunk/src/grc/gui/NotebookPage.py
===================================================================
--- grc/trunk/src/grc/gui/NotebookPage.py       2008-06-07 02:43:04 UTC (rev 
8561)
+++ grc/trunk/src/grc/gui/NotebookPage.py       2008-06-07 21:42:05 UTC (rev 
8562)
@@ -43,7 +43,7 @@
                @param file_path path to a flow graph file
                """             
                self._flow_graph = flow_graph
-               self.set_pid_file('')
+               self.set_pid(None)
                #import the file
                self.main_window = main_window
                self.set_file_path(file_path)
@@ -114,19 +114,19 @@
                """
                return self.tab
                
-       def get_pid_file(self):
+       def get_pid(self):
                """!
-               Get the pid file for the flow graph.
-               @return the pid file or ''
+               Get the pid for the flow graph.
+               @return the pid number
                """
-               return self.pid_file
+               return self.pid
        
-       def set_pid_file(self, pid_file=''):
+       def set_pid(self, pid):
                """!
-               Set the pid file, '' for no pid file.
-               @param pid_file file path string
+               Set the pid number.
+               @param pid the new pid number
                """
-               self.pid_file = pid_file
+               self.pid = pid
                
        def get_flow_graph(self):
                """!





reply via email to

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