summaryrefslogtreecommitdiff
path: root/grc
diff options
context:
space:
mode:
authorJosh Blum2009-10-12 12:16:12 -0700
committerJosh Blum2009-10-12 12:16:12 -0700
commit5b74bb4d34f381fa8a8af1e1d96ea2d673a8be71 (patch)
treead6a9f64e3b610d008b0fb612772efd4162a82aa /grc
parent57e810d3f07909947a9fb2daeb507b439d5f4f50 (diff)
parent38d5389f3054164a2f04d6e4e8fe381aa5ee03fc (diff)
downloadgnuradio-5b74bb4d34f381fa8a8af1e1d96ea2d673a8be71.tar.gz
gnuradio-5b74bb4d34f381fa8a8af1e1d96ea2d673a8be71.tar.bz2
gnuradio-5b74bb4d34f381fa8a8af1e1d96ea2d673a8be71.zip
Merge commit '38d5389f3054164a2f04d6e4e8fe381aa5ee03fc' into vrt
Diffstat (limited to 'grc')
-rw-r--r--grc/base/Block.py24
-rw-r--r--grc/base/FlowGraph.py1
-rw-r--r--grc/blocks/Makefile.am1
-rw-r--r--grc/blocks/block_tree.xml1
-rw-r--r--grc/blocks/gr_copy.xml67
-rw-r--r--grc/blocks/gr_kludge_copy.xml11
-rw-r--r--grc/blocks/gr_nop.xml9
-rw-r--r--grc/blocks/options.xml29
-rw-r--r--grc/gui/PropsDialog.py11
-rw-r--r--grc/python/flow_graph.tmpl5
-rw-r--r--grc/todo.txt2
11 files changed, 138 insertions, 23 deletions
diff --git a/grc/base/Block.py b/grc/base/Block.py
index cb21c3958..b2015cc40 100644
--- a/grc/base/Block.py
+++ b/grc/base/Block.py
@@ -233,12 +233,22 @@ class Block(Element):
"""
Import this block's params from nested data.
Any param keys that do not exist will be ignored.
+ Since params can be dynamically created based another param,
+ call rewrite, and repeat the load until the params stick.
+ This call to rewrite will also create any dynamic ports
+ that are needed for the connections creation phase.
@param n the nested data odict
"""
- params_n = n.findall('param')
- for param_n in params_n:
- key = param_n.find('key')
- value = param_n.find('value')
- #the key must exist in this block's params
- if key in self.get_param_keys():
- self.get_param(key).set_value(value)
+ get_hash = lambda: hash(tuple(map(hash, self.get_params())))
+ my_hash = 0
+ while get_hash() != my_hash:
+ params_n = n.findall('param')
+ for param_n in params_n:
+ key = param_n.find('key')
+ value = param_n.find('value')
+ #the key must exist in this block's params
+ if key in self.get_param_keys():
+ self.get_param(key).set_value(value)
+ #store hash and call rewrite
+ my_hash = get_hash()
+ self.rewrite()
diff --git a/grc/base/FlowGraph.py b/grc/base/FlowGraph.py
index ce370ca24..7c51ef42a 100644
--- a/grc/base/FlowGraph.py
+++ b/grc/base/FlowGraph.py
@@ -184,7 +184,6 @@ class FlowGraph(Element):
#only load the block when the block key was valid
if block: block.import_data(block_n)
else: Messages.send_error_load('Block key "%s" not found in %s'%(key, self.get_parent()))
- self.rewrite() #rewrite all blocks before connections are made (ex: nports)
#build the connections
for connection_n in connections_n:
#try to make the connection
diff --git a/grc/blocks/Makefile.am b/grc/blocks/Makefile.am
index 617a3bf60..df3479761 100644
--- a/grc/blocks/Makefile.am
+++ b/grc/blocks/Makefile.am
@@ -84,6 +84,7 @@ dist_ourdata_DATA = \
gr_complex_to_real.xml \
gr_conjugate_cc.xml \
gr_constellation_decoder_cb.xml \
+ gr_copy.xml \
gr_correlate_access_code_bb.xml \
gr_costas_loop_cc.xml \
gr_cpfsk_bc.xml \
diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml
index 296f0ee91..6fec0be67 100644
--- a/grc/blocks/block_tree.xml
+++ b/grc/blocks/block_tree.xml
@@ -300,6 +300,7 @@
<block>gr_skiphead</block>
<block>gr_kludge_copy</block>
+ <block>gr_copy</block>
<block>gr_nop</block>
<block>xmlrpc_server</block>
diff --git a/grc/blocks/gr_copy.xml b/grc/blocks/gr_copy.xml
new file mode 100644
index 000000000..757f14303
--- /dev/null
+++ b/grc/blocks/gr_copy.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Copy
+###################################################
+ -->
+<block>
+ <name>Copy</name>
+ <key>gr_copy</key>
+ <import>from gnuradio import gr</import>
+ <make>gr.copy($type.size*$vlen)
+self.$(id).set_enabled($enabled)</make>
+ <callback>set_enabled($enabled)</callback>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Enabled</name>
+ <key>enabled</key>
+ <value>True</value>
+ <type>bool</type>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </source>
+</block>
diff --git a/grc/blocks/gr_kludge_copy.xml b/grc/blocks/gr_kludge_copy.xml
index 3c817c572..8058b082d 100644
--- a/grc/blocks/gr_kludge_copy.xml
+++ b/grc/blocks/gr_kludge_copy.xml
@@ -5,7 +5,7 @@
###################################################
-->
<block>
- <name>Copy</name>
+ <name>Kludge Copy</name>
<key>gr_kludge_copy</key>
<import>from gnuradio import gr</import>
<make>gr.kludge_copy($type.size*$vlen)</make>
@@ -40,20 +40,29 @@
</option>
</param>
<param>
+ <name>Num Ports</name>
+ <key>num_ports</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <param>
<name>Vec Length</name>
<key>vlen</key>
<value>1</value>
<type>int</type>
</param>
+ <check>$num_ports &gt; 0</check>
<check>$vlen &gt; 0</check>
<sink>
<name>in</name>
<type>$type</type>
<vlen>$vlen</vlen>
+ <nports>$num_ports</nports>
</sink>
<source>
<name>out</name>
<type>$type</type>
<vlen>$vlen</vlen>
+ <nports>$num_ports</nports>
</source>
</block>
diff --git a/grc/blocks/gr_nop.xml b/grc/blocks/gr_nop.xml
index 127a78a55..bd884d6b8 100644
--- a/grc/blocks/gr_nop.xml
+++ b/grc/blocks/gr_nop.xml
@@ -40,20 +40,29 @@
</option>
</param>
<param>
+ <name>Num Ports</name>
+ <key>num_ports</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <param>
<name>Vec Length</name>
<key>vlen</key>
<value>1</value>
<type>int</type>
</param>
+ <check>$num_ports &gt; 0</check>
<check>$vlen &gt; 0</check>
<sink>
<name>in</name>
<type>$type</type>
<vlen>$vlen</vlen>
+ <nports>$num_ports</nports>
</sink>
<source>
<name>out</name>
<type>$type</type>
<vlen>$vlen</vlen>
+ <nports>$num_ports</nports>
</source>
</block>
diff --git a/grc/blocks/options.xml b/grc/blocks/options.xml
index 1798a69f8..4d0dd2899 100644
--- a/grc/blocks/options.xml
+++ b/grc/blocks/options.xml
@@ -78,19 +78,36 @@ else: self.stop(); self.wait()</callback>
<hide>#if $generate_options() == 'hb' then 'none' else 'all'#</hide>
</param>
<param>
+ <name>Run Options</name>
+ <key>run_options</key>
+ <value>prompt</value>
+ <type>enum</type>
+ <hide>#if $generate_options() == 'no_gui' then 'none' else 'all'#</hide>
+ <option>
+ <name>Run to Completion</name>
+ <key>run</key>
+ </option>
+ <option>
+ <name>Prompt for Exit</name>
+ <key>prompt</key>
+ </option>
+ </param>
+ <param>
<name>Run</name>
<key>run</key>
<value>True</value>
<type>bool</type>
- <hide>#if $generate_options() == 'wx_gui'
- #if str($run) == 'True'
-part#slurp
+ <hide>
+#if $generate_options() == 'wx_gui'
+ #if $run()
+ part
#else
-none#slurp
+ none
#end if
#else
-all#slurp
-#end if</hide>
+ all
+#end if
+ </hide>
<option>
<name>Autostart</name>
<key>True</key>
diff --git a/grc/gui/PropsDialog.py b/grc/gui/PropsDialog.py
index a7822b228..cc84fd088 100644
--- a/grc/gui/PropsDialog.py
+++ b/grc/gui/PropsDialog.py
@@ -93,15 +93,14 @@ class PropsDialog(gtk.Dialog):
Ex: Added, removed, type change, hide change...
To the props dialog, the hide setting of 'none' and 'part' are identical.
Therfore, the props dialog only cares if the hide setting is/not 'all'.
- Make a hash that uniquely represents the params state.
+ Make a hash that uniquely represents the params' state.
@return true if changed
"""
old_hash = self._hash
- self._hash = 0
- for param in self._block.get_params():
- self._hash ^= hash(param)
- self._hash ^= hash(param.get_type())
- self._hash ^= hash(param.get_hide() == 'all')
+ #create a tuple of things from each param that affects the params box
+ self._hash = hash(tuple([(
+ hash(param), param.get_type(), param.get_hide() == 'all',
+ ) for param in self._block.get_params()]))
return self._hash != old_hash
def _handle_changed(self, *args):
diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl
index dce4037d5..31d99a61c 100644
--- a/grc/python/flow_graph.tmpl
+++ b/grc/python/flow_graph.tmpl
@@ -233,9 +233,14 @@ if __name__ == '__main__':
#if $generate_options == 'wx_gui'
tb.Run($flow_graph.get_option('run'))
#elif $generate_options == 'no_gui'
+ #set $run_options = $flow_graph.get_option('run_options')
+ #if $run_options == 'prompt'
tb.start()
raw_input('Press Enter to quit: ')
tb.stop()
+ #elif $run_options == 'run'
+ tb.run()
+ #end if
#end if
#end if
diff --git a/grc/todo.txt b/grc/todo.txt
index 7fa68e523..b4e3af39d 100644
--- a/grc/todo.txt
+++ b/grc/todo.txt
@@ -69,8 +69,6 @@
* threads dont die on exit in probe and variable sink
* align param titles in properties dialog
* weird grid params misbehaving
-* the block's import data does not handle variable params
- * call rewrite after load, if new params appear, try load again...
##################################################
# Future