commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r7616 - in grc/branches/grc_reloaded/src/grc: elements


From: jblum
Subject: [Commit-gnuradio] r7616 - in grc/branches/grc_reloaded/src/grc: elements platforms/gnuradio_python platforms/gnuradio_python/blocks platforms/gnuradio_python/blocks/variables
Date: Fri, 8 Feb 2008 16:18:57 -0700 (MST)

Author: jblum
Date: 2008-02-08 16:18:57 -0700 (Fri, 08 Feb 2008)
New Revision: 7616

Added:
   
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/options.xml
   
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_drop_down.xml
Removed:
   grc/branches/grc_reloaded/src/grc/elements/DataType.py
   grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/DataType.py
   
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_enum.xml
Modified:
   grc/branches/grc_reloaded/src/grc/elements/FlowGraph.py
   grc/branches/grc_reloaded/src/grc/elements/Param.py
   grc/branches/grc_reloaded/src/grc/elements/Platform.py
   grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/FlowGraph.py
   
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable.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_slider.xml
Log:
options block, param evaluations

Deleted: grc/branches/grc_reloaded/src/grc/elements/DataType.py

Modified: grc/branches/grc_reloaded/src/grc/elements/FlowGraph.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/elements/FlowGraph.py     2008-02-08 
22:42:07 UTC (rev 7615)
+++ grc/branches/grc_reloaded/src/grc/elements/FlowGraph.py     2008-02-08 
23:18:57 UTC (rev 7616)
@@ -31,37 +31,34 @@
        def __init__(self, platform):
                """!
                Make a flow graph from the arguments.
-               @param platforms a list of platforms to load
+               @param platform a platforms with blocks and contrcutors
                @return the flow graph object
                """
                Element.__init__(self, platform)
-               #load the platform modules
-               #self._platforms = odict()
-               #for key in platforms:
-               #       try: 
-               #               platform_module = __import__(
-               #                       'grc.platforms', 
-               #                       globals=globals(), 
-               #                       locals=locals(),
-               #                       fromlist=[key],
-               #                       level=-1,
-               #               )
-               #               platform = getattr(platform_module, 
key).get_platform()
-               #               self._platforms[platform.get_key()] = platform
-               #       except ImportError, e: self._exit_with_error('Error 
importing platform "%s": "%s"'%(key, e))
+               self._file_path = ''
+               self._options_block = self.get_parent().get_new_block(self, 
'options')
+               self._options_block.get_param('id').set_value('options')
+               
+       def __str__(self): return 'FlowGraph: "%s"' + self.get_option('name')
        
-       def __str__(self): return 'FlowGraph: '
+       def get_option(self, key):
+               """!
+               Get the option for a given key.
+               The option comes from the special options block.
+               @param key the param key for the options block
+               @return the value held by that param
+               """
+               self._options_block.get_param(key).get_value()
        
        def is_flow_graph(self): return True
        
        def evaluate(self, expr):
-               """
+               """!
                Evaluate the expression.
                @param expr the string expression
-               @throw Exception bad expression
-               @return the evaluated data
+               @throw NotImplementedError
                """
-               return eval(expr, {}, {})               
+               raise NotImplementedError       
        
        def validate(self):
                """
@@ -69,6 +66,12 @@
                All connections and blocks must be valid.
                """
                #TODO
+               
+       ##############################################
+       ## Access file_path
+       ##############################################  
+       def get_file_path(self): return self._file_path
+       def set_file_path(self, file_path): self._file_path = file_path 
        
        ##############################################
        ## Import/Export Methods

Modified: grc/branches/grc_reloaded/src/grc/elements/Param.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/elements/Param.py 2008-02-08 22:42:07 UTC 
(rev 7615)
+++ grc/branches/grc_reloaded/src/grc/elements/Param.py 2008-02-08 23:18:57 UTC 
(rev 7616)
@@ -142,10 +142,18 @@
                Validate the param.
                The value must be evaluated and type must a possible type.
                """
-               try: self.evaluate()
-               except: self._add_error_message('Value "%s" cannot be 
evaluated.'%self.get_value())
-               try: assert(self.get_type() in self.TYPES)
-               except AssertionError: self._add_error_message('Type "%s" is 
not a possible type.'%type)                
+               try: 
+                       assert(self.get_type() in self.TYPES)
+                       try: self.evaluate()
+                       except: self._add_error_message('Value "%s" cannot be 
evaluated.'%self.get_value())             
+               except AssertionError: self._add_error_message('Type "%s" is 
not a possible type.'%type)        
+               
+       def evaluate(self):
+               """!
+               Evaluate the value of this param.
+               @throw NotImplementedError
+               """
+               raise NotImplementedError       
        
        def __str__(self): return 'Param: %s(%s)'%(self.get_name(), 
self.get_key())
        

Modified: grc/branches/grc_reloaded/src/grc/elements/Platform.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/elements/Platform.py      2008-02-08 
22:42:07 UTC (rev 7615)
+++ grc/branches/grc_reloaded/src/grc/elements/Platform.py      2008-02-08 
23:18:57 UTC (rev 7616)
@@ -43,9 +43,11 @@
                self._name = name
                self._key = key 
                self._path = path
+               #create a dummy flow graph for the blocks
+               flow_graph = _Element(self)
                #load the blocks
-               flow_graph = self.FlowGraph(self)
                self._blocks = dict()
+               self._blocks_n = dict()
                for dirpath,dirnames,filenames in os.walk(self._path + 
'/blocks/'):
                        for filename in filter(lambda f: f.endswith('.xml'), 
filenames):
                                f = dirpath + '/' + filename
@@ -60,6 +62,7 @@
                                except AssertionError: 
self._exit_with_error('Key "%s" already exists in blocks'%key)
                                #store the block
                                self._blocks[key] = block
+                               self._blocks_n[key] = n
        
        def __str__(self): return 'Platform: %s(%s)'%(self.get_name(), 
self.get_key())
        
@@ -69,7 +72,8 @@
        # Access Blocks
        ##############################################
        def get_block_keys(self): return self._blocks.keys()
-       def get_block(self, block): return self._blocks[key]
+       def get_block(self, key): return self._blocks[key]
+       def get_new_block(self, flow_graph, key): return self.Block(flow_graph, 
n=self._blocks_n[key])
        
        def get_name(self): return self._name
        

Deleted: grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/DataType.py

Modified: 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/FlowGraph.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/FlowGraph.py    
2008-02-08 22:42:07 UTC (rev 7615)
+++ grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/FlowGraph.py    
2008-02-08 23:18:57 UTC (rev 7616)
@@ -34,18 +34,18 @@
                @return the evaluated data
                """
                #bring in gnuradio modules
-               from gnuradio import gr
                from gnuradio.gr import firdes
                import math
                import cmath
-               my_eval = lambda exp: eval(exp, {
+               my_eval = lambda exp: eval(
+                       exp, 
+                       {
                                '__builtins__': __builtins__,
-                               'gr': gr,
                                'firdes': firdes,
                                'math': math,
                                'cmath': cmath,
                                #TODO add varables here
-                       }
+                       },
                )               
                return my_eval(expr)
                

Added: 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/options.xml
===================================================================
--- 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/options.xml  
                            (rev 0)
+++ 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/options.xml  
    2008-02-08 23:18:57 UTC (rev 7616)
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<!DOCTYPE block SYSTEM "./block.dtd">
+<!-- 
+###################################################
+##Options Block:
+## options for window size, 
+## and flow graph building.
+###################################################
+ -->
+<block>
+       <name>Options</name>
+       <key>options</key>
+       <cat>Main</cat>
+       <fcn />
+       <param>
+               <name>Name</name>
+               <key>name</key>
+               <value>untitled</value>
+               <type>string</type>             
+       </param>
+       <param>
+               <name>Description</name>
+               <key>description</key>
+               <value>untitled flow graph</value>
+               <type>string</type>                     
+       </param>
+       <param>
+               <name>Window Width</name>
+               <key>window_width</key>
+               <value>800</value>
+               <type>int</type>                
+       </param>
+       <param>
+               <name>Window Height</name>
+               <key>window_height</key>
+               <value>600</value>
+               <type>int</type>
+       </param>
+       <param>
+               <name>Generate Options</name>
+               <key>generate_options</key>
+               <value>wx</value>
+               <type>enum</type>
+               <option>
+                       <name>WX GUI</name>
+                       <key>wx</key>   
+               </option>
+               <option>
+                       <name>No GUI</name>
+                       <key>no_gui</key>       
+               </option>
+       </param>        
+       <check>400 &lt;= $window_width &lt;= 1600</check>
+       <check>300 &lt;= $window_height &lt;= 1200</check>
+</block>

Modified: 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable.xml
===================================================================
--- 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable.xml
   2008-02-08 22:42:07 UTC (rev 7615)
+++ 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable.xml
   2008-02-08 23:18:57 UTC (rev 7616)
@@ -21,8 +21,8 @@
                <type>raw</type>
        </param>
        <doc>
-This block maps a value to a variable name. 
-The variable name must be unique and the value must evaluate to a python value.
+This block maps a value to a variable key. 
+The variable key must be unique and the value must evaluate to a python value.
 This variable block has no graphical representation.
 Use the variable slider, enum, or button for graphical options.
        </doc>  

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-02-08 22:42:07 UTC (rev 7615)
+++ 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_button.xml
    2008-02-08 23:18:57 UTC (rev 7616)
@@ -16,6 +16,20 @@
                <type>var_key</type>
        </param>
        <param>
+               <name>Default Value</name>      
+               <key>default_value</key>
+               <value>on</value>
+               <type>enum</type>
+               <option>
+                       <name>On</name>
+                       <key>on</key>                   
+               </option>
+               <option>
+                       <name>Off</name>
+                       <key>off</key>                  
+               </option>
+       </param>
+       <param>
                <name>Off Value</name>
                <key>off_value</key>
                <value>0</value>
@@ -27,4 +41,8 @@
                <value>1</value>
                <type>raw</type>        
        </param>
+       <doc>
+This block creates a variable with a button. 
+The variable key must be unique.
+       </doc>
 </block>

Copied: 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_drop_down.xml
 (from rev 7609, 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_enum.xml)
===================================================================
--- 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_drop_down.xml
                         (rev 0)
+++ 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_drop_down.xml
 2008-02-08 23:18:57 UTC (rev 7616)
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<!DOCTYPE block SYSTEM "../block.dtd">
+<!-- 
+###################################################
+##Variable block: a grc variable with key, value, min, max, step
+###################################################
+ -->
+<block>
+       <name>Variable Drop Down</name>
+       <key>variable_drop_down</key>
+       <cat>Variables</cat>
+       <fcn />
+       <param>
+               <name>Key</name>
+               <key>key</key>
+               <type>var_key</type>
+       </param>
+       <param>
+               <name>Default Value</name>
+               <key>default_value</key>
+               <value>0</value>
+               <type>int</type>
+       </param>
+       <param>
+               <name>Choices</name>
+               <key>choices</key>
+               <value>[val0, val1, val2...]</value>
+               <type>raw</type>
+       </param>
+       <check>len($choices) > 0</check>
+       <check>$default_value in range(0, len($choices))</check>
+       <doc>
+This block creates a variable with a drop down. 
+The variable key must be unique.
+The default value is the index of a particular choice.
+The choices must be a list of possible values.
+       </doc>
+</block>

Deleted: 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_enum.xml

Modified: 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_slider.xml
===================================================================
--- 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_slider.xml
    2008-02-08 22:42:07 UTC (rev 7615)
+++ 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_slider.xml
    2008-02-08 23:18:57 UTC (rev 7616)
@@ -35,4 +35,12 @@
                <key>step</key>
                <type>real</type>
        </param>
+       <check>$min &lt;= $value &lt;= $max</check>
+       <doc>
+This block creates a variable with a slider. 
+The variable key must be unique.
+The value must be a real number.
+The value must be between the minimum and the maximum.
+The step size must be TODO.
+       </doc>
 </block>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]