From f4da804ea3dde5e376e520769a93f80545670208 Mon Sep 17 00:00:00 2001
From: Jose Quaresma <tzopik@gmail.com>
Date: Thu, 3 May 2012 12:50:39 -0400
Subject: GRC: patch to allow users to specify max_noutput_items in GRC options
 block.

---
 grc/blocks/options.xml     | 17 +++++++++++++++++
 grc/python/flow_graph.tmpl | 16 ++++++++++++++++
 2 files changed, 33 insertions(+)

(limited to 'grc')

diff --git a/grc/blocks/options.xml b/grc/blocks/options.xml
index b27ea900cc..1cf0b77079 100644
--- a/grc/blocks/options.xml
+++ b/grc/blocks/options.xml
@@ -124,6 +124,19 @@ else: self.stop(); self.wait()</callback>
 			<key>False</key>
 		</option>
 	</param>
+	<param>
+		<name>Max Number of Output</name>
+		<key>max_nouts</key>
+		<value>0</value>
+		<type>int</type>
+		<hide>#if $generate_options() == 'hb'
+all#slurp
+#elif $max_nouts()
+none#slurp
+#else
+part#slurp
+#end if</hide>
+	</param>
 	<param>
 		<name>Realtime Scheduling</name>
 		<key>realtime_scheduling</key>
@@ -169,5 +182,9 @@ For example, an id of my_block will generate the file my_block.py and class my_b
 The category parameter determines the placement of the block in the block selection window. \
 The category only applies when creating hier blocks. \
 To put hier blocks into the root category, enter / for the category.
+
+The Max Number of Output is the maximum number of output items allowed for any block \
+in the flowgraph; to disable this set the max_nouts equal to 0.\
+Use this to adjust the maximum latency a flowgraph can exhibit.
 	</doc>
 </block>
diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl
index 0878be4ba3..17feb01f65 100644
--- a/grc/python/flow_graph.tmpl
+++ b/grc/python/flow_graph.tmpl
@@ -244,12 +244,20 @@ if __name__ == '__main__':
 	#end if
 	#if $generate_options == 'wx_gui'
 	tb = $(class_name)($(', '.join($params_eq_list)))
+		#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'))
+		#end if
 	#elif $generate_options == 'qt_gui'
 	qapp = Qt.QApplication(sys.argv)
 	tb = $(class_name)($(', '.join($params_eq_list)))
 	#if $flow_graph.get_option('run')
+		#if $flow_graph.get_option('max_nouts')
+	tb.start($flow_graph.get_option('max_nouts'))
+		#else
 	tb.start()
+		#end if
 	#end if
 	tb.show()
 	qapp.exec_()
@@ -258,11 +266,19 @@ if __name__ == '__main__':
 	tb = $(class_name)($(', '.join($params_eq_list)))
 		#set $run_options = $flow_graph.get_option('run_options')
 		#if $run_options == 'prompt'
+			#if $flow_graph.get_option('max_nouts')
+	tb.start($flow_graph.get_option('max_nouts'))
+			#else
 	tb.start()
+			#end if
 	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'))
+			#else
 	tb.run()
+			#end if
 		#end if
 	#end if
 #end if
-- 
cgit v1.2.3