added stream id type and checking in evaluate
authorJosh Blum <josh@joshknows.com>
Sat, 29 Aug 2009 03:57:40 +0000 (20:57 -0700)
committerJosh Blum <josh@joshknows.com>
Sat, 29 Aug 2009 03:57:40 +0000 (20:57 -0700)
grc/blocks/virtual_sink.xml
grc/blocks/virtual_source.xml
grc/python/Param.py
grc/todo.txt

index bd858522b24e64fada863380d8eacdceb9a8f715..35fb27e67cb42da76271f494a527b3cd16143091 100644 (file)
@@ -12,7 +12,7 @@
                <name>Stream ID</name>
                <key>stream_id</key>
                <value></value>
-               <type>string</type>
+               <type>stream_id</type>
        </param>
        <sink>
                <name>in</name>
index 11eb0c0fb1ea512f18009cf3d41ed20050bcc59b..e0c7754492707d2314e0f880285e7f3431824753 100644 (file)
@@ -12,7 +12,7 @@
                <name>Stream ID</name>
                <key>stream_id</key>
                <value></value>
-               <type>string</type>
+               <type>stream_id</type>
        </param>
        <source>
                <name>out</name>
index f971d0c3fb6330ca7b06d24f5863e777334d6399..49601f1687388e1dae752294348217f7d92a1cde 100644 (file)
@@ -94,7 +94,7 @@ class Param(_Param):
                'complex_vector', 'real_vector', 'int_vector',
                'hex', 'string', 'bool',
                'file_open', 'file_save',
-               'id',
+               'id', 'stream_id',
                'grid_pos', 'notebook',
                'import',
        ]
@@ -310,14 +310,31 @@ class Param(_Param):
                        #can python use this as a variable?
                        try: assert _check_id_matcher.match(v)
                        except AssertionError: raise Exception, 'ID "%s" must begin with a letter and may contain letters, numbers, and underscores.'%v
-                       params = self.get_all_params('id')
-                       keys = [param.get_value() for param in params]
-                       try: assert keys.count(v) <= 1 #id should only appear once, or zero times if block is disabled
+                       ids = [param.get_value() for param in self.get_all_params(t)]
+                       try: assert ids.count(v) <= 1 #id should only appear once, or zero times if block is disabled
                        except: raise Exception, 'ID "%s" is not unique.'%v
                        try: assert v not in ID_BLACKLIST
                        except: raise Exception, 'ID "%s" is blacklisted.'%v
                        return v
                #########################
+               # Stream ID Type
+               #########################
+               elif t == 'stream_id':
+                       #get a list of all stream ids used in the virtual sinks 
+                       ids = [param.get_value() for param in filter(
+                               lambda p: p.get_parent().get_key() == 'virtual_sink',
+                               self.get_all_params(t),
+                       )]
+                       #check that the virtual sink's stream id is unique
+                       if self.get_parent().get_key() == 'virtual_sink':
+                               try: assert ids.count(v) <= 1 #id should only appear once, or zero times if block is disabled
+                               except: raise Exception, 'Stream ID "%s" is not unique.'%v
+                       #check that the virtual source's steam id is found
+                       if self.get_parent().get_key() == 'virtual_source':
+                               try: assert v in ids
+                               except: raise Exception, 'Stream ID "%s" is not found.'%v
+                       return v
+               #########################
                # Grid Position Type
                #########################
                elif t == 'grid_pos':
index ad02bf79065f77ba6dce8d0fc552d423195035f6..ef94abfb5ff00afb8984262abc5b4f839925de5a 100644 (file)
@@ -58,8 +58,6 @@
 ##################################################
 # Problems
 ##################################################
-* need a way to make an id param in the xml that will override the default
-  * ex: display pad sink id in continuation mode using hide tag for id param
 * hier block generation
   * auto generate hier library on changes
   * auto clean hier library when block removed