[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5682 - in grc/branches/jblum_work/src: . Elements Gra
From: |
jblum |
Subject: |
[Commit-gnuradio] r5682 - in grc/branches/jblum_work/src: . Elements Graphics SignalBlockDefs |
Date: |
Tue, 5 Jun 2007 00:32:30 -0600 (MDT) |
Author: jblum
Date: 2007-06-05 00:32:30 -0600 (Tue, 05 Jun 2007)
New Revision: 5682
Added:
grc/branches/jblum_work/src/Editor.py
grc/branches/jblum_work/src/ExecFlowGraph.py
grc/branches/jblum_work/src/ExecFlowGraphGUI.py
Removed:
grc/branches/jblum_work/src/FlowGraphApp.py
grc/branches/jblum_work/src/Run.py
Modified:
grc/branches/jblum_work/src/ActionHandler.py
grc/branches/jblum_work/src/Actions.py
grc/branches/jblum_work/src/Constants.py
grc/branches/jblum_work/src/Elements/__init__.py
grc/branches/jblum_work/src/Graphics/Bars.py
grc/branches/jblum_work/src/Graphics/MainWindow.py
grc/branches/jblum_work/src/MathExprParser.py
grc/branches/jblum_work/src/SignalBlockDefs/Misc.py
grc/branches/jblum_work/src/SignalBlockDefs/SignalBlockTree.py
Log:
improved handling of importing modules, renamed executables, renamed run to
execute and snap shot to screen capture
Modified: grc/branches/jblum_work/src/ActionHandler.py
===================================================================
--- grc/branches/jblum_work/src/ActionHandler.py 2007-06-05 04:53:19 UTC
(rev 5681)
+++ grc/branches/jblum_work/src/ActionHandler.py 2007-06-05 06:32:30 UTC
(rev 5682)
@@ -102,13 +102,13 @@
self.handle_states(SOCKET_CONTROLLER_INC)
elif self.flow_graph.get_focus_flag() and keyname in ('minus',
'KP_Subtract'): #mouse focus
self.handle_states(SOCKET_CONTROLLER_DEC)
- #################### Run/Stop/Print
###############################
+ #################### Exec/Stop/Print
###############################
elif keyname == 'F5':
- self.handle_states(FLOW_GRAPH_RUN)
+ self.handle_states(FLOW_GRAPH_EXEC)
elif keyname == 'F7':
self.handle_states(FLOW_GRAPH_STOP)
elif keyname == 'Print':
- self.handle_states(FLOW_GRAPH_SNAP_SHOT)
+ self.handle_states(FLOW_GRAPH_SCREEN_CAPTURE)
#propagate this if the fg is not in focus or nothing is selected
return self.flow_graph.get_focus_flag() and
self.flow_graph.is_selected()
@@ -141,7 +141,7 @@
Graphics.enable_usrp_diagnostics() #try to enable
usrp diagnostics
for action in (APPLICATION_QUIT, FLOW_GRAPH_NEW,
FLOW_GRAPH_OPEN, FLOW_GRAPH_SAVE_AS,
ABOUT_WINDOW_DISPLAY, COLORS_WINDOW_DISPLAY, HOTKEYS_WINDOW_DISPLAY,
MATH_EXPR_WINDOW_DISPLAY,
-
FLOW_GRAPH_WINDOW_RESIZE, PREFS_WINDOW_DISPLAY, FLOW_GRAPH_SNAP_SHOT):
+
FLOW_GRAPH_WINDOW_RESIZE, PREFS_WINDOW_DISPLAY, FLOW_GRAPH_SCREEN_CAPTURE):
get_action_from_name(action).set_sensitive(True)
if self.flow_graph_file_path == '':
initial_state =
ParseXML.from_xml(ParseXML.from_file(INITIAL_FLOW_GRAPH_FILE))
@@ -296,7 +296,7 @@
if file_path != None:
self.flow_graph_file_path = file_path
self.handle_states(FLOW_GRAPH_SAVE)
- elif state == FLOW_GRAPH_SNAP_SHOT:
+ elif state == FLOW_GRAPH_SCREEN_CAPTURE:
fc = Graphics.FlowGraphFileDialog('save image',
self.flow_graph_file_path)
file_path = fc.run()
if file_path != None:
@@ -308,7 +308,7 @@
##############################################################################################
# Run/Stop
##############################################################################################
- elif state == FLOW_GRAPH_RUN:
+ elif state == FLOW_GRAPH_EXEC:
if self.pid_file == None:
self.handle_states(FLOW_GRAPH_SAVE)
if self.flow_graph_file_path != '': RUN(self)
@@ -319,9 +319,9 @@
except: print "could not kill pid file:
%s"%self.pid_file
MUTEX.unlock()
else: print "!!! State not handled !!!"
- # set the running button if the flow graph is valid and is not
already running #
+ # set the exec button if the flow graph is valid and is not
already running #
while not MUTEX.testandset(): pass #try to lock repeatedly
until lock is aquired
-
get_action_from_name(FLOW_GRAPH_RUN).set_sensitive(self.flow_graph.is_valid()
and self.pid_file == None)
+
get_action_from_name(FLOW_GRAPH_EXEC).set_sensitive(self.flow_graph.is_valid()
and self.pid_file == None)
MUTEX.unlock()
# hide/show the reports window based on the preferences #
self.main_window.show_reports_window(Preferences.show_reports_window())
@@ -353,7 +353,7 @@
self.pid_file = self.action_handler.pid_file =
'/tmp/grc-%d.pid'%os.getpid()
self.report_file = '/tmp/grc-%d.report'%os.getpid()
self.flow_graph_file_path =
self.action_handler.flow_graph_file_path
- get_action_from_name(FLOW_GRAPH_RUN).set_sensitive(False)
+ get_action_from_name(FLOW_GRAPH_EXEC).set_sensitive(False)
get_action_from_name(FLOW_GRAPH_STOP).set_sensitive(True)
Messages.send_start_run(self.flow_graph_file_path)
self.start()
@@ -373,5 +373,5 @@
while not MUTEX.testandset(): pass #try to lock repeatedly
until lock is aquired
self.action_handler.pid_file = None
get_action_from_name(FLOW_GRAPH_STOP).set_sensitive(False)
- get_action_from_name(FLOW_GRAPH_RUN).set_sensitive(True)
+ get_action_from_name(FLOW_GRAPH_EXEC).set_sensitive(True)
MUTEX.unlock()
Modified: grc/branches/jblum_work/src/Actions.py
===================================================================
--- grc/branches/jblum_work/src/Actions.py 2007-06-05 04:53:19 UTC (rev
5681)
+++ grc/branches/jblum_work/src/Actions.py 2007-06-05 06:32:30 UTC (rev
5682)
@@ -64,9 +64,9 @@
FLOW_GRAPH_SAVE_AS = 'flow graph save as'
FLOW_GRAPH_NEW = 'flow graph new'
FLOW_GRAPH_WINDOW_RESIZE = 'flow graph window resize'
-FLOW_GRAPH_RUN = 'flow graph run'
+FLOW_GRAPH_EXEC = 'flow graph exec'
FLOW_GRAPH_STOP = 'flow graph stop'
-FLOW_GRAPH_SNAP_SHOT = 'flow graph snap shot'
+FLOW_GRAPH_SCREEN_CAPTURE = 'flow graph screen capture'
ABOUT_WINDOW_DISPLAY = 'about window display'
COLORS_WINDOW_DISPLAY = 'colors window display'
@@ -98,9 +98,9 @@
gtk.Action(COLORS_WINDOW_DISPLAY, '_Colors', 'Data Type Colors',
'gtk-select-color'),
gtk.Action(HOTKEYS_WINDOW_DISPLAY, '_HotKeys', 'Hot Keys', 'gtk-info'),
gtk.Action(MATH_EXPR_WINDOW_DISPLAY, '_Math Expressions', 'Mathematical
Expressions', 'gtk-convert'),
- gtk.Action(FLOW_GRAPH_RUN, '_Run', 'Run the flow graph', 'gtk-execute'),
+ 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_SNAP_SHOT, 'S_nap Shot', 'Take a snap shot image
of the flow graph', 'gtk-print'),
+ gtk.Action(FLOW_GRAPH_SCREEN_CAPTURE, 'S_creen Capture', 'Create a
screen capture of the flow graph', 'gtk-print'),
]
def get_action_from_name(action_name):
Modified: grc/branches/jblum_work/src/Constants.py
===================================================================
--- grc/branches/jblum_work/src/Constants.py 2007-06-05 04:53:19 UTC (rev
5681)
+++ grc/branches/jblum_work/src/Constants.py 2007-06-05 06:32:30 UTC (rev
5682)
@@ -189,7 +189,7 @@
if sys.platform == 'darwin': PYEXEC = 'pythonw'
""" The default command to run a flow graph file """
-DEFAULT_FLOW_GRAPH_EXEC = '%s %s/FlowGraphApp.py'%(PYEXEC, SRC_DIR)
+DEFAULT_FLOW_GRAPH_EXEC = '%s %s/ExecFlowGraphGUI.py'%(PYEXEC, SRC_DIR)
""" The default user preferences file. """
PREFERENCES_FILE_PATH = os.path.abspath(DEFAULT_FILE_PATH + '/.grc.xml')
Added: grc/branches/jblum_work/src/Editor.py
===================================================================
--- grc/branches/jblum_work/src/Editor.py (rev 0)
+++ grc/branches/jblum_work/src/Editor.py 2007-06-05 06:32:30 UTC (rev
5682)
@@ -0,0 +1,57 @@
+#! /usr/bin/env python
+"""
+Copyright 2007 Free Software Foundation, Inc.
+This file is part of GNU Radio
+
+GNU Radio Companion is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+GNU Radio Companion is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+"""
+"""
+ Editor.py
+ Josh Blum
+ Execute the flow graph editor GUI. This file must be called by the
python interpreter.
+"""
+
+from Constants import VERSION,DEFAULT_FILE_EXTENSION
+from optparse import OptionParser
+
+if __name__ == "__main__":
+ usage = "usage: %prog optional_flow_graph"+DEFAULT_FILE_EXTENSION
+ version = """
+GNU Radio Companion %s
+
+This file is part of GNU Radio
+GRC comes with ABSOLUTELY NO WARRANTY.
+This is free software,
+and you are welcome to redistribute it.
+"""%VERSION
+ parser = OptionParser(usage=usage, version=version)
+ (options, args) = parser.parse_args()
+ # "test" import modules that this program will use #
+ try:
+ import pygtk
+ pygtk.require('2.0')
+ import gtk
+ import xml.dom.minidom
+ import xml.dom.ext
+ import gnuradio
+ except ImportError, e: #print error and exit
+ print 'Missing critical component: "%s"\nExiting!'%(e,)
+ exit(-1)
+ # end import of modules #
+ from ActionHandler import ActionHandler
+ if len(args): ActionHandler(args[0])
+ else: ActionHandler()
+ exit(0)
+
Property changes on: grc/branches/jblum_work/src/Editor.py
___________________________________________________________________
Name: svn:executable
+ *
Modified: grc/branches/jblum_work/src/Elements/__init__.py
===================================================================
--- grc/branches/jblum_work/src/Elements/__init__.py 2007-06-05 04:53:19 UTC
(rev 5681)
+++ grc/branches/jblum_work/src/Elements/__init__.py 2007-06-05 06:32:30 UTC
(rev 5682)
@@ -29,8 +29,11 @@
from Element import Element
from Param import Param
-from GraphicalSignalBlock import GraphicalSignalBlock
-from GraphicalSocket import
GraphicalSocket,GraphicalOutputSocket,GraphicalInputSocket
-from GraphicalConnection import GraphicalConnection
-from GraphicalElement import GraphicalElement
-from GraphicalParam import GraphicalParam
+try: #do not import if gtk module dne
+ from GraphicalSignalBlock import GraphicalSignalBlock
+ from GraphicalSocket import
GraphicalSocket,GraphicalOutputSocket,GraphicalInputSocket
+ from GraphicalConnection import GraphicalConnection
+ from GraphicalElement import GraphicalElement
+ from GraphicalParam import GraphicalParam
+except ImportError: pass
+
Added: grc/branches/jblum_work/src/ExecFlowGraph.py
===================================================================
--- grc/branches/jblum_work/src/ExecFlowGraph.py
(rev 0)
+++ grc/branches/jblum_work/src/ExecFlowGraph.py 2007-06-05 06:32:30 UTC
(rev 5682)
@@ -0,0 +1,26 @@
+#! /usr/bin/env python
+"""
+Copyright 2007 Free Software Foundation, Inc.
+This file is part of GNU Radio
+
+GNU Radio Companion is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+GNU Radio Companion is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+"""
+"""
+ ExecFlowGraph.py
+ Josh Blum
+ Use a xml input file to build and run a gnu radio flow graph with wx
GUI elements.
+"""
+
+#TODO: create this!
\ No newline at end of file
Property changes on: grc/branches/jblum_work/src/ExecFlowGraph.py
___________________________________________________________________
Name: svn:executable
+ *
Added: grc/branches/jblum_work/src/ExecFlowGraphGUI.py
===================================================================
--- grc/branches/jblum_work/src/ExecFlowGraphGUI.py
(rev 0)
+++ grc/branches/jblum_work/src/ExecFlowGraphGUI.py 2007-06-05 06:32:30 UTC
(rev 5682)
@@ -0,0 +1,265 @@
+#! /usr/bin/env python
+"""
+Copyright 2007 Free Software Foundation, Inc.
+This file is part of GNU Radio
+
+GNU Radio Companion is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+GNU Radio Companion is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+"""
+"""
+ ExecFlowGraphGUI.py
+ Josh Blum
+ Use a xml input file to build and run a gnu radio flow graph without
graphics.
+"""
+
+import ParseXML
+import Variables
+import SignalBlockDefs
+from Elements import SignalBlock
+from gnuradio import gr
+import wx
+import sys,os
+from Constants import *
+import math
+from optparse import OptionParser
+
+##############################################################################################
+# Variable Control
+##############################################################################################
+class VariableControl(wx.BoxSizer):
+ """ House a Slider and a Text Box for variable control. """
+ def __init__(self, parent, key, parse_callbacks):
+ """ Create the slider, text box, and label given the variable
key.
+ parse_callbacks is a method to update the registered
signal block callback methods. """
+ self.key = key
+ self.parse_callbacks = parse_callbacks
+ value, min, max, step = Variables.get_values(key)
+ wx.BoxSizer.__init__(self, wx.VERTICAL)
+ label_text_sizer = wx.BoxSizer(wx.HORIZONTAL) #label and text
box container
+ label = wx.StaticText(parent, -1, key+' -> ')
+ self.text_box = text_box = wx.TextCtrl(parent, -1, value,
style=wx.TE_PROCESS_ENTER)
+ text_box.Bind(wx.EVT_TEXT_ENTER, self.handle_enter) #bind
this special enter hotkey event
+ for obj in (label, text_box): #fill the container with label
and text entry box
+ label_text_sizer.Add(obj, 0,
wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL)
+ self.Add(label_text_sizer, 0, wx.ALIGN_CENTER)
+ ### Determine the slider width based on the number of steps
###
+ self.num_steps = num_steps =
(float(max)-float(min))/float(step)
+ if num_steps == DEFAULT_SLIDER_STEPS: slider_width =
DEFAULT_SLIDER_WIDTH
+ elif num_steps > DEFAULT_SLIDER_STEPS: # make the slider wider
than default
+ slider_width = MAX_SLIDER_WIDTH -
(MAX_SLIDER_WIDTH-DEFAULT_SLIDER_WIDTH)*DEFAULT_SLIDER_STEPS/num_steps
+ elif num_steps < DEFAULT_SLIDER_STEPS: # make the slider slimer
then default
+ slider_width = MIN_SLIDER_WIDTH +
(DEFAULT_SLIDER_WIDTH-MIN_SLIDER_WIDTH)*num_steps/DEFAULT_SLIDER_STEPS
+ self.slider_width = slider_width = int(slider_width) #make
sure width is an integer number of pixels
+ ### make the slider ###
+ self.slider = slider = wx.Slider(parent, -1,
size=wx.Size(slider_width, SLIDER_HEIGHT), style=wx.SL_HORIZONTAL)
+ try: slider.SetRange(0, num_steps)
+ except Exception, e:
+ sys.stderr.write('Slider, "%s", has too many
steps!\n'%key)
+ sys.exit(1)
+ slider.Bind(wx.EVT_SCROLL, self.handle_scroll) #bind the
scrolling event
+ self.Add(slider, 0, wx.ALIGN_CENTER)
+ self.handle_enter()#sets the slider's value
+
+ def get_slider_width(self):
+ """ Get the width of the slider in pixels. """
+ return self.slider_width
+
+ def get_slider_value(self):
+ """ Read the value from the slider slider.
+ Translate the slider value into a real numerical value. """
+ slider_value = self.slider.GetValue()
+ value, min, max, step = Variables.get_values(self.key)
+ return str(slider_value*(float(max)-float(min))/self.num_steps
+ float(min))
+
+ def set_slider_value(self, real_value):
+ """ Translate the real numerical value into a slider value.
+ Write the value to the slider. """
+ value, min, max, step = Variables.get_values(self.key)
+ slider_value =
(float(real_value)-float(min))*self.num_steps/(float(max)-float(min))
+ self.slider.SetValue(slider_value)
+
+ def handle_scroll(self, event=None):
+ """ A scroll event is detected. Read the slider. Try to
register the new entry:
+ If the registration passes, update the text box, and parse the
callbacks.
+ If the registration fails, restore the slider to the previous
registered values. """
+ key = self.key
+ new_value = str(self.get_slider_value()) #the new value
must be a string!
+ value, min, max, step = Variables.get_values(key)
+ Variables.unregister(key)
+ try:
+ Variables.register(key, new_value, min, max, step)
+ self.text_box.SetValue(str(new_value))
+ self.parse_callbacks()
+ except:
+ Variables.register(key, value, min, max, step)
+ self.set_slider_value(value)
+
+ def handle_enter(self, event=None):
+ """ An enter key was pressed. Read the text box. Try to
register the new entry:
+ If the registration passes, move the slider, and parse the
callbacks.
+ If the registration fails, restore the text box to the
previous registered value. """
+ key = self.key
+ new_value = str(self.text_box.GetValue()) #the new value
must be a string!
+ value, min, max, step = Variables.get_values(key)
+ Variables.unregister(key)
+ try:
+ Variables.register(key, new_value, min, max, step)
+ self.set_slider_value(new_value)
+ self.parse_callbacks()
+ except:
+ Variables.register(key, value, min, max, step)
+ self.text_box.SetValue(value)
+
+##############################################################################################
+# Flow Graph Frame
+##############################################################################################
+class FlowGraphFrame(wx.Frame, gr.flow_graph):
+ """ A FlowGraphFrame is a wx.Frame and a gr.flow_graph.
+ This flow graph frame parses a saved flow graph file,
+ houses all the sliders and graphical sinks,
+ and starts the flow graph. """
+ def __init__(self, file_path):
+ file_path = os.path.abspath(file_path)
+ wx.Frame.__init__(self, None , -1, MAIN_WINDOW_PREFIX+' -
Executing: '+file_path)
+ if WX_APP_ICON: self.SetIcon(wx.Icon(WX_APP_ICON,
wx.BITMAP_TYPE_ANY))
+ self.SetSizeHints(200, 100)
+ gr.flow_graph.__init__(self)
+ self.callbacks = list()
+ self.sliders_dict = dict()
+ self.text_box_dict = dict()
+ # create holder for scopes and ffts #
+ self.sink_windows = dict()
+ graphs_box = wx.GridSizer(1, 1, 0, 0)
+ self.panel = panel = wx.ScrolledWindow(self, -1)
+ panel.SetSizer(graphs_box)
+ # create the main box for all components #
+ main_box = wx.BoxSizer(wx.VERTICAL)
+ self.sliders_box = wx.BoxSizer(wx.VERTICAL)
+ main_box.Add(self.sliders_box, 0, wx.ALIGN_CENTER)
+ main_box.Add(panel, 0, wx.EXPAND)
+ self.Bind(wx.EVT_CLOSE, self.Quit)
+ nested_data = ParseXML.from_xml(ParseXML.from_file(file_path))
+ # fill in all the sliders and graphs #
+ self.parse_nested_data(nested_data)
+ graphs_box.SetCols(int(math.sqrt(len(self.sink_windows))))
+ for key in sorted(self.sink_windows.keys()):
graphs_box.Add(self.sink_windows[key], 0, wx.EXPAND)
+ self.SetSizerAndFit(main_box)
+ self.Show()
+ self.start() #start the flow graph
+
+ def Quit(self, event):
+ ''' Exit the application. '''
+ self.stop() #stop the flow graph
+ self.Destroy() #destroy the wx frame
+ sys.exit(0)
+
+ def add_window(self, window, type='', title=''):
+ ''' Register the scope/fft window with a unique key. '''
+ key = str(type) + str(title)
+ while self.sink_windows.has_key(key): key = key + '_'
+ self.sink_windows[key] = window
+
+ def get_panel(self):
+ ''' Get the panel that will parent the graphical blocks.
'''
+ return self.panel
+
+ def add_callback(self, function, data_type_params):
+ """ Register a callback function with its associated data.
"""
+ self.callbacks.append((function, data_type_params))
+
+ def parse_callbacks(self):
+ """ For each call back, parse all of the data and
+ call the registered callback function on that data. """
+ for function, data_type_params in self.callbacks:
+ try:
+ if type(data_type_params) in (type(list()),
type(tuple())):
+ function(*map(lambda param:
param.parse(), data_type_params))
+ else: function(data_type_params.parse())
+ except: print "error parsing a callback -> ignoring..."
+
+ def parse_nested_data(self, nested_data):
+ """ Parse nested data from a flow graph file and build the
graphics.
+ This code is partially copied from FlowGraph.py, with
unnecessary code removed. """
+ find_data = ParseXML.find_data
+ flow_graph = find_data([nested_data], 'flow_graph')
+ vars = find_data(flow_graph, 'vars')
+ signal_blocks = find_data(flow_graph, 'signal_blocks')
+ connections = find_data(flow_graph, 'connections')
+ len = 0
+ keys = Variables.from_nested_data(vars)
+ for key in keys:
+ value, min, max, step = Variables.get_values(key)
+ if Variables.is_ranged(key):
+ variable_control = VariableControl(self, key,
self.parse_callbacks)
+ width = variable_control.get_slider_width()
+ ### Create a new row of sliders if the
current row is full ###
+ if len == 0 or len + width > MAX_SLIDERS_WIDTH:
+ len = 0
+ slider_box = wx.BoxSizer(wx.HORIZONTAL)
+ self.sliders_box.Add(slider_box, 0,
wx.ALIGN_CENTER)
+ slider_box.Add(variable_control, 0,
wx.ALIGN_CENTER)
+ len = len + width
+ ################ done with sliders and variables
#######################
+ signal_blocks_dict = dict()
+ for signal_block in signal_blocks:
+ signal_block,runnable_signal_block =
SignalBlock.from_nested_data(None, signal_block, SignalBlock)
+ data_type_params = list()
+ data_type_params.append(self)#put the flow graph thing
here
+ for param in signal_block.get_params(): #load the list
of arguments to the runnable block
+ data_type_params.append(param.get_data_type())
+ signal_blocks_dict[signal_block.get_id()] =
runnable_signal_block(*data_type_params)
+ for connection in connections:
+ connection = find_data([connection], 'connection')
+ input_signal_block_id = find_data(connection,
'input_signal_block_id')
+ input_socket_index = int(find_data(connection,
'input_socket_index'))
+ output_signal_block_id = find_data(connection,
'output_signal_block_id')
+ output_socket_index = int(find_data(connection,
'output_socket_index'))
+ self.connect(# use this flow graph's connect method
#
+ (signal_blocks_dict[output_signal_block_id],
output_socket_index),
+ (signal_blocks_dict[input_signal_block_id],
input_socket_index))
+
+##############################################################################################
+# Flow Graph App
+##############################################################################################
+class FlowGraphApp(wx.App):
+ """ The FlowGraphApp is the wx.App containing the FlowGraphFrame.
"""
+ def __init__(self, flow_graph_file_path):
+ self.flow_graph_file_path = flow_graph_file_path
+ wx.App.__init__(self, 0)
+
+ def OnInit(self):
+ """ If the creation of the frame fails, return False so the
program will exit. """
+ try:
+
self.SetTopWindow(FlowGraphFrame(self.flow_graph_file_path))#first argument is
the flow graph
+ return True
+ except Exception, e:
+ sys.stderr.write(str(e)+'\n')
+ sys.exit(1)
+
+if __name__ == '__main__':
+ usage = "usage: %prog [-p] flow_graph"+DEFAULT_FILE_EXTENSION
+ parser = OptionParser(usage=usage)
+ parser.add_option("-p", "--pid_file", action="store", type="string",
dest="pid_file", help="record process id")
+ parser.add_option("-d", "--disable-wx", action="store_true",
dest="no_wx", default=False, help="disable the wx gui")
+ (options, args) = parser.parse_args()
+ if options.pid_file:
+ try: open(options.pid_file, 'w').write('%d\n' % os.getpid())
+ except: print "could not create pid file: %s"%options.pid_file
+ if len(args): #only create the wx app if a flow graph was passed
+ app = FlowGraphApp(args[0])
+ if options.no_wx: raw_input('Flow Graph Running...\nPress Enter
to Exit: ') #do not start wx
+ else: app.MainLoop() #start the wxApp MainLoop
+ else: parser.print_help()
+
+
\ No newline at end of file
Property changes on: grc/branches/jblum_work/src/ExecFlowGraphGUI.py
___________________________________________________________________
Name: svn:executable
+ *
Deleted: grc/branches/jblum_work/src/FlowGraphApp.py
Modified: grc/branches/jblum_work/src/Graphics/Bars.py
===================================================================
--- grc/branches/jblum_work/src/Graphics/Bars.py 2007-06-05 04:53:19 UTC
(rev 5681)
+++ grc/branches/jblum_work/src/Graphics/Bars.py 2007-06-05 06:32:30 UTC
(rev 5682)
@@ -28,69 +28,62 @@
import gtk
TOOLBAR_LIST = [
- FLOW_GRAPH_NEW,
- FLOW_GRAPH_OPEN,
- FLOW_GRAPH_SAVE,
- None,
- FLOW_GRAPH_SNAP_SHOT,
- None,
- FLOW_GRAPH_UNDO,
- FLOW_GRAPH_REDO,
- None,
- FLOW_GRAPH_RUN,
- FLOW_GRAPH_STOP,
- None,
- ELEMENT_DELETE,
- SIGNAL_BLOCK_ROTATE_LEFT,
- SIGNAL_BLOCK_ROTATE_RIGHT,
- ]
+ FLOW_GRAPH_NEW,
+ FLOW_GRAPH_OPEN,
+ FLOW_GRAPH_SAVE,
+ None,
+ FLOW_GRAPH_SCREEN_CAPTURE,
+ None,
+ FLOW_GRAPH_UNDO,
+ FLOW_GRAPH_REDO,
+ None,
+ FLOW_GRAPH_EXEC,
+ FLOW_GRAPH_STOP,
+ None,
+ ELEMENT_DELETE,
+ SIGNAL_BLOCK_ROTATE_LEFT,
+ SIGNAL_BLOCK_ROTATE_RIGHT,
+]
MENU_BAR_LIST = [
- (gtk.Action('File', '_File',
None, None),
- [
- FLOW_GRAPH_NEW,
- FLOW_GRAPH_OPEN,
- None,
- FLOW_GRAPH_SAVE,
-
FLOW_GRAPH_SAVE_AS,
- None,
-
FLOW_GRAPH_SNAP_SHOT,
- None,
-
APPLICATION_QUIT,
- ]),
- (gtk.Action('Edit', '_Edit',
None, None),
- [
- FLOW_GRAPH_UNDO,
- FLOW_GRAPH_REDO,
- None,
- ELEMENT_DELETE,
-
SIGNAL_BLOCK_ROTATE_LEFT,
-
SIGNAL_BLOCK_ROTATE_RIGHT,
-
SIGNAL_BLOCK_PARAM_MODIFY,
- ]),
- (gtk.Action('Run', '_Run',
None, None),
- [
- FLOW_GRAPH_RUN,
- FLOW_GRAPH_STOP,
- ]),
- (gtk.Action('Options',
'_Options', None, None),
- [
-
FLOW_GRAPH_WINDOW_RESIZE,
-
PREFS_WINDOW_DISPLAY,
- ]),
- (gtk.Action('Help', '_Help',
None, None),
- [
-
ABOUT_WINDOW_DISPLAY,
-
COLORS_WINDOW_DISPLAY,
-
HOTKEYS_WINDOW_DISPLAY,
-
MATH_EXPR_WINDOW_DISPLAY,
-
USRP_DIAGNOSTICS_DISPLAY,
- ])
+ (gtk.Action('File', '_File', None, None), [
+ FLOW_GRAPH_NEW,
+ FLOW_GRAPH_OPEN,
+ None,
+ FLOW_GRAPH_SAVE,
+ FLOW_GRAPH_SAVE_AS,
+ None,
+ FLOW_GRAPH_SCREEN_CAPTURE,
+ None,
+ APPLICATION_QUIT,
+ ]),
+ (gtk.Action('Edit', '_Edit', None, None), [
+ FLOW_GRAPH_UNDO,
+ FLOW_GRAPH_REDO,
+ None,
+ ELEMENT_DELETE,
+ SIGNAL_BLOCK_ROTATE_LEFT,
+ SIGNAL_BLOCK_ROTATE_RIGHT,
+ SIGNAL_BLOCK_PARAM_MODIFY,
+ ]),
+ (gtk.Action('Execute', '_Execute', None, None), [
+ FLOW_GRAPH_EXEC,
+ FLOW_GRAPH_STOP,
+ ]),
+ (gtk.Action('Options', '_Options', None, None), [
+ FLOW_GRAPH_WINDOW_RESIZE,
+ PREFS_WINDOW_DISPLAY,
+ ]),
+ (gtk.Action('Help', '_Help', None, None), [
+ ABOUT_WINDOW_DISPLAY,
+ COLORS_WINDOW_DISPLAY,
+ HOTKEYS_WINDOW_DISPLAY,
+ MATH_EXPR_WINDOW_DISPLAY,
+ USRP_DIAGNOSTICS_DISPLAY,
+ ])
- ]
+]
-
-
class Toolbar(gtk.Toolbar):
""" Toolbar is a gtk Toolbar with actions added from the toolbar
list """
def __init__(self):
Modified: grc/branches/jblum_work/src/Graphics/MainWindow.py
===================================================================
--- grc/branches/jblum_work/src/Graphics/MainWindow.py 2007-06-05 04:53:19 UTC
(rev 5681)
+++ grc/branches/jblum_work/src/Graphics/MainWindow.py 2007-06-05 06:32:30 UTC
(rev 5682)
@@ -92,7 +92,7 @@
def set_title(self, title):
""" set the title and prepend the program name """
- prepend_str = MAIN_WINDOW_PREFIX + ' - '
+ prepend_str = MAIN_WINDOW_PREFIX + ' - Editing: '
gtk.Window.set_title(self, prepend_str + str(title))
def show_reports_window(self, show):
Modified: grc/branches/jblum_work/src/MathExprParser.py
===================================================================
--- grc/branches/jblum_work/src/MathExprParser.py 2007-06-05 04:53:19 UTC
(rev 5681)
+++ grc/branches/jblum_work/src/MathExprParser.py 2007-06-05 06:32:30 UTC
(rev 5682)
@@ -66,7 +66,7 @@
def verify_int(num):
''' Verify that the number has no imaginary part.
- Verify that the complex number has no decimal part.
+ Verify that the number has no decimal part.
Otherwise raise an exception.
Return the value as a int '''
f_num = verify_float(num)
@@ -316,13 +316,12 @@
# remove whitespace #
return filter(lambda elem: not _is_whitespace(elem), elements)
-def _rectify_minus(elements):
- ''' Rectify the functionality of the minus sign (-)
- in the element list formed by separating the expression.
- Minus can be an operator or an implied -1*.
+def _rectify_operators(elements):
+ ''' Rectify the functionality of the minus sign (-),
+ and the plus sign (+) (in the floating point format).
Determine if the minus sign is used as a negative,
- and replace it with -1*.
- Return the list of elements with minus used only as an
operator. '''
+ and replace it with -1* or ^-. Also rejoin floating point
formats.
+ Return the list of elements with minus and plus used only as
operators. '''
rectified_elements = list()
for i,element in enumerate(elements):
if i == 0 and element == '-': #first element was a minus
@@ -335,10 +334,14 @@
else: #^ proceeds - in order of ops, remove the
^ and append ^- as a special operator
rectified_elements.pop() #remove
last element
rectified_elements.append('^-')
- elif elements[i-1][-1] == 'e' and
_is_number(elements[i-1][0:-1]): #found a floating point format
+ elif elements[i-1][-1] == 'e' and
_is_number(elements[i-1][0:-1]): #found a -floating point format
f = rectified_elements.pop() #remove last
element
elements[i+1] = "%s-%s"%(f, elements[i+1])
else: rectified_elements.append(element)
#regular minus
+ elif i != 0 and element == '+' and i+1 != len(elements) and \
+ elements[i-1][-1] == 'e' and
_is_number(elements[i-1][0:-1]): #found a +floating point format
+ f = rectified_elements.pop() #remove last element
+ elements[i+1] = "%s+%s"%(f, elements[i+1])
else: rectified_elements.append(element) #non minus
return rectified_elements
@@ -424,7 +427,7 @@
Return a list containing the parsed expression. '''
separated_elements = _separate_expression(expr_str)
#print "separated", separated_elements
- rectified_elements = _rectify_minus(separated_elements)
+ rectified_elements = _rectify_operators(separated_elements)
#print "rectified", rectified_elements
nested_elements = _nest_elements(rectified_elements)
#print "nested", nested_elements
Deleted: grc/branches/jblum_work/src/Run.py
Modified: grc/branches/jblum_work/src/SignalBlockDefs/Misc.py
===================================================================
--- grc/branches/jblum_work/src/SignalBlockDefs/Misc.py 2007-06-05 04:53:19 UTC
(rev 5681)
+++ grc/branches/jblum_work/src/SignalBlockDefs/Misc.py 2007-06-05 06:32:30 UTC
(rev 5682)
@@ -36,7 +36,7 @@
sb.add_param('Type', type, False, type=True)
sb.add_param('Sampling Rate', Float(default_samp_rate))
sb.add_param('Vector Length', vlen)
- sb.set_docs('''Connect a throttle to control the flow rate of data.''')
+ sb.set_docs('''Connect a throttle to control the actual rate of the
data.''')
return sb, lambda fg, type, samp_rate, vlen:
fcn(type.parse().get_num_bytes()*vlen.parse(), samp_rate.parse())
def Head(sb):
@@ -48,7 +48,7 @@
sb.add_param('Type', type, False, type=True)
sb.add_param('Num Items', Int(1000, min=0))
sb.add_param('Vector Length', vlen)
- sb.set_docs('''Copies the first num items to the output then signals
done.''')
+ sb.set_docs('''Copies the first num items to the output then stops.''')
return sb, lambda fg, type, num_items, vlen:
fcn(type.parse().get_num_bytes()*vlen.parse(), num_items.parse())
def SkipHead(sb):
@@ -85,81 +85,3 @@
def Note(sb):
sb.add_param('Note', String(''))
return sb, lambda *args: None
-
-#######################################################################################
-## Selector Def and Selector Class
-#######################################################################################
-
-class selector_handler:
- """ This selector handler class replaces an signal block,
- and instead, manages connections between its inputs and outputs.
- The selector handler will only allow one input and output to be
connected.
- The inputs and outputs are registered in the selector handler
when the flow graph is constructed.
- The input and output are set via access methods and can be
changed at runtime.
- Invalid connection indexes cause a complete disconnection.
"""
-
- meta_block = True #attribute to tell the flow graph app that this
is not a real block
-
- def __init__(self, fg, input_index=-1, output_index=-1):
- """ Create data structures to hold input/output blocks.
- Store initial input index and output index. """
- self.fg = fg
- self.inputs = dict()
- self.outputs = dict() #map indexes to a (signal block, socket
index)
- self.current_connection = None
- self.input_index = self.output_index = -1
- self.set_input_index(input_index)
- self.set_output_index(output_index)
-
- def set_input_index(self, input_index):
- """ Set the input index. """
- self.input_index = input_index
- self._update_connections()
-
- def set_output_index(self, output_index):
- """ Set the output index. """
- self.output_index = output_index
- self._update_connections()
-
- def register_input(self, input_index, signal_block, socket_index):
- """ Store the block,index tuple in the inputs dict. """
- self.inputs[input_index] = (signal_block, socket_index)
- self._update_connections()
-
- def register_output(self, output_index, signal_block, socket_index):
- """ Store the block,index tuple in the outputs dict.
"""
- self.outputs[output_index] = (signal_block, socket_index)
- self._update_connections()
-
- def _update_connections(self):
- """ Disconnect the current connection and then try to connect
the blocks at the input/output index. """
- if self.current_connection != None:
- self.fg.disconnect(*self.current_connection)
- self.current_connection = None
- if self.inputs.has_key(self.input_index) and
self.outputs.has_key(self.output_index):
- self.current_connection =
self.outputs[self.output_index], self.inputs[self.input_index]
- self.fg.connect(*self.current_connection)
-
-def Selector(sb):
- type = Enum(all_choices, 1)
- vlen = Int(1, min=1)
- sb.add_input_socket('in', Variable(type), vlen=vlen)
- sb.add_output_socket('out', Variable(type), vlen=vlen)
- sb.add_param('Type', type, False, type=True)
- sb.add_param('Num Inputs', Int(1, min=1, max=MAX_NUM_SOCKETS),
- show_label=False,
input_sockets_controller=True)
- sb.add_param('Num Outputs', Int(1, min=1, max=MAX_NUM_SOCKETS),
- show_label=False,
output_sockets_controller=True)
- sb.add_param('Vector Length', vlen)
- sb.add_param('Input Index', Int(-1))
- sb.add_param('Output Index', Int(-1))
- sb.set_docs('''\
-Selector Block is not implemented! Do not use.
-1 <= Num Inputs/Outputs <= %d'''%MAX_NUM_SOCKETS)
- def make(fg, type, num_inputs, num_outputs, vlen, input_index,
output_index):
- sh = selector_handler(fg, input_index.parse(),
output_index.parse())
- fg.add_callback(sh.set_input_index, input_index)
- fg.add_callback(sh.set_output_index, output_index)
- return sh
- return sb, make
-
\ No newline at end of file
Modified: grc/branches/jblum_work/src/SignalBlockDefs/SignalBlockTree.py
===================================================================
--- grc/branches/jblum_work/src/SignalBlockDefs/SignalBlockTree.py
2007-06-05 04:53:19 UTC (rev 5681)
+++ grc/branches/jblum_work/src/SignalBlockDefs/SignalBlockTree.py
2007-06-05 06:32:30 UTC (rev 5682)
@@ -165,7 +165,7 @@
('BCJR Algorithm Combined with Metric',
Trellis.Soft_In_Soft_Out_Combined),
('Interleaver', Trellis.Interleaver),
('Deinterleaver', Trellis.Deinterleaver),
- ]),
+ ]),
('Misc', [
('Throttle', Misc.Throttle),
('Head', Misc.Head),
@@ -173,7 +173,6 @@
('RMS', Misc.RMS),
('About', Misc.About),
('Note', Misc.Note),
- ('Selector', Misc.Selector),
]),
]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5682 - in grc/branches/jblum_work/src: . Elements Graphics SignalBlockDefs,
jblum <=