diff options
-rw-r--r-- | gr-audio/grc/audio_sink.xml | 2 | ||||
-rw-r--r-- | gr-audio/grc/audio_source.xml | 2 | ||||
-rw-r--r-- | gr-blocks/grc/blocks_throttle.xml | 2 | ||||
-rw-r--r-- | gr-blocks/grc/blocks_udp_source.xml | 2 | ||||
-rw-r--r-- | gr-fcd/grc/fcd_source_c.xml | 2 | ||||
-rw-r--r-- | gr-uhd/grc/gen_uhd_usrp_blocks.py | 2 | ||||
-rw-r--r-- | grc/base/Block.py | 18 | ||||
-rw-r--r-- | grc/base/Constants.py | 2 | ||||
-rw-r--r-- | grc/python/Block.py | 3 | ||||
-rw-r--r-- | grc/python/block.dtd | 5 |
10 files changed, 28 insertions, 12 deletions
diff --git a/gr-audio/grc/audio_sink.xml b/gr-audio/grc/audio_sink.xml index 9a70006e72..727767b72e 100644 --- a/gr-audio/grc/audio_sink.xml +++ b/gr-audio/grc/audio_sink.xml @@ -8,7 +8,7 @@ <name>Audio Sink</name> <key>audio_sink</key> <category>Audio</category> - <throttle>1</throttle> + <flags>throttle</flags> <import>from gnuradio import audio</import> <make>audio.sink($samp_rate, $device_name, $ok_to_block)</make> <param> diff --git a/gr-audio/grc/audio_source.xml b/gr-audio/grc/audio_source.xml index 0cb73a3ae9..aaa3225e8b 100644 --- a/gr-audio/grc/audio_source.xml +++ b/gr-audio/grc/audio_source.xml @@ -8,7 +8,7 @@ <name>Audio Source</name> <key>audio_source</key> <category>Audio</category> - <throttle>1</throttle> + <flags>throttle</flags> <import>from gnuradio import audio</import> <make>audio.source($samp_rate, $device_name, $ok_to_block)</make> <param> diff --git a/gr-blocks/grc/blocks_throttle.xml b/gr-blocks/grc/blocks_throttle.xml index 790e195750..26f4aa768b 100644 --- a/gr-blocks/grc/blocks_throttle.xml +++ b/gr-blocks/grc/blocks_throttle.xml @@ -7,7 +7,7 @@ <block> <name>Throttle</name> <key>blocks_throttle</key> - <throttle>1</throttle> + <flags>throttle</flags> <import>from gnuradio import blocks</import> <make>blocks.throttle($type.size*$vlen, $samples_per_second,$ignoretag)</make> <callback>set_sample_rate($samples_per_second)</callback> diff --git a/gr-blocks/grc/blocks_udp_source.xml b/gr-blocks/grc/blocks_udp_source.xml index 3b434c107e..03dbb5781b 100644 --- a/gr-blocks/grc/blocks_udp_source.xml +++ b/gr-blocks/grc/blocks_udp_source.xml @@ -7,7 +7,7 @@ <block> <name>UDP Source</name> <key>blocks_udp_source</key> - <throttle>1</throttle> + <flags>throttle</flags> <import>from gnuradio import blocks</import> <make>blocks.udp_source($type.size*$vlen, $ipaddr, $port, $psize, $eof)</make> <callback>set_mtu($mtu)</callback> diff --git a/gr-fcd/grc/fcd_source_c.xml b/gr-fcd/grc/fcd_source_c.xml index b514c6126c..01ea26d81c 100644 --- a/gr-fcd/grc/fcd_source_c.xml +++ b/gr-fcd/grc/fcd_source_c.xml @@ -3,7 +3,7 @@ <name>Funcube Dongle Source</name> <key>fcd_source_c</key> <category>FCD</category> - <throttle>1</throttle> + <flags>throttle</flags> <import>from gnuradio import fcd</import> <make>fcd.source_c($device_name) #if $lna() != 20.0 diff --git a/gr-uhd/grc/gen_uhd_usrp_blocks.py b/gr-uhd/grc/gen_uhd_usrp_blocks.py index fda1b9dfd7..72f1b50135 100644 --- a/gr-uhd/grc/gen_uhd_usrp_blocks.py +++ b/gr-uhd/grc/gen_uhd_usrp_blocks.py @@ -23,7 +23,7 @@ MAIN_TMPL = """\ <block> <name>UHD: USRP $sourk.title()</name> <key>uhd_usrp_$(sourk)</key> - <throttle>1</throttle> + <flags>throttle</flags> <import>from gnuradio import uhd</import> <import>import time</import> <make>uhd.usrp_$(sourk)( diff --git a/grc/base/Block.py b/grc/base/Block.py index b367e60e69..d2d7ebf426 100644 --- a/grc/base/Block.py +++ b/grc/base/Block.py @@ -18,13 +18,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ from . import odict -from . Constants import ADVANCED_PARAM_TAB, DEFAULT_PARAM_TAB +from . Constants import ADVANCED_PARAM_TAB, DEFAULT_PARAM_TAB, BLOCK_FLAG_THROTTLE from Element import Element from Cheetah.Template import Template from UserDict import UserDict from itertools import imap +from .. gui import Messages + + class TemplateArg(UserDict): """ A cheetah template argument created from a param. @@ -46,11 +49,16 @@ class TemplateArg(UserDict): def __call__(self): return self._param.get_evaluated() -def _get_keys(lst): return [elem.get_key() for elem in lst] + +def _get_keys(lst): + return [elem.get_key() for elem in lst] + + def _get_elem(lst, key): try: return lst[_get_keys(lst).index(key)] except ValueError: raise ValueError, 'Key "%s" not found in %s.'%(key, _get_keys(lst)) + class Block(Element): def __init__(self, flow_graph, n): @@ -73,6 +81,9 @@ class Block(Element): self._name = n.find('name') self._key = n.find('key') self._category = n.find('category') or '' + self._flags = n.find('flags') or '' + if n.find('throttle') and BLOCK_FLAG_THROTTLE not in self._flags: # backwards-compatibility + self._flags += BLOCK_FLAG_THROTTLE self._grc_source = n.find('grc_source') or '' self._block_wrapper_path = n.find('block_wrapper_path') self._bussify_sink = n.find('bus_sink') @@ -240,6 +251,9 @@ class Block(Element): def get_block_wrapper_path(self): return self._block_wrapper_path def get_comment(self): return self.get_param('comment').get_value() + def get_flags(self): return self._flags + def throttle(self): return "throttle" in self._flags + ############################################## # Access Params ############################################## diff --git a/grc/base/Constants.py b/grc/base/Constants.py index efae0ecbb5..7949708d5b 100644 --- a/grc/base/Constants.py +++ b/grc/base/Constants.py @@ -38,3 +38,5 @@ DOMAIN_DTD = os.path.join(DATA_DIR, 'domain.dtd') GR_STREAM_DOMAIN = "gr_stream" GR_MESSAGE_DOMAIN = "gr_message" DEFAULT_DOMAIN = GR_STREAM_DOMAIN + +BLOCK_FLAG_THROTTLE = 'throttle' diff --git a/grc/python/Block.py b/grc/python/Block.py index 191b03b452..5d52e2bf3c 100644 --- a/grc/python/Block.py +++ b/grc/python/Block.py @@ -52,7 +52,6 @@ class Block(_Block, _GUIBlock): self._var_make = n.find('var_make') self._checks = n.findall('check') self._callbacks = n.findall('callback') - self._throttle = n.find('throttle') or '' self._bus_structure_source = n.find('bus_structure_source') or '' self._bus_structure_sink = n.find('bus_structure_sink') or '' #build the block @@ -78,8 +77,6 @@ class Block(_Block, _GUIBlock): except: return '' - def throttle(self): return bool(self._throttle) - def validate(self): """ Validate this block. diff --git a/grc/python/block.dtd b/grc/python/block.dtd index 8cfd3dd392..145f4d8610 100644 --- a/grc/python/block.dtd +++ b/grc/python/block.dtd @@ -25,7 +25,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Top level element. A block contains a name, ...parameters list, and list of IO ports. --> -<!ELEMENT block (name, key, category?, throttle?, import*, var_make?, var_value?, make, callback*, param_tab_order?, param*, bus_sink?, bus_source?, check*, sink*, source*, bus_structure_sink?, bus_structure_source?, doc?, grc_source?)> +<!ELEMENT block (name, key, category?, throttle?, flags?, import*, var_make?, var_value?, + make, callback*, param_tab_order?, param*, bus_sink?, bus_source?, check*, + sink*, source*, bus_structure_sink?, bus_structure_source?, doc?, grc_source?)> <!-- Sub level elements. --> @@ -64,3 +66,4 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA <!ELEMENT callback (#PCDATA)> <!ELEMENT optional (#PCDATA)> <!ELEMENT throttle (#PCDATA)> +<!ELEMENT flags (#PCDATA)> |