summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2013-02-05 21:03:38 -0500
committerTom Rondeau <trondeau@vt.edu>2013-02-06 13:03:46 -0500
commitf9d72e0a0c966322ae14be0f06658ffacefd15fd (patch)
treea0bc863191b89d0183f40391b91dd04eb03f6a47
parent5616862e0e1fcf623311f015f82040f6f0b5aacb (diff)
GRC: can get list of ControlPort monitors to start them after top_block starts.
For any GUI type (wx, qt, none), the ControlPort monitors will be started after the flowgraph is started to make sure the endpoints and blocks are created and available.
-rw-r--r--gnuradio-core/src/python/gnuradio/ctrlport/monitor.py1
-rw-r--r--grc/python/FlowGraph.py8
-rw-r--r--grc/python/Generator.py2
-rw-r--r--grc/python/flow_graph.tmpl20
4 files changed, 27 insertions, 4 deletions
diff --git a/gnuradio-core/src/python/gnuradio/ctrlport/monitor.py b/gnuradio-core/src/python/gnuradio/ctrlport/monitor.py
index 1e74a814f0..53a571a698 100644
--- a/gnuradio-core/src/python/gnuradio/ctrlport/monitor.py
+++ b/gnuradio-core/src/python/gnuradio/ctrlport/monitor.py
@@ -27,7 +27,6 @@ class monitor:
def __init__(self):
print "ControlPort Monitor running."
self.started = False
- self.start()
atexit.register(self.shutdown)
def __del__(self):
diff --git a/grc/python/FlowGraph.py b/grc/python/FlowGraph.py
index 055488b314..95cf9950a9 100644
--- a/grc/python/FlowGraph.py
+++ b/grc/python/FlowGraph.py
@@ -24,6 +24,7 @@ import re
_variable_matcher = re.compile('^(variable\w*)$')
_parameter_matcher = re.compile('^(parameter)$')
+_monitors_searcher = re.compile('(monitor)')
class FlowGraph(_FlowGraph, _GUIFlowGraph):
@@ -137,6 +138,13 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
parameters = filter(lambda b: _parameter_matcher.match(b.get_key()), self.get_enabled_blocks())
return parameters
+ def get_monitors(self):
+ """
+ Get a list of all ControlPort monitors
+ """
+ monitors = filter(lambda b: _monitors_searcher.search(b.get_key()), self.get_enabled_blocks())
+ return monitors
+
def rewrite(self):
"""
Flag the namespace to be renewed.
diff --git a/grc/python/Generator.py b/grc/python/Generator.py
index 912ce13752..77abc45281 100644
--- a/grc/python/Generator.py
+++ b/grc/python/Generator.py
@@ -107,6 +107,7 @@ Add a Misc->Throttle block to your flow graph to avoid CPU congestion.''')
imports = self._flow_graph.get_imports()
variables = self._flow_graph.get_variables()
parameters = self._flow_graph.get_parameters()
+ monitors = self._flow_graph.get_monitors()
#list of blocks not including variables and imports and parameters and disabled
def _get_block_sort_text(block):
code = block.get_make().replace(block.get_id(), ' ')
@@ -146,6 +147,7 @@ Add a Misc->Throttle block to your flow graph to avoid CPU congestion.''')
'flow_graph': self._flow_graph,
'variables': variables,
'parameters': parameters,
+ 'monitors': monitors,
'blocks': blocks,
'connections': connections,
'messages': messages,
diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl
index 78604c30c8..11e33af7fd 100644
--- a/grc/python/flow_graph.tmpl
+++ b/grc/python/flow_graph.tmpl
@@ -286,7 +286,11 @@ if __name__ == '__main__':
#if $flow_graph.get_option('max_nouts')
tb.Run($flow_graph.get_option('run'), $flow_graph.get_option('max_nouts'))
#else
- tb.Run($flow_graph.get_option('run'))
+ tb.Start($flow_graph.get_option('run'))
+ #for $m in $monitors
+ (tb.$m.get_id()).start()
+ #end for
+ tb.Wait()
#end if
#elif $generate_options == 'qt_gui'
qapp = Qt.QApplication(sys.argv)
@@ -299,6 +303,9 @@ if __name__ == '__main__':
#end if
#end if
tb.show()
+ #for $m in $monitors
+ (tb.$m.get_id()).start()
+ #end for
qapp.exec_()
tb.stop()
tb = None #to clean up Qt widgets
@@ -311,15 +318,22 @@ if __name__ == '__main__':
#else
tb.start()
#end if
+ #for $m in $monitors
+ (tb.$m.get_id()).start()
+ #end for
raw_input('Press Enter to quit: ')
tb.stop()
#elif $run_options == 'run'
#if $flow_graph.get_option('max_nouts')
- tb.run($flow_graph.get_option('max_nouts'))
+ tb.start($flow_graph.get_option('max_nouts'))
#else
- tb.run()
+ tb.start()
#end if
#end if
+ #for $m in $monitors
+ (tb.$m.get_id()).start()
+ #end for
+ tb.wait()
#end if
#end if