[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r7954 - in grc/branches/grc_reloaded: notes src/grc/el
From: |
jblum |
Subject: |
[Commit-gnuradio] r7954 - in grc/branches/grc_reloaded: notes src/grc/elements src/grc/platforms/gnuradio_python src/grc/platforms/gnuradio_python/blocks src/grc/platforms/gnuradio_python/blocks/graphical_sinks src/grc/platforms/gnuradio_python/blocks/operators src/grc/platforms/gnuradio_python/blocks/sources src/grc/platforms/gnuradio_python/blocks/variables |
Date: |
Thu, 6 Mar 2008 21:23:17 -0700 (MST) |
Author: jblum
Date: 2008-03-06 21:23:16 -0700 (Thu, 06 Mar 2008)
New Revision: 7954
Modified:
grc/branches/grc_reloaded/notes/todo.txt
grc/branches/grc_reloaded/src/grc/elements/Block.py
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Block.py
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Generator.py
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Port.py
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/graphical_sinks/wxgui_fftsink2.xml
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/graphical_sinks/wxgui_scopesink2.xml
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_add_const_vxx.xml
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_add_vxx.xml
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_and_xx.xml
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_multiply_const_vxx.xml
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_multiply_vxx.xml
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_not_xx.xml
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_or_xx.xml
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_xor_xx.xml
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/options.xml
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/sources/gr_sig_source_x.xml
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_button.xml
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_chooser.xml
Log:
switched dependency strings to use cheetah templates
Modified: grc/branches/grc_reloaded/notes/todo.txt
===================================================================
--- grc/branches/grc_reloaded/notes/todo.txt 2008-03-06 21:54:11 UTC (rev
7953)
+++ grc/branches/grc_reloaded/notes/todo.txt 2008-03-07 04:23:16 UTC (rev
7954)
@@ -1,7 +1,6 @@
############ GRC Reloaded: #############
generate button next to execute
dtd for saved flow graphs
-pid file in generator
############ Blocks to Add: ####################
-ofdm (blks2)
@@ -36,7 +35,6 @@
############ Uninteresting Features: ####################
-add the concept of a current working directory
-auto param to usrp diagnose dialog
--use popen3 once it works in cygwin
############ Get GTK Stock IDs: ####################
gtk.stock_list_ids()
Modified: grc/branches/grc_reloaded/src/grc/elements/Block.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/elements/Block.py 2008-03-06 21:54:11 UTC
(rev 7953)
+++ grc/branches/grc_reloaded/src/grc/elements/Block.py 2008-03-07 04:23:16 UTC
(rev 7954)
@@ -26,6 +26,31 @@
from grc.elements.Param import Param
from grc.elements.Port import Port
+from Cheetah.Template import Template
+from UserDict import UserDict
+
+class TemplateArg(UserDict):
+ """
+ A cheetah template argument created from a param.
+ The str of this class evaluates to the param's to code method.
+ The use of this class as a dictionary (enum only) will reveal the enum
opts.
+ The eval method can return the param evaluated to a raw python data
type.
+ """
+
+ def __init__(self, param):
+ UserDict.__init__(self)
+ self._param = param
+ if param.is_enum():
+ for key in param.get_opt_keys():
+ self[key] = str(param.get_opt(key))
+
+ def __str__(self):
+ return str(self._param.to_code())
+
+ def eval(self):
+ return self._param.evaluate()
+
+
class Block(Element):
def __init__(self, flow_graph, n):
@@ -106,7 +131,7 @@
for msg in c.get_error_messages():
self._add_error_message('%s: %s'%(c,
msg))
for check in self._checks:
- check_res = self.resolve_dependencies(check,
to_code=True)
+ check_res = self.resolve_dependencies(check)
try:
check_eval =
self.get_parent().evaluate(check_res)
try: assert(check_eval)
@@ -148,30 +173,17 @@
def get_source(self, key): return self._sources[key]
def get_sources(self): return self._sources.values()
- def resolve_dependencies(self, string, to_code=False):
+ def resolve_dependencies(self, tmpl):
"""
- Resolve a paramater dependency.
- Dependencies are simple strings.
- A dependency begining with $ is evaluated by extracting the
value from the matching param.
- Without the $, dependencies are evaluated as is.
- Dependencies are specified as $param_key where param_key is an
existing parameter.
- For enumerated parameters, dependencies are $param_key:opt_key
where opt_key is an existing opt key.
- @param string the string with dependencies
- @param to_code true if to_code method should be used
+ Resolve a paramater dependency with cheetah templates.
+ @param tmpl the string with dependencies
@return the resolved value
"""
- for param in self.get_params():
- #replace all $param_key:opt_key for enums
- if param.is_enum():
- for key in param.get_opt_keys():
- find = '$'+param.get_key()+':'+key
- replace = param.get_opt(key)
- string = string.replace(find, replace)
- #replace all $param_key for all params
- find = '$'+param.get_key()
- replace = to_code and param.to_code() or
param.get_value()
- string = string.replace(find, replace)
- return string
+ tmpl = str(tmpl)
+ if '$' not in tmpl: return tmpl
+ n = dict((p.get_key(), TemplateArg(p)) for p in
self.get_params())
+ try: return str(Template(tmpl, n))
+ except Exception, e: return "-------->\n%s: %s\n<--------"%(e,
tmpl)
##############################################
## Import/Export Methods
Modified: grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Block.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Block.py
2008-03-06 21:54:11 UTC (rev 7953)
+++ grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Block.py
2008-03-07 04:23:16 UTC (rev 7954)
@@ -93,8 +93,8 @@
def get_imports(self): return self._imports
- def get_make(self): return self.resolve_dependencies(self._make,
to_code=True)
+ def get_make(self): return self.resolve_dependencies(self._make)
def get_callbacks(self):
- return map(lambda c: self.get_id() + '.' +
self.resolve_dependencies(c, to_code=True), self._callbacks)
+ return map(lambda c: self.get_id() + '.' +
self.resolve_dependencies(c), self._callbacks)
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Generator.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Generator.py
2008-03-06 21:54:11 UTC (rev 7953)
+++ grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Generator.py
2008-03-07 04:23:16 UTC (rev 7954)
@@ -66,6 +66,7 @@
all_blocks = self._flow_graph.get_blocks()
#get imports
imports = list()
+ imports.append('from gnuradio import gr')
for block in all_blocks: imports.extend(block.get_imports())
for block in filter(lambda b: b.get_key() == 'import',
all_blocks):
imports.append(block.get_make())
Modified: grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Port.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Port.py
2008-03-06 21:54:11 UTC (rev 7953)
+++ grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Port.py
2008-03-07 04:23:16 UTC (rev 7954)
@@ -51,13 +51,13 @@
def test(self):
_Port.test(self)
- if self.get_nports():
- try: assert(int(self.get_key()) == 0)
- except (AssertionError,ValueError):
self._exit_with_error('Port key must be "0" when nports is specified.')
- try:
- if self.is_sink():
assert(len(self.get_parent().get_sinks()) == 1)
- elif self.is_source():
assert(len(self.get_parent().get_sources()) == 1)
- except AssertionError: self._exit_with_error('Other
ports not allowed when nports is specified.')
+ #if self.get_nports():
+ # try: assert(int(self.get_key()) == 0)
+ # except (AssertionError,ValueError):
self._exit_with_error('Port key must be "0" when nports is specified.')
+ # try:
+ # if self.is_sink():
assert(len(self.get_parent().get_sinks()) == 1)
+ # elif self.is_source():
assert(len(self.get_parent().get_sources()) == 1)
+ # except AssertionError: self._exit_with_error('Other
ports not allowed when nports is specified.')
def get_vlen(self):
"""
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/graphical_sinks/wxgui_fftsink2.xml
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/graphical_sinks/wxgui_fftsink2.xml
2008-03-06 21:54:11 UTC (rev 7953)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/graphical_sinks/wxgui_fftsink2.xml
2008-03-07 04:23:16 UTC (rev 7954)
@@ -9,7 +9,7 @@
<name>FFT Sink</name>
<key>wxgui_fftsink2</key>
<import>from gnuradio.wxgui import fftsink2</import>
- <make>fftsink2.$type:fcn(
+ <make>fftsink2.$(type.fcn)(
_frame,
baseband_freq=$baseband_freq,
y_per_div=$y_per_div,
@@ -18,10 +18,14 @@
sample_rate=$samp_rate,
fft_size=$fft_size,
fft_rate=$fft_rate,
- average=$options:average,
+ average=$options.average,
+#if $avg_alpha.eval == 0
+ avg_alpha=None,
+#else
avg_alpha=$avg_alpha,
+#end if
title=$title,
- peak_hold=$options:peak_hold,
+ peak_hold=$options.peak_hold,
)</make>
<param>
<name>Type</name>
@@ -90,7 +94,7 @@
<param>
<name>Average Alpha</name>
<key>avg_alpha</key>
- <value>2.0/15</value>
+ <value>0</value>
<type>real</type>
</param>
<param>
@@ -135,6 +139,8 @@
<nports>$num_inputs</nports>
</sink>
<doc>
+Set Average Alpha to 0 for automatic setting.
+
Use the Grid Position (row, column, row span, column span) to position the
graphical element in the window.
</doc>
</block>
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/graphical_sinks/wxgui_scopesink2.xml
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/graphical_sinks/wxgui_scopesink2.xml
2008-03-06 21:54:11 UTC (rev 7953)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/graphical_sinks/wxgui_scopesink2.xml
2008-03-07 04:23:16 UTC (rev 7954)
@@ -9,12 +9,16 @@
<name>Scope Sink</name>
<key>wxgui_scopesink2</key>
<import>from gnuradio.wxgui import scopesink2</import>
- <make>scopesink2.$type:fcn(
+ <make>scopesink2.$(type.fcn)(
_frame,
title=$title,
sample_rate=$samp_rate,
frame_decim=$frame_decim,
+#if $v_scale.eval == 0
+ v_scale=None,
+#else
v_scale=$v_scale,
+#end if
t_scale=$t_scale,
num_inputs=$num_inputs,
)</make>
@@ -56,7 +60,7 @@
<param>
<name>V Scale</name>
<key>v_scale</key>
- <value>1000</value>
+ <value>0</value>
<type>real</type>
</param>
<param>
@@ -83,6 +87,8 @@
<nports>$num_inputs</nports>
</sink>
<doc>
+Set the V Scale to 0 for the scope to auto-scale.
+
Use the Grid Position (row, column, row span, column span) to position the
graphical element in the window.
</doc>
</block>
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_add_const_vxx.xml
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_add_const_vxx.xml
2008-03-06 21:54:11 UTC (rev 7953)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_add_const_vxx.xml
2008-03-07 04:23:16 UTC (rev 7954)
@@ -10,7 +10,7 @@
<name>Add Const</name>
<key>gr_add_const_vxx</key>
<import>from gnuradio import gr</import>
- <make>$type:fcn($const)</make>
+ <make>$(type.fcn)($const)</make>
<callback>set_k($const)</callback>
<param>
<name>Constant</name>
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_add_vxx.xml
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_add_vxx.xml
2008-03-06 21:54:11 UTC (rev 7953)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_add_vxx.xml
2008-03-07 04:23:16 UTC (rev 7954)
@@ -10,7 +10,7 @@
<name>Add</name>
<key>gr_add_vxx</key>
<import>from gnuradio import gr</import>
- <make>$type:fcn($vlen)</make>
+ <make>$(type.fcn)($vlen)</make>
<param>
<name>Num Inputs</name>
<key>num_inputs</key>
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_and_xx.xml
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_and_xx.xml
2008-03-06 21:54:11 UTC (rev 7953)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_and_xx.xml
2008-03-07 04:23:16 UTC (rev 7954)
@@ -9,7 +9,7 @@
<name>And</name>
<key>gr_and_xx</key>
<import>from gnuradio import gr</import>
- <make>$type:fcn()</make>
+ <make>$(type.fcn)()</make>
<param>
<name>IO Type</name>
<key>type</key>
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_multiply_const_vxx.xml
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_multiply_const_vxx.xml
2008-03-06 21:54:11 UTC (rev 7953)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_multiply_const_vxx.xml
2008-03-07 04:23:16 UTC (rev 7954)
@@ -10,7 +10,7 @@
<name>Multiply Const</name>
<key>gr_multiply_const_vxx</key>
<import>from gnuradio import gr</import>
- <make>$type:fcn($const)</make>
+ <make>$(type.fcn)($const)</make>
<callback>set_k($const)</callback>
<param>
<name>Constant</name>
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_multiply_vxx.xml
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_multiply_vxx.xml
2008-03-06 21:54:11 UTC (rev 7953)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_multiply_vxx.xml
2008-03-07 04:23:16 UTC (rev 7954)
@@ -10,7 +10,7 @@
<name>Multiply</name>
<key>gr_multiply_vxx</key>
<import>from gnuradio import gr</import>
- <make>$type:fcn($vlen)</make>
+ <make>$(type.fcn)($vlen)</make>
<param>
<name>Num Inputs</name>
<key>num_inputs</key>
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_not_xx.xml
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_not_xx.xml
2008-03-06 21:54:11 UTC (rev 7953)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_not_xx.xml
2008-03-07 04:23:16 UTC (rev 7954)
@@ -9,7 +9,7 @@
<name>Not</name>
<key>gr_not_xx</key>
<import>from gnuradio import gr</import>
- <make>$type:fcn()</make>
+ <make>$(type.fcn)()</make>
<param>
<name>IO Type</name>
<key>type</key>
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_or_xx.xml
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_or_xx.xml
2008-03-06 21:54:11 UTC (rev 7953)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_or_xx.xml
2008-03-07 04:23:16 UTC (rev 7954)
@@ -9,7 +9,7 @@
<name>Or</name>
<key>gr_or_xx</key>
<import>from gnuradio import gr</import>
- <make>$type:fcn()</make>
+ <make>$(type.fcn)()</make>
<param>
<name>IO Type</name>
<key>type</key>
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_xor_xx.xml
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_xor_xx.xml
2008-03-06 21:54:11 UTC (rev 7953)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/operators/gr_xor_xx.xml
2008-03-07 04:23:16 UTC (rev 7954)
@@ -2,14 +2,14 @@
<!DOCTYPE block SYSTEM "../block.dtd">
<!--
###################################################
-##Logical Xxor Block
+##Logical Xor Block
###################################################
-->
<block>
<name>Xor</name>
<key>gr_xor_xx</key>
<import>from gnuradio impxort gr</import>
- <make>$type:fcn()</make>
+ <make>$(type.fcn)()</make>
<param>
<name>IO Type</name>
<key>type</key>
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/options.xml
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/options.xml
2008-03-06 21:54:11 UTC (rev 7953)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/options.xml
2008-03-07 04:23:16 UTC (rev 7954)
@@ -43,9 +43,9 @@
<key>no_gui</key>
</option>
</param>
- <check>len(($window_size)) == 2</check>
- <check>400 <= $window_size[0] <= 2048</check>
- <check>300 <= $window_size[1] <= 1536</check>
+ <check>len($window_size) == 2</check>
+ <check>400 <= $(window_size)[0] <= 2048</check>
+ <check>300 <= $(window_size)[1] <= 1536</check>
<doc>
The window size in (width, height) must be between (400, 300) and (2048, 1536).
</doc>
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/sources/gr_sig_source_x.xml
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/sources/gr_sig_source_x.xml
2008-03-06 21:54:11 UTC (rev 7953)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/sources/gr_sig_source_x.xml
2008-03-07 04:23:16 UTC (rev 7954)
@@ -9,7 +9,7 @@
<name>Signal Source</name>
<key>gr_sig_source_x</key>
<import>from gnuradio import gr</import>
- <make>$type:fcn($samp_rate, $waveform, $freq, $amp, $offset)</make>
+ <make>$(type.fcn)($samp_rate, $waveform, $freq, $amp, $offset)</make>
<callback>set_sampling_freq($samp_rate)</callback>
<callback>set_frequency($freq)</callback>
<callback>set_amplitude($amp)</callback>
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_button.xml
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_button.xml
2008-03-06 21:54:11 UTC (rev 7953)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_button.xml
2008-03-07 04:23:16 UTC (rev 7954)
@@ -8,7 +8,7 @@
<block>
<name>Variable Button</name>
<key>variable_button</key>
- <make>($off_value, $on_value)[$value_index:i]</make>
+ <make>$({'off': $off_value, 'on':
$on_value}[$value_index.eval()])</make>
<param>
<name>Default Value</name>
<key>value_index</key>
@@ -16,13 +16,11 @@
<type>enum</type>
<option>
<name>On</name>
- <key>on</key>
- <opt>i:1</opt>
+ <key>on</key>
</option>
<option>
<name>Off</name>
<key>off</key>
- <opt>i:0</opt>
</option>
</param>
<param>
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_chooser.xml
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_chooser.xml
2008-03-06 21:54:11 UTC (rev 7953)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_chooser.xml
2008-03-07 04:23:16 UTC (rev 7954)
@@ -8,7 +8,7 @@
<block>
<name>Variable Chooser</name>
<key>variable_chooser</key>
- <make>$choices[$value_index]</make>
+ <make>$(choices)[$value_index]</make>
<param>
<name>Value Index</name>
<key>value_index</key>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r7954 - in grc/branches/grc_reloaded: notes src/grc/elements src/grc/platforms/gnuradio_python src/grc/platforms/gnuradio_python/blocks src/grc/platforms/gnuradio_python/blocks/graphical_sinks src/grc/platforms/gnuradio_python/blocks/operators src/grc/platforms/gnuradio_python/blocks/sources src/grc/platforms/gnuradio_python/blocks/variables,
jblum <=