commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8119 - in grc/branches/grc_reloaded: notes src/grc sr


From: jblum
Subject: [Commit-gnuradio] r8119 - in grc/branches/grc_reloaded: notes src/grc src/grc/gui src/grc_gnuradio
Date: Thu, 27 Mar 2008 16:20:35 -0600 (MDT)

Author: jblum
Date: 2008-03-27 16:20:35 -0600 (Thu, 27 Mar 2008)
New Revision: 8119

Modified:
   grc/branches/grc_reloaded/notes/todo.txt
   grc/branches/grc_reloaded/src/grc/ActionHandler.py
   grc/branches/grc_reloaded/src/grc/Actions.py
   grc/branches/grc_reloaded/src/grc/Messages.py
   grc/branches/grc_reloaded/src/grc/gui/Bars.py
   grc/branches/grc_reloaded/src/grc/gui/Dialogs.py
   grc/branches/grc_reloaded/src/grc_gnuradio/Generator.py
Log:
added generate option

Modified: grc/branches/grc_reloaded/notes/todo.txt
===================================================================
--- grc/branches/grc_reloaded/notes/todo.txt    2008-03-27 21:45:06 UTC (rev 
8118)
+++ grc/branches/grc_reloaded/notes/todo.txt    2008-03-27 22:20:35 UTC (rev 
8119)
@@ -7,12 +7,12 @@
 -cpm (blks2)
 -filterbank (blks2)
 -usrp quad souce, set z == 1 to ignore Q inputs 
+-usrp hier2 blocks
 
 ############   Known Problems: ####################
 -packet threads block on close
 -usrp transmit dies in lock/unlock
 -audio dies lock/unlock
--numbersink needs patch to set peak hold
 
 ############   Features to Add:        ####################
 -startup tips

Modified: grc/branches/grc_reloaded/src/grc/ActionHandler.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/ActionHandler.py  2008-03-27 21:45:06 UTC 
(rev 8118)
+++ grc/branches/grc_reloaded/src/grc/ActionHandler.py  2008-03-27 22:20:35 UTC 
(rev 8119)
@@ -48,6 +48,7 @@
                @param file_paths a list of flow graph file passed from command 
line
                @param platform platform module
                """
+               self.generator = None
                platform = Platform(platform)                   
                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)
@@ -119,11 +120,13 @@
                        self.handle_states(PORT_CONTROLLER_INC)
                elif self.get_focus_flag() and keyname in ('minus', 
'KP_Subtract'): #mouse focus
                        self.handle_states(PORT_CONTROLLER_DEC)         
-               ####################    Exec/Stop/Print 
###############################
+               ####################    Gen/Exec/Stop/Print     
###############################
                elif keyname == 'F5':
+                       self.handle_states(FLOW_GRAPH_GEN)
+               elif keyname == 'F6':
                        self.handle_states(FLOW_GRAPH_EXEC)
                elif keyname == 'F7':
-                       self.handle_states(FLOW_GRAPH_STOP)
+                       self.handle_states(FLOW_GRAPH_KILL)
                elif keyname == 'Print':
                        self.handle_states(FLOW_GRAPH_SCREEN_CAPTURE)
                #propagate this if the fg is not in focus or nothing is selected
@@ -299,15 +302,29 @@
                                pixbuf.get_from_drawable(pixmap, 
pixmap.get_colormap(), 0, 0, 0, 0, width, height)
                                pixbuf.save(file_path, 
IMAGE_FILE_EXTENSION[1:])                                                
                
##############################################################################################
-               #       Exec/Stop
+               #       Gen/Exec/Stop
                
##############################################################################################
          
-               elif state == FLOW_GRAPH_EXEC:
+               elif state == FLOW_GRAPH_GEN:
                        if not self.get_page().get_pid_file():
                                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(): 
-                                       ExecFlowGraphThread(self)       #only 
exec if file path and saved
-               elif state == FLOW_GRAPH_STOP:
+                                       self.generator = 
self.get_flow_graph().get_parent().get_generator()(
+                                               self.get_flow_graph(),
+                                               self.get_page().get_file_path(),
+                                       ) #only gen if file path and saved
+                                       try: 
+                                               
Messages.send_start_gen(self.generator.get_file_path())
+                                               self.generator.write_file()
+                                       except Exception,e: 
+                                               Messages.send_fail_gen(e)
+                                               self.generator = None   
+                               else: self.generator = None                     
+               elif state == FLOW_GRAPH_EXEC:
+                       if not self.get_page().get_pid_file():
+                               self.handle_states(FLOW_GRAPH_GEN)
+                               if self.generator: 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()
@@ -329,10 +346,10 @@
                Lock and unlock the mutex for race conditions with exec flow 
graph threads.
                """
                MUTEX.lock()
-               get_action_from_name(FLOW_GRAPH_EXEC).set_sensitive(
-                       self.get_flow_graph().is_valid() and not 
self.get_page().get_pid_file()
-               )
-               
get_action_from_name(FLOW_GRAPH_STOP).set_sensitive(self.get_page().get_pid_file()
 != '')       
+               sensitive = self.get_flow_graph().is_valid() and not 
self.get_page().get_pid_file()
+               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()
 != '')       
                MUTEX.unlock()
                        
 class ExecFlowGraphThread(Thread):
@@ -347,12 +364,10 @@
                self.flow_graph = action_handler.get_flow_graph()
                #store page and dont use main window calls in run
                self.page = action_handler.get_page()
-               #get generator
-               generator = 
self.flow_graph.get_parent().get_generator()(self.flow_graph)
-               Messages.send_start_exec(self.page.get_file_path())
+               
Messages.send_start_exec(action_handler.generator.get_file_path())
                #get the popen
                try: 
-                       self.p = generator.get_popen(self.page.get_file_path())
+                       self.p = action_handler.generator.get_popen()
                        self.page.set_pid_file(self.p.pid)
                        #update
                        self.update_exec_stop()

Modified: grc/branches/grc_reloaded/src/grc/Actions.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/Actions.py        2008-03-27 21:45:06 UTC 
(rev 8118)
+++ grc/branches/grc_reloaded/src/grc/Actions.py        2008-03-27 22:20:35 UTC 
(rev 8119)
@@ -60,8 +60,9 @@
 FLOW_GRAPH_SAVE_AS = 'flow graph save as'
 FLOW_GRAPH_CLOSE = 'flow graph close'
 FLOW_GRAPH_NEW = 'flow graph new'
+FLOW_GRAPH_GEN = 'flow graph gen'
 FLOW_GRAPH_EXEC = 'flow graph exec'
-FLOW_GRAPH_STOP = 'flow graph stop'
+FLOW_GRAPH_KILL = 'flow graph kill'
 FLOW_GRAPH_SCREEN_CAPTURE = 'flow graph screen capture'
 
 ABOUT_WINDOW_DISPLAY = 'about window display'
@@ -88,8 +89,9 @@
        gtk.Action(PREFS_WINDOW_DISPLAY, '_Preferences', 'Configure 
Preferences', 'gtk-preferences'),
        gtk.Action(ABOUT_WINDOW_DISPLAY, '_About', 'About this program', 
'gtk-about'),
        gtk.Action(HOTKEYS_WINDOW_DISPLAY, '_HotKeys', 'Hot Keys', 'gtk-info'),
+       gtk.Action(FLOW_GRAPH_GEN, '_Generate', 'Generate the flow graph', 
'gtk-convert'),
        gtk.Action(FLOW_GRAPH_EXEC, '_Execute', 'Execute the flow graph', 
'gtk-execute'),
-       gtk.Action(FLOW_GRAPH_STOP, '_Stop', 'Stop the flow graph', 'gtk-stop'),
+       gtk.Action(FLOW_GRAPH_KILL, '_Kill', 'Kill the flow graph', 'gtk-stop'),
        gtk.Action(FLOW_GRAPH_SCREEN_CAPTURE, 'S_creen Capture', 'Create a 
screen capture of the flow graph', 'gtk-print'),
 )
 

Modified: grc/branches/grc_reloaded/src/grc/Messages.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/Messages.py       2008-03-27 21:45:06 UTC 
(rev 8118)
+++ grc/branches/grc_reloaded/src/grc/Messages.py       2008-03-27 22:20:35 UTC 
(rev 8119)
@@ -65,6 +65,15 @@
        send(">>> Failue\n")            
        traceback.print_exc()
 
+#################      functions for generating flow graphs    
########################################        
+def send_start_gen(file_path):
+       send('\nGenerating: "%s"'%file_path + '\n')
+
+def send_fail_gen(error):
+       send('Generate Error: %s\n'%error)
+       send(">>> Failue\n")            
+       traceback.print_exc()
+
 #################      functions for executing flow graphs     
########################################        
 def send_start_exec(file_path):
        send('\nExecuting: "%s"'%file_path + '\n')

Modified: grc/branches/grc_reloaded/src/grc/gui/Bars.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/Bars.py       2008-03-27 21:45:06 UTC 
(rev 8118)
+++ grc/branches/grc_reloaded/src/grc/gui/Bars.py       2008-03-27 22:20:35 UTC 
(rev 8119)
@@ -36,8 +36,9 @@
        FLOW_GRAPH_UNDO,
        FLOW_GRAPH_REDO,
        None,
+       FLOW_GRAPH_GEN,
        FLOW_GRAPH_EXEC,
-       FLOW_GRAPH_STOP,
+       FLOW_GRAPH_KILL,
        None,
        ELEMENT_REMOVE,
        BLOCK_ROTATE_LEFT,
@@ -67,9 +68,10 @@
                BLOCK_ROTATE_RIGHT,
                BLOCK_PARAM_MODIFY,
        ]),
-       (gtk.Action('Execute', '_Execute', None, None), [
+       (gtk.Action('Build', '_Build', None, None), [
+               FLOW_GRAPH_GEN,
                FLOW_GRAPH_EXEC,
-               FLOW_GRAPH_STOP,
+               FLOW_GRAPH_KILL,
        ]),
        (gtk.Action('Options', '_Options', None, None), [
                PREFS_WINDOW_DISPLAY,                                   

Modified: grc/branches/grc_reloaded/src/grc/gui/Dialogs.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/Dialogs.py    2008-03-27 21:45:06 UTC 
(rev 8118)
+++ grc/branches/grc_reloaded/src/grc/gui/Dialogs.py    2008-03-27 22:20:35 UTC 
(rev 8119)
@@ -131,8 +131,9 @@
                        ('Modify Data Type', 'Down'),
                        ('Add a Port', '+'),
                        ('Remove a Port', '-'),
-                       ('Flow Graph Run', 'F5'),
-                       ('Flow Graph Stop', 'F7'),
+                       ('Flow Graph Generate', 'F5'),
+                       ('Flow Graph Execute', 'F6'),
+                       ('Flow Graph Kill', 'F7'),
                        ('Screen Shot', 'PrintScreen'),
                ): markup = '%s\n<b>%s:</b>%s'%(markup, action, 
hotkey.rjust(25-len(action), ' '))
                label = gtk.Label()

Modified: grc/branches/grc_reloaded/src/grc_gnuradio/Generator.py
===================================================================
--- grc/branches/grc_reloaded/src/grc_gnuradio/Generator.py     2008-03-27 
21:45:06 UTC (rev 8118)
+++ grc/branches/grc_reloaded/src/grc_gnuradio/Generator.py     2008-03-27 
22:20:35 UTC (rev 8119)
@@ -39,20 +39,24 @@
 
 class Generator(object):
        
-       def __init__(self, flow_graph):
+       def __init__(self, flow_graph, file_path):
                self._flow_graph = flow_graph
+               self._file_path = file_path.replace(FLOW_GRAPH_FILE_EXTENSION, 
'') + '.py'
                
-       def get_popen(self, file_path):
+       def get_file_path(self): return self._file_path
+               
+       def write_file(self):
+               #generate
+               open(self.get_file_path(), 'w').write(str(self))
+               
+       def get_popen(self):
                """!
                Generate and execute this python flow graph.
                @param file_path the file path of the flow graph
                @return a popen object
-               """
-               exec_file = file_path.replace(FLOW_GRAPH_FILE_EXTENSION, '') + 
'.py'
-               #generate file
-               open(exec_file, 'w').write(str(self))
+               """             
                #execute
-               cmds = [PYEXEC, exec_file]
+               cmds = [PYEXEC, self.get_file_path()]
                if self._flow_graph.get_option('generate_options') == 'no_gui':
                        cmds = ['xterm', '-e'] + cmds                   
                p = subprocess.Popen(args=cmds, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE, shell=False, universal_newlines=True)





reply via email to

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