[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5874 - in grc/branches/jblum_work: examples notes src
From: |
jblum |
Subject: |
[Commit-gnuradio] r5874 - in grc/branches/jblum_work: examples notes src src/Graphics src/SignalBlockDefs |
Date: |
Thu, 28 Jun 2007 23:03:27 -0600 (MDT) |
Author: jblum
Date: 2007-06-28 23:03:26 -0600 (Thu, 28 Jun 2007)
New Revision: 5874
Added:
grc/branches/jblum_work/notes/programming_style.txt
grc/branches/jblum_work/src/Graphics/FileDialogs.py
Removed:
grc/branches/jblum_work/src/Graphics/FlowGraphFileDialog.py
Modified:
grc/branches/jblum_work/examples/packet_mod_demod.grc.xml
grc/branches/jblum_work/examples/selector.grc.xml
grc/branches/jblum_work/notes/notes.txt
grc/branches/jblum_work/src/ActionHandler.py
grc/branches/jblum_work/src/Constants.py
grc/branches/jblum_work/src/DataTypes.py
grc/branches/jblum_work/src/Editor.py
grc/branches/jblum_work/src/ExecFlowGraph.py
grc/branches/jblum_work/src/ExecFlowGraphXMLRPC.py
grc/branches/jblum_work/src/Graphics/__init__.py
grc/branches/jblum_work/src/Preferences.py
grc/branches/jblum_work/src/SignalBlockDefs/Misc.py
Log:
code cleanup, readme, docs
Modified: grc/branches/jblum_work/examples/packet_mod_demod.grc.xml
===================================================================
--- grc/branches/jblum_work/examples/packet_mod_demod.grc.xml 2007-06-28
20:56:12 UTC (rev 5873)
+++ grc/branches/jblum_work/examples/packet_mod_demod.grc.xml 2007-06-29
05:03:26 UTC (rev 5874)
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<flow_graph>
- <timestamp>1182897586.7</timestamp>
+ <timestamp>1182980737.28</timestamp>
<hostname>tiggle</hostname>
<version>0.70 alpha</version>
<valid>True</valid>
Modified: grc/branches/jblum_work/examples/selector.grc.xml
===================================================================
--- grc/branches/jblum_work/examples/selector.grc.xml 2007-06-28 20:56:12 UTC
(rev 5873)
+++ grc/branches/jblum_work/examples/selector.grc.xml 2007-06-29 05:03:26 UTC
(rev 5874)
@@ -1,21 +1,14 @@
<?xml version='1.0' encoding='UTF-8'?>
<flow_graph>
- <timestamp>1182902366.59</timestamp>
+ <timestamp>1183066964.1</timestamp>
<hostname>tiggle</hostname>
<version>0.70 alpha</version>
<valid>True</valid>
- <window_width>1600</window_width>
- <window_height>800</window_height>
+ <window_width>1400</window_width>
+ <window_height>600</window_height>
<vars>
<var>
- <key>samp_rate_in</key>
- <value>5e3</value>
- <min/>
- <max/>
- <step/>
- </var>
- <var>
- <key>samp_rate_out</key>
+ <key>samp_rate</key>
<value>100e3</value>
<min/>
<max/>
@@ -40,8 +33,8 @@
<signal_block>
<tag>PSK Modulator</tag>
<id>PSK Modulator0</id>
- <x_coordinate>792</x_coordinate>
- <y_coordinate>342</y_coordinate>
+ <x_coordinate>500</x_coordinate>
+ <y_coordinate>341</y_coordinate>
<rotation>0</rotation>
<params>
<param>1</param>
@@ -51,24 +44,9 @@
</params>
</signal_block>
<signal_block>
- <tag>Scope Sink</tag>
- <id>Scope Sink0</id>
- <x_coordinate>14</x_coordinate>
- <y_coordinate>405</y_coordinate>
- <rotation>180</rotation>
- <params>
- <param>1</param>
- <param>Input </param>
- <param>$samp_rate_in</param>
- <param>1</param>
- <param>0</param>
- <param>0.001</param>
- </params>
- </signal_block>
- <signal_block>
<tag>GMSK Modulator</tag>
<id>GMSK Modulator0</id>
- <x_coordinate>804</x_coordinate>
+ <x_coordinate>544</x_coordinate>
<y_coordinate>58</y_coordinate>
<rotation>0</rotation>
<params>
@@ -77,52 +55,28 @@
</params>
</signal_block>
<signal_block>
- <tag>Constellation Sink</tag>
- <id>Constellation Sink0</id>
- <x_coordinate>1292</x_coordinate>
- <y_coordinate>230</y_coordinate>
- <rotation>0</rotation>
- <params>
- <param>Ouput Constellation</param>
- <param>$samp_rate_out</param>
- <param>1</param>
- <param>0</param>
- </params>
- </signal_block>
- <signal_block>
<tag>Note</tag>
<id>Note0</id>
- <x_coordinate>619</x_coordinate>
- <y_coordinate>261</y_coordinate>
+ <x_coordinate>485</x_coordinate>
+ <y_coordinate>259</y_coordinate>
<rotation>0</rotation>
<params>
<param>0=gmsk, 1=dqpsk, -1=disconnected</param>
</params>
</signal_block>
<signal_block>
- <tag>About</tag>
- <id>About0</id>
- <x_coordinate>633</x_coordinate>
- <y_coordinate>176</y_coordinate>
+ <tag>Selector</tag>
+ <id>Selector1</id>
+ <x_coordinate>924</x_coordinate>
+ <y_coordinate>330</y_coordinate>
<rotation>0</rotation>
<params>
- <param>Selecting Between Modulators</param>
- <param>Josh Blum</param>
- </params>
- </signal_block>
- <signal_block>
- <tag>Signal Source</tag>
- <id>Signal Source0</id>
- <x_coordinate>12</x_coordinate>
- <y_coordinate>11</y_coordinate>
- <rotation>0</rotation>
- <params>
+ <param>0</param>
+ <param>$index</param>
+ <param>0</param>
+ <param>2</param>
<param>1</param>
- <param>$samp_rate_in</param>
<param>1</param>
- <param>500</param>
- <param>1</param>
- <param>0</param>
</params>
</signal_block>
<signal_block>
@@ -132,7 +86,7 @@
<y_coordinate>68</y_coordinate>
<rotation>0</rotation>
<params>
- <param>1</param>
+ <param>4</param>
<param>0</param>
<param>$index</param>
<param>1</param>
@@ -141,107 +95,99 @@
</params>
</signal_block>
<signal_block>
- <tag>Packet Modulator</tag>
- <id>Packet Modulator1</id>
- <x_coordinate>524</x_coordinate>
- <y_coordinate>24</y_coordinate>
- <rotation>0</rotation>
+ <tag>Random Source</tag>
+ <id>Random Source0</id>
+ <x_coordinate>170</x_coordinate>
+ <y_coordinate>196</y_coordinate>
+ <rotation>180</rotation>
<params>
- <param>1</param>
+ <param>3</param>
+ <param>1000</param>
<param>0</param>
- <param>2</param>
- <param>$packet_len</param>
- <param/>
- <param>0</param>
<param>1</param>
+ <param>422291</param>
+ <param>0</param>
</params>
</signal_block>
<signal_block>
- <tag>Packet Modulator</tag>
- <id>Packet Modulator0</id>
- <x_coordinate>377</x_coordinate>
- <y_coordinate>325</y_coordinate>
- <rotation>0</rotation>
+ <tag>Constellation Sink</tag>
+ <id>Constellation Sink0</id>
+ <x_coordinate>886</x_coordinate>
+ <y_coordinate>114</y_coordinate>
+ <rotation>180</rotation>
<params>
+ <param>Ouput Constellation</param>
+ <param>$samp_rate</param>
<param>1</param>
- <param>2</param>
- <param>2</param>
- <param>$packet_len</param>
- <param/>
<param>0</param>
+ </params>
+ </signal_block>
+ <signal_block>
+ <tag>Throttle</tag>
+ <id>Throttle0</id>
+ <x_coordinate>5</x_coordinate>
+ <y_coordinate>150</y_coordinate>
+ <rotation>90</rotation>
+ <params>
+ <param>4</param>
+ <param>$samp_rate</param>
<param>1</param>
</params>
</signal_block>
<signal_block>
- <tag>Selector</tag>
- <id>Selector1</id>
- <x_coordinate>1072</x_coordinate>
- <y_coordinate>332</y_coordinate>
+ <tag>About</tag>
+ <id>About0</id>
+ <x_coordinate>504</x_coordinate>
+ <y_coordinate>164</y_coordinate>
<rotation>0</rotation>
<params>
- <param>0</param>
- <param>$index</param>
- <param>0</param>
- <param>2</param>
- <param>1</param>
- <param>1</param>
+ <param>Selecting Between Modulators</param>
+ <param>Josh Blum</param>
</params>
</signal_block>
</signal_blocks>
<connections>
<connection>
- <input_signal_block_id>Selector0</input_signal_block_id>
+ <input_signal_block_id>Selector1</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>GMSK Modulator0</output_signal_block_id>
<output_socket_index>0</output_socket_index>
</connection>
<connection>
- <input_signal_block_id>Packet Modulator0</input_signal_block_id>
- <input_socket_index>0</input_socket_index>
- <output_signal_block_id>Selector0</output_signal_block_id>
- <output_socket_index>1</output_socket_index>
+ <input_signal_block_id>Selector1</input_signal_block_id>
+ <input_socket_index>1</input_socket_index>
+ <output_signal_block_id>PSK Modulator0</output_signal_block_id>
+ <output_socket_index>0</output_socket_index>
</connection>
<connection>
- <input_signal_block_id>Packet Modulator1</input_signal_block_id>
+ <input_signal_block_id>Constellation Sink0</input_signal_block_id>
<input_socket_index>0</input_socket_index>
- <output_signal_block_id>Selector0</output_signal_block_id>
+ <output_signal_block_id>Selector1</output_signal_block_id>
<output_socket_index>0</output_socket_index>
</connection>
<connection>
<input_signal_block_id>GMSK Modulator0</input_signal_block_id>
<input_socket_index>0</input_socket_index>
- <output_signal_block_id>Packet Modulator1</output_signal_block_id>
+ <output_signal_block_id>Selector0</output_signal_block_id>
<output_socket_index>0</output_socket_index>
</connection>
<connection>
<input_signal_block_id>PSK Modulator0</input_signal_block_id>
<input_socket_index>0</input_socket_index>
- <output_signal_block_id>Packet Modulator0</output_signal_block_id>
- <output_socket_index>0</output_socket_index>
+ <output_signal_block_id>Selector0</output_signal_block_id>
+ <output_socket_index>1</output_socket_index>
</connection>
<connection>
- <input_signal_block_id>Selector1</input_signal_block_id>
+ <input_signal_block_id>Throttle0</input_signal_block_id>
<input_socket_index>0</input_socket_index>
- <output_signal_block_id>GMSK Modulator0</output_signal_block_id>
+ <output_signal_block_id>Random Source0</output_signal_block_id>
<output_socket_index>0</output_socket_index>
</connection>
<connection>
- <input_signal_block_id>Selector1</input_signal_block_id>
- <input_socket_index>1</input_socket_index>
- <output_signal_block_id>PSK Modulator0</output_signal_block_id>
- <output_socket_index>0</output_socket_index>
- </connection>
- <connection>
- <input_signal_block_id>Constellation Sink0</input_signal_block_id>
+ <input_signal_block_id>Selector0</input_signal_block_id>
<input_socket_index>0</input_socket_index>
- <output_signal_block_id>Selector1</output_signal_block_id>
+ <output_signal_block_id>Throttle0</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_socket_index>0</output_socket_index>
- </connection>
</connections>
</flow_graph>
Modified: grc/branches/jblum_work/notes/notes.txt
===================================================================
--- grc/branches/jblum_work/notes/notes.txt 2007-06-28 20:56:12 UTC (rev
5873)
+++ grc/branches/jblum_work/notes/notes.txt 2007-06-29 05:03:26 UTC (rev
5874)
@@ -10,7 +10,6 @@
-file save, ask for overwrite even when appending file extension
-blocks need to fix themselves when they go out of bounds, like in a resize
-socket controllers should be intelligent on shrinkage
--the nested data variables should indicate that they are nested data ->
variable_data
############ Features to Add: ####################
-startup tips
Added: grc/branches/jblum_work/notes/programming_style.txt
===================================================================
--- grc/branches/jblum_work/notes/programming_style.txt
(rev 0)
+++ grc/branches/jblum_work/notes/programming_style.txt 2007-06-29 05:03:26 UTC
(rev 5874)
@@ -0,0 +1,27 @@
+Programming Style
+
+1) Indentation:
+ Python dependends on correct indentation levels.
+ A tab character equals a single indentation level.
+ Most editors can display a tab as a user-defined width or number of
spaces.
+ The expand command can convert a file with tab indentations to a file
with space indentation.
+
+2) Naming Conventions:
+ CamelCaseNames for files and classes.
+ UPPER_CASE_NAMES for constants.
+ lower_case_names for public methods and all variables.
+ _underscored_lower_case_names for private methods.
+
+3) Documentation:
+ Source code follows the doxygen/javadoc conventions (and will be parsed
by doxygen).
+ Files begin with a ##comment block, a package name, brief description,
and author.
+ Constants follow a ##comment line.
+ All methods and classes require docstrings.
+ Docstrings with javadoc style entries need a leading "!".
+
+4) Blank Lines:
+ Separate all classes and methods with a blank line.
+ Group related constants and separate unrelated constants with a blank
line.
+ Leave 2 blank lines at the end of every file.
+
+
\ No newline at end of file
Modified: grc/branches/jblum_work/src/ActionHandler.py
===================================================================
--- grc/branches/jblum_work/src/ActionHandler.py 2007-06-28 20:56:12 UTC
(rev 5873)
+++ grc/branches/jblum_work/src/ActionHandler.py 2007-06-29 05:03:26 UTC
(rev 5874)
@@ -60,6 +60,7 @@
# determine the initial flow graph file, preference to
command line input #
if input_arg_file_path: self.flow_graph_file_path =
os.path.abspath(input_arg_file_path)
else: self.flow_graph_file_path =
Preferences.get_default_flow_graph()
+ self.saved = True
self.handle_states(APPLICATION_INITIALIZE)
# enter the mainloop
gtk.gdk.threads_init()
@@ -155,10 +156,11 @@
for action in ACTIONS_LIST: action.set_sensitive(False)
#set all actions disabled
# enable a select few actions
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_SCREEN_CAPTURE):
- get_action_from_name(action).set_sensitive(True)
+ 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_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))
self.flow_graph.from_nested_data(initial_state)
@@ -175,7 +177,7 @@
Messages.send_fail_load(e)
self.flow_graph_file_path = ''
self.handle_states(APPLICATION_INITIALIZE)
- self._set_saved_state(True)
+ self.saved = True
elif state == APPLICATION_QUIT:
if self._loose_changes():
self.handle_states(FLOW_GRAPH_STOP)
@@ -201,40 +203,40 @@
##############################################################################################
elif state == SIGNAL_BLOCK_MOVE:
self.state_cache.save_new_state(self.flow_graph.to_nested_data())
- self._set_saved_state(False)
+ self.saved = False
elif state == SIGNAL_BLOCK_ROTATE_LEFT:
if self.flow_graph.rotate_selected(DIR_LEFT):
self.state_cache.save_new_state(self.flow_graph.to_nested_data())
- self._set_saved_state(False)
+ self.saved = False
elif state == SIGNAL_BLOCK_ROTATE_RIGHT:
if self.flow_graph.rotate_selected(DIR_RIGHT):
self.state_cache.save_new_state(self.flow_graph.to_nested_data())
- self._set_saved_state(False)
+ self.saved = False
elif state == ELEMENT_DELETE:
if self.flow_graph.delete_selected():
self.state_cache.save_new_state(self.flow_graph.to_nested_data())
self.handle_states(NOTHING_SELECT)
- self._set_saved_state(False)
+ self.saved = False
elif state == CONNECTION_CREATE or state ==
SIGNAL_BLOCK_CREATE:
self.state_cache.save_new_state(self.flow_graph.to_nested_data())
self.handle_states(NOTHING_SELECT)
- self._set_saved_state(False)
+ self.saved = False
elif state == SIGNAL_BLOCK_INC_TYPE:
if self.flow_graph.type_controller_modify_selected(1):
self.state_cache.save_new_state(self.flow_graph.to_nested_data())
- self._set_saved_state(False)
+ self.saved = False
elif state == SIGNAL_BLOCK_DEC_TYPE:
if self.flow_graph.type_controller_modify_selected(-1):
self.state_cache.save_new_state(self.flow_graph.to_nested_data())
- self._set_saved_state(False)
+ self.saved = False
elif state == SOCKET_CONTROLLER_INC:
if self.flow_graph.socket_controller_modify_selected(1):
self.state_cache.save_new_state(self.flow_graph.to_nested_data())
- self._set_saved_state(False)
+ self.saved = False
elif state == SOCKET_CONTROLLER_DEC:
if
self.flow_graph.socket_controller_modify_selected(-1):
self.state_cache.save_new_state(self.flow_graph.to_nested_data())
- self._set_saved_state(False)
+ self.saved = False
##############################################################################################
# Window stuff
##############################################################################################
@@ -256,21 +258,21 @@
if dimensions != None:
self.flow_graph.set_size_request(dimensions[0],
dimensions[1])
self.state_cache.save_new_state(self.flow_graph.to_nested_data())
- self._set_saved_state(False)
+ self.saved = False
##############################################################################################
# Variable and Param Modifications
##############################################################################################
elif state == SIGNAL_BLOCK_PARAM_MODIFY:
if self.flow_graph.param_modify_selected():
self.state_cache.save_new_state(self.flow_graph.to_nested_data())
- self._set_saved_state(False)
+ self.saved = False
elif state == VARIABLE_MODIFY:
self.state_cache.save_new_state(self.flow_graph.to_nested_data())
- self._set_saved_state(False)
+ self.saved = False
self.flow_graph.update()
elif state == VARIABLE_REORDER:
self.state_cache.save_new_state(self.flow_graph.to_nested_data())
- self._set_saved_state(False)
+ self.saved = False
##############################################################################################
# Undo/Redo
##############################################################################################
@@ -279,13 +281,13 @@
if nested_data != None:
self.handle_states(NOTHING_SELECT)
self.flow_graph.from_nested_data(nested_data)
- self._set_saved_state(False)
+ self.saved = False
elif state == FLOW_GRAPH_REDO:
nested_data = self.state_cache.get_next_state()
if nested_data != None:
self.handle_states(NOTHING_SELECT)
self.flow_graph.from_nested_data(nested_data)
- self._set_saved_state(False)
+ self.saved = False
##############################################################################################
# New/Open/Save
##############################################################################################
@@ -294,9 +296,8 @@
self.flow_graph_file_path = ''
self.handle_states(APPLICATION_INITIALIZE)
elif state == FLOW_GRAPH_OPEN:
- if self._loose_changes():
- fc = Graphics.FlowGraphFileDialog('open',
self.flow_graph_file_path)
- file_path = fc.run()
+ if self._loose_changes():
+ file_path =
Graphics.OpenFlowGraphFileDialog(self.flow_graph_file_path).run()
if file_path != None:
self.flow_graph_file_path = file_path
self.handle_states(APPLICATION_INITIALIZE)
@@ -305,19 +306,17 @@
else:
try:
ParseXML.to_file(ParseXML.to_xml(self.flow_graph.to_nested_data()),
self.flow_graph_file_path)
- self._set_saved_state(True)
+ self.saved = True
except IOError:
Messages.send_fail_save(self.flow_graph_file_path)
- self._set_saved_state(False)
+ self.saved = False
elif state == FLOW_GRAPH_SAVE_AS:
- fc = Graphics.FlowGraphFileDialog('save',
self.flow_graph_file_path)
- file_path = fc.run()
+ file_path =
Graphics.SaveFlowGraphFileDialog(self.flow_graph_file_path).run()
if file_path != None:
self.flow_graph_file_path = file_path
self.handle_states(FLOW_GRAPH_SAVE)
elif state == FLOW_GRAPH_SCREEN_CAPTURE:
- fc = Graphics.FlowGraphFileDialog('save image',
self.flow_graph_file_path)
- file_path = fc.run()
+ file_path =
Graphics.SaveImageFileDialog(self.flow_graph_file_path).run()
if file_path != None:
pixmap = self.flow_graph.pixmap
width, height = pixmap.get_size()
@@ -338,32 +337,24 @@
except: print "could not kill pid file:
%s"%self.pid_file
MUTEX.unlock()
else: print "!!! State not handled !!!"
- # set the exec 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
MUTEX.lock()
-
get_action_from_name(FLOW_GRAPH_EXEC).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)
+
get_action_from_name(FLOW_GRAPH_STOP).set_sensitive(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())
-
- def _set_saved_state(self, saved):
- """!
- Update GUI elements based on the saved state of the flow graph.
- If saved is true, the flow graph was just saved:
- set the window title and grey out the save button.
- If saved is false, the flow graph has unsaved changes:
- set the window title with a * and activate the save
button.
- @param saved true when saved
- """
- if saved:
+ #saved status
+ if self.saved: #set the window title and grey out the save
button
get_action_from_name(FLOW_GRAPH_SAVE).set_sensitive(False)
if self.flow_graph_file_path == '':
self.main_window.set_title(NEW_FLOGRAPH_TITLE)
else:
self.main_window.set_title(self.flow_graph_file_path)
- else:
+ else: #set the window title with a * and activate the save
button
get_action_from_name(FLOW_GRAPH_SAVE).set_sensitive(True)
if self.flow_graph_file_path == '':
self.main_window.set_title(NEW_FLOGRAPH_TITLE +
'*')
- else:
self.main_window.set_title(self.flow_graph_file_path + '*')
+ else:
self.main_window.set_title(self.flow_graph_file_path + '*')
+ #hide/show the reports window based on the preferences
+ Preferences.show_reports_window(self.main_window)
def _loose_changes(self):
"""!
@@ -371,8 +362,7 @@
If the save was not greyed-out, the user is presented with a
dialog.
@return true if save is greyed-out, or the user's choice.
"""
- return not
get_action_from_name(FLOW_GRAPH_SAVE).get_sensitive() or\
- (Graphics.LooseChangesMessage().run())
+ return not
get_action_from_name(FLOW_GRAPH_SAVE).get_sensitive() or
Graphics.LooseChangesMessage().run()
class ExecFlowGraphThread(Thread):
"""Execute the flow graph as a new process and wait on it to finish."""
Modified: grc/branches/jblum_work/src/Constants.py
===================================================================
--- grc/branches/jblum_work/src/Constants.py 2007-06-28 20:56:12 UTC (rev
5873)
+++ grc/branches/jblum_work/src/Constants.py 2007-06-29 05:03:26 UTC (rev
5874)
@@ -173,8 +173,8 @@
##The setting for a blank flow graph.
INITIAL_FLOW_GRAPH_FILE =
os.path.abspath(DATA_DIR+'/initial_flow_graph.grc.xml')
-##The default file extension for file open and save dialogs.
-DEFAULT_FILE_EXTENSION = '.grc.xml'
+##The default file extension for flow graphs.
+FLOW_GRAPH_FILE_EXTENSION = '.grc.xml'
##The default file extension for saving flow graph snap shots.
IMAGE_FILE_EXTENSION = '.png'
@@ -182,8 +182,10 @@
##The default path for the open/save dialogs.
DEFAULT_FILE_PATH = os.path.expanduser('~')+'/'
-##The default icon for all windows.
+##The default icon for the gtk windows.
PY_GTK_ICON = os.path.abspath(DATA_DIR+'/grc-icon-256.png')
+
+##The default icon for the wx windows.
WX_APP_ICON = os.path.abspath(DATA_DIR+'/grc-icon-32.png')
#>>> platform dependency! wx under cygwin has issues with icon paths #
if sys.platform == 'cygwin': WX_APP_ICON = None
Modified: grc/branches/jblum_work/src/DataTypes.py
===================================================================
--- grc/branches/jblum_work/src/DataTypes.py 2007-06-28 20:56:12 UTC (rev
5873)
+++ grc/branches/jblum_work/src/DataTypes.py 2007-06-29 05:03:26 UTC (rev
5874)
@@ -31,6 +31,7 @@
Do not use, this is a base class only.
"""
base_type = None
+
def __init__(self, data='0', min=None, max=None):
"""!
DataType constructor.
@@ -43,6 +44,7 @@
self.min = min
##parser messages
self.msg = ''
+
def __str__(self):
"""!
Get the string representation of this data type.
@@ -50,23 +52,27 @@
@return the string representation.
"""
return self.msg
+
def set_data(self, data):
"""!
Store the data as a string.
@param data the data
"""
self.data = str(data)
+
def get_data(self):
"""!
Get the data as a string.
@return the data """
return self.data
+
def parse(self):
"""!
Substitute in variables.
Replace all variable instances with the variable's string
representation.
@return the data without variables"""
return Variables.replace_var_instances(self.get_data())
+
def is_valid(self):
"""!
Is this data type valid?
@@ -84,24 +90,28 @@
except Exception, e:
self.msg = str(e)
return False
+
def get_type(self):
"""!
Get a string describing the specific data type.
@return type string
"""
return self.type
+
def get_base_type(self):
"""!
Get a string describing the base (category) of this data type.
@return base type string
"""
return self.base_type
+
def get_num_bytes(self):
"""!
How man bytes in this data type?
@return number of bytes
"""
return self.num_bytes
+
def _verify_bounds(self, value):
"""!
Is the value within the bounds of this data type?
@@ -120,6 +130,7 @@
Do not use, this is a base class only.
"""
base_type = 'number'
+
def parse(self):
"""!
Evaluate the math expressions in the data type.
@@ -134,6 +145,7 @@
"""The integer data type."""
type = 'int'
num_bytes = gr.sizeof_int
+
def parser(self, value):
"""!
Parse the data for an integer value or raise an error.
@@ -156,6 +168,7 @@
"""The float data type."""
type = 'float'
num_bytes = gr.sizeof_float
+
def parser(self, value):
"""!
Parse the data for an float value or raise an error.
@@ -168,6 +181,7 @@
"""The complex data type."""
type = 'complex'
num_bytes = gr.sizeof_gr_complex
+
def parser(self, value):
"""!
Parse the data for an complex value or raise an error.
@@ -182,12 +196,14 @@
class RawExpr(DataType):
"""A raw mathematical expression."""
type = 'raw'
+
def __init__(self, data=''):
"""!
Raw data type contructor.
@param data the data
"""
DataType.__init__(self, data)
+
def parse(self):
"""!
Get the raw data returned by the math parser.
@@ -200,6 +216,7 @@
class String(DataType):
"""The string data type."""
type = 'string'
+
def __init__(self, data='', min=None, max=None):
"""!
String data type contructor.
@@ -208,6 +225,7 @@
@param max the maximum length of the string
"""
DataType.__init__(self, data, min, max)
+
def parse(self):
"""!
Get the data as a string.
@@ -221,6 +239,7 @@
class Hex(DataType):
"""The hex data type."""
type = 'hex'
+
def parse(self):
"""!
Get the data as an integer parsed from a hex string.
@@ -231,6 +250,7 @@
class File(String):
"""A file data type. Do not use, this is a base class only."""
base_type = 'file'
+
def __init__(self, data='', allow_blank=False):
"""!
File data type contructor.
@@ -244,6 +264,7 @@
class FileOpen(File):
"""A file data type for choosing existing files."""
type = 'fileopen'
+
def is_valid(self):
"""!
Does the file path exist?
@@ -256,6 +277,7 @@
class FileSave(File):
"""A file data type for choosing files to save."""
type = 'filesave'
+
def is_valid(self):
"""!
Is the file path possible?
@@ -275,6 +297,7 @@
The variable data type.
Takes properties from an enumerated data type of data types.
"""
+
def __init__(self, enum_data_type, data='0', index=None, min=None,
max=None):
"""!
Variable constructor.
@@ -290,6 +313,7 @@
DataType.__init__(self, data, min, max)
self.enum_data_type = enum_data_type
self.index = index
+
def _parse_enum_data_type(self):
"""!
Parse the selected data type.
@@ -298,24 +322,28 @@
"""
if self.index is None: return self.enum_data_type.parse()
else: return self.enum_data_type.parse()[self.index]
+
def get_type(self):
"""!
Get the type from the enumerated data type.
@return the type
"""
return self._parse_enum_data_type().get_type()
+
def get_base_type(self):
"""!
Get the base type from the enumerated data type.
@return the base type
"""
return self._parse_enum_data_type().get_base_type()
+
def get_num_bytes(self):
"""!
Get the number of bytes from the enumerated data type.
@return the number of bytes.
"""
return self._parse_enum_data_type().get_num_bytes()
+
def parse(self):
"""!
Use the parser from the enumerated data type.
@@ -332,6 +360,7 @@
The data must represent an integer index. """
type = 'enum'
base_type = 'enum'
+
def __init__(self, choices=[('',0)], data='0'):
"""!
Enum constructor.
@@ -340,7 +369,8 @@
@param data the choice index 0-> len(choices)-1
"""
self.choices = choices
- DataType.__init__(self, data)
+ DataType.__init__(self, data)
+
def set_data(self, data):
"""!
Set the data.
@@ -350,18 +380,21 @@
"""
self.choices[int(data)]
DataType.set_data(self, data)
+
def parse(self):
"""!
Parse the data by returning the current selection pointed to by
the data.
@return the choice at the index held in data
"""
return self.choices[int(self.get_data())][1]
+
def get_cname(self):
"""!
Get the cannonical name of the currently selected choice.
@return the cannonical name
"""
return self.choices[int(self.get_data())][0]
+
def get_cnames_list(self):
"""!
Get a list of the cannonical names from the choices (in order).
@@ -378,6 +411,7 @@
"""
type = 'variable enum'
base_type = 'variable enum'
+
def __init__(self, data='', all_variables=False):
"""!
Variable key selector contructor.
@@ -387,19 +421,22 @@
@param all_variables boolean to allow certain variables
"""
DataType.__init__(self, data)
- self.all_variables = all_variables
+ self.all_variables = all_variables
+
def parse(self):
"""!
Parse the data by returning the current key.
@return the var key
"""
return self.get_data().strip()
+
def is_valid(self):
"""!
Is the variable key valid?
The data must be in the keys list.
@return true if valid"""
return self.parse() in self.get_variables_list()
+
def get_variables_list(self):
"""!
Get a list of the keys.
@@ -418,6 +455,7 @@
This boolean type is an Enum with two choices.
One choice will parse to True, the other False. """
type = 'bool'
+
def __init__(self, true='True', false='False', default=True):
"""!
Bool contructor.
@@ -439,6 +477,7 @@
Do not use, this is a base class only.
"""
base_type = 'vector'
+
def parse(self):
"""!
Parse the vector data type.
@@ -495,7 +534,7 @@
Int().get_type() : IntVector(),
Float().get_type() : FloatVector(),
Complex().get_type() : ComplexVector(),
- }
+ }
if type in regular_to_vector_dict.keys():
return regular_to_vector_dict[type]
return data_type #otherwise return the input data type
Modified: grc/branches/jblum_work/src/Editor.py
===================================================================
--- grc/branches/jblum_work/src/Editor.py 2007-06-28 20:56:12 UTC (rev
5873)
+++ grc/branches/jblum_work/src/Editor.py 2007-06-29 05:03:26 UTC (rev
5874)
@@ -21,11 +21,11 @@
#Execute the flow graph editor GUI. This file must be called by the python
interpreter.
address@hidden Josh Blum
-from Constants import VERSION,DEFAULT_FILE_EXTENSION
+from Constants import VERSION,FLOW_GRAPH_FILE_EXTENSION
from optparse import OptionParser
if __name__ == "__main__":
- usage = "usage: %prog optional_flow_graph"+DEFAULT_FILE_EXTENSION
+ usage = "usage: %prog optional_flow_graph"+FLOW_GRAPH_FILE_EXTENSION
version = """
GNU Radio Companion %s
@@ -37,17 +37,11 @@
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
- import gnuradio.gr.hier_block2
- except ImportError, e: #print error and exit
- print '\nMissing critical component: "%s"\nExiting!'%(e,)
- exit(-1)
+ for module in ('pygtk', 'gtk', 'wx', 'numpy', 'xml.dom.minidom',
'xml.dom.ext', 'gnuradio', 'gnuradio.gr.hier_block2'):
+ try: __import__(module)
+ except ImportError: #print error and exit
+ print '\nMissing critical module:
"%s"\nExiting!\n'%module
+ exit(-1)
# end import of modules #
from ActionHandler import ActionHandler
if len(args): ActionHandler(args[0])
Modified: grc/branches/jblum_work/src/ExecFlowGraph.py
===================================================================
--- grc/branches/jblum_work/src/ExecFlowGraph.py 2007-06-28 20:56:12 UTC
(rev 5873)
+++ grc/branches/jblum_work/src/ExecFlowGraph.py 2007-06-29 05:03:26 UTC
(rev 5874)
@@ -26,7 +26,7 @@
from Elements import SignalBlock
from gnuradio import gr
import os
-from Constants import DEFAULT_FILE_EXTENSION,MUTEX
+from Constants import FLOW_GRAPH_FILE_EXTENSION,MUTEX
from optparse import OptionParser
##############################################################################################
@@ -129,7 +129,7 @@
and ensures that a flow graph is passed on the command line."""
def __init__(self):
"""Create the base option parser and add usage and basic
options."""
- usage = "usage: %prog [options]
flow_graph"+DEFAULT_FILE_EXTENSION
+ usage = "usage: %prog [options]
flow_graph"+FLOW_GRAPH_FILE_EXTENSION
OptionParser.__init__(self, usage=usage)
self.add_option("-p", "--pid_file", action="store",
type="string", dest="pid_file", help="record process id")
Modified: grc/branches/jblum_work/src/ExecFlowGraphXMLRPC.py
===================================================================
--- grc/branches/jblum_work/src/ExecFlowGraphXMLRPC.py 2007-06-28 20:56:12 UTC
(rev 5873)
+++ grc/branches/jblum_work/src/ExecFlowGraphXMLRPC.py 2007-06-29 05:03:26 UTC
(rev 5874)
@@ -44,18 +44,24 @@
# Flow Graph Access
##############################################################################################
class FlowGraphAccess(FlowGraphBuilder):
- """ Implement a flow graph builder,
- and provide access functions for the xmlrpc server. """
+ """Implement a flow graph builder, and provide access functions for the
xmlrpc server."""
def get_var_range(self, key):
- """ Return the min and the max of a variable (strings). """
+ """!
+ Get the min and the max of a variable (strings).
+ @return the min,max tuple
+ """
value, min, max, step = Variables.get_values(key)
return str(min), str(max)
def set_var(self, key, new_value):
- """ Value can be any type (will be cast to a string below).
- Register the new value and call parse callbacks.
- Return the new value as a string. """
+ """!
+ Register the new value and call parse callbacks.
+ Value can be any type (will be cast to a string).
+ @param key the variable key
+ @param new_value the new value for the variable
+ @return the new value as a string or the old value if failed
+ """
try:
if Variables.reregister(key, new_value):
self.parse_callbacks()
except: pass
Copied: grc/branches/jblum_work/src/Graphics/FileDialogs.py (from rev 5826,
grc/branches/jblum_work/src/Graphics/FlowGraphFileDialog.py)
===================================================================
--- grc/branches/jblum_work/src/Graphics/FileDialogs.py
(rev 0)
+++ grc/branches/jblum_work/src/Graphics/FileDialogs.py 2007-06-29 05:03:26 UTC
(rev 5874)
@@ -0,0 +1,107 @@
+"""
+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
+"""
address@hidden Graphics.FileDialogs
+#The open/save dialog for flow graph fFileDialogiles and screen shots.
address@hidden Josh Blum
+
+import pygtk
+pygtk.require('2.0')
+import gtk
+from Constants import
DEFAULT_FILE_PATH,FLOW_GRAPH_FILE_EXTENSION,IMAGE_FILE_EXTENSION,NEW_FLOGRAPH_TITLE
+from os import path
+
+OPEN_FLOW_GRAPH = 'open flow graph'
+SAVE_FLOW_GRAPH = 'save flow graph'
+SAVE_IMAGE = 'save image'
+
+class FileDialog(gtk.FileChooserDialog):
+ """A dialog box to save or open flow graph files. This is a base class,
do not use."""
+
+ ##the filter for flow graph files
+ flow_graph_files_filter = gtk.FileFilter()
+ flow_graph_files_filter.set_name('FG Files')
+ flow_graph_files_filter.add_pattern('*'+FLOW_GRAPH_FILE_EXTENSION)
+
+ ##the filter for image files
+ image_files_filter = gtk.FileFilter()
+ image_files_filter.set_name('Image Files')
+ image_files_filter.add_pattern('*'+IMAGE_FILE_EXTENSION)
+ #image_files_filter.add_pixbuf_formats()
+
+ ##the filter for all files
+ all_files_filter = gtk.FileFilter()
+ all_files_filter.set_name('All Files')
+ all_files_filter.add_pattern('*')
+
+ def __init__(self, current_file_path):
+ """!
+ FileDialog constructor.
+ Create a new gtk.FileChooserDialog, type specifies what filter
to use:
+ open and save are for flow graphs, save image is for
screenshots.
+ @param current_file_path the current directory
+ """
+ if current_file_path == '': current_file_path =
DEFAULT_FILE_PATH+NEW_FLOGRAPH_TITLE+FLOW_GRAPH_FILE_EXTENSION
+ if self.type == OPEN_FLOW_GRAPH:
+ gtk.FileChooserDialog.__init__(self, 'Open a Flow Graph
from a File...', None,
+ gtk.FILE_CHOOSER_ACTION_OPEN,
('gtk-cancel',gtk.RESPONSE_CANCEL,'gtk-open',gtk.RESPONSE_OK))
+ self.add_filter(self.flow_graph_files_filter)
+ self.set_filter(self.flow_graph_files_filter)
+ self.add_filter(self.all_files_filter)
+ elif self.type == SAVE_FLOW_GRAPH:
+ gtk.FileChooserDialog.__init__(self, 'Save a Flow Graph
to a File...', None,
+ gtk.FILE_CHOOSER_ACTION_SAVE,
('gtk-cancel',gtk.RESPONSE_CANCEL, 'gtk-save',gtk.RESPONSE_OK))
+ #self.set_do_overwrite_confirmation(True) #enable this
when u get it working with auto-extension
+ self.add_filter(self.flow_graph_files_filter)
+ self.set_filter(self.flow_graph_files_filter)
+ self.add_filter(self.all_files_filter)
+ self.set_current_name(path.basename(current_file_path))
#show the current filename
+ elif self.type == SAVE_IMAGE:
+ gtk.FileChooserDialog.__init__(self, 'Save a Flow Graph
Screen Shot...', None,
+ gtk.FILE_CHOOSER_ACTION_SAVE,
('gtk-cancel',gtk.RESPONSE_CANCEL, 'gtk-save',gtk.RESPONSE_OK))
+ #self.set_do_overwrite_confirmation(True) #enable this
when u get it working with auto-extension
+ self.add_filter(self.image_files_filter)
+ self.set_filter(self.image_files_filter)
+ self.add_filter(self.all_files_filter)
+ current_file_path = current_file_path +
IMAGE_FILE_EXTENSION
+ self.set_current_name(path.basename(current_file_path))
#show the current filename
+ self.set_current_folder(path.dirname(current_file_path))
#current directory
+ #self.set_show_hidden(False) #doesnt seem to work ;-)
+ self.set_select_multiple(False)
+ self.set_local_only(True)
+
+ def run(self):
+ """!
+ Call run, wait for user response, and destroy the dialog.
+ @return the filename or None if a close/cancel occured.
+ """
+ response = gtk.FileChooserDialog.run(self)
+ if response == gtk.RESPONSE_OK:
+ filename = self.get_filename()
+ if
filename[len(filename)-len(FLOW_GRAPH_FILE_EXTENSION):] !=
FLOW_GRAPH_FILE_EXTENSION and\
+ self.flow_graph_files_filter ==
self.get_filter(): filename = filename + FLOW_GRAPH_FILE_EXTENSION
+ elif filename[len(filename)-len(IMAGE_FILE_EXTENSION):]
!= IMAGE_FILE_EXTENSION and\
+ self.image_files_filter == self.get_filter():
filename = filename + IMAGE_FILE_EXTENSION
+ else: filename = None
+ self.destroy()
+ return filename
+
+class OpenFlowGraphFileDialog(FileDialog): type = OPEN_FLOW_GRAPH
+class SaveFlowGraphFileDialog(FileDialog): type = SAVE_FLOW_GRAPH
+class SaveImageFileDialog(FileDialog): type = SAVE_IMAGE
+
Deleted: grc/branches/jblum_work/src/Graphics/FlowGraphFileDialog.py
Modified: grc/branches/jblum_work/src/Graphics/__init__.py
===================================================================
--- grc/branches/jblum_work/src/Graphics/__init__.py 2007-06-28 20:56:12 UTC
(rev 5873)
+++ grc/branches/jblum_work/src/Graphics/__init__.py 2007-06-29 05:03:26 UTC
(rev 5874)
@@ -22,6 +22,6 @@
# only import the modules that need external access #
from MainWindow import MainWindow
-from FlowGraphFileDialog import FlowGraphFileDialog
+from FileDialogs import
OpenFlowGraphFileDialog,SaveFlowGraphFileDialog,SaveImageFileDialog
from Dialogs import
PreferencesDialog,FlowGraphWindowSizeDialog,LooseChangesMessage,AboutDialog,DataTypeColorsDialog,HotKeysDialog,MathExprDialog
from USRPDiagnostics import USRPDiagnosticsDialog,enable_usrp_diagnostics
Modified: grc/branches/jblum_work/src/Preferences.py
===================================================================
--- grc/branches/jblum_work/src/Preferences.py 2007-06-28 20:56:12 UTC (rev
5873)
+++ grc/branches/jblum_work/src/Preferences.py 2007-06-29 05:03:26 UTC (rev
5874)
@@ -176,8 +176,8 @@
def check_params():
return _get_value(PARAM_CHECKING_PREF)
-def show_reports_window():
- return _get_value(REPORTS_WIN_SHOW_PREF)
+def show_reports_window(window):
+ return window.show_reports_window(_get_value(REPORTS_WIN_SHOW_PREF))
def get_grid_size():
return _get_value(GRID_SIZE_PREF)
Modified: grc/branches/jblum_work/src/SignalBlockDefs/Misc.py
===================================================================
--- grc/branches/jblum_work/src/SignalBlockDefs/Misc.py 2007-06-28 20:56:12 UTC
(rev 5873)
+++ grc/branches/jblum_work/src/SignalBlockDefs/Misc.py 2007-06-29 05:03:26 UTC
(rev 5874)
@@ -23,7 +23,7 @@
import gnuradio.gr.gr_threading as threading
from DataTypes import *
from gnuradio import gr,blks
-from SignalBlockConstants import
default_samp_rate,all_choices,DEFAULT_QUEUE_LIMIT,ThrottleHelper,MAX_NUM_SOCKETS
+from SignalBlockConstants import default_samp_rate,all_choices,MAX_NUM_SOCKETS
def Throttle(sb):
fcn = gr.throttle
@@ -108,13 +108,11 @@
#terminator blocks for unused inputs and outputs
self.input_terminators = [gr.null_sink(item_size) for i in
range(num_inputs)]
self.output_terminators = [gr.head(item_size, 0) for i in
range(num_outputs)]
- self.copy = gr.skiphead(item_size, 0)
- self.term_copy_in = gr.head(item_size, 0)
- self.term_copy_out = gr.null_sink(item_size)
- self.connect(gr.null_source(item_size), self.term_copy_in,
self.copy, self.term_copy_out)
+ self.copy = None
#connections
for i in range(num_inputs): self.connect((self, i),
self.input_terminators[i])
for i in range(num_outputs):
self.connect(gr.null_source(item_size), self.output_terminators[i], (self, i))
+ self.item_size = item_size
self.input_index = input_index
self.output_index = output_index
self.num_inputs = num_inputs
@@ -135,12 +133,10 @@
if self._indexes_valid():
self.disconnect((self, self.input_index),
self.input_terminators[self.input_index])
self.disconnect(self.output_terminators[self.output_index], (self,
self.output_index))
- self.disconnect(self.term_copy_in, self.copy)
- self.disconnect(self.copy, self.term_copy_out)
+ self.copy = gr.skiphead(self.item_size, 0)
self.connect((self, self.input_index), self.copy)
self.connect(self.copy, (self, self.output_index))
self.connect(self.output_terminators[self.output_index],
self.input_terminators[self.input_index])
- self.connect(self.term_copy_in, self.term_copy_out)
def _disconnect_current(self):
"""If the input and output indexes are valid:
@@ -151,11 +147,10 @@
self.disconnect((self, self.input_index), self.copy)
self.disconnect(self.copy, (self, self.output_index))
self.disconnect(self.output_terminators[self.output_index],
self.input_terminators[self.input_index])
- self.disconnect(self.term_copy_in, self.term_copy_out)
+ del self.copy
+ self.copy = None
self.connect((self, self.input_index),
self.input_terminators[self.input_index])
self.connect(self.output_terminators[self.output_index], (self,
self.output_index))
- self.connect(self.term_copy_in, self.copy)
- self.connect(self.copy, self.term_copy_out)
def set_input_index(self, input_index):
"""!
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5874 - in grc/branches/jblum_work: examples notes src src/Graphics src/SignalBlockDefs,
jblum <=