[message filter]
- take filter string and substite string - can now replace key by another key git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@529 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -4,13 +4,24 @@
|
||||
<key>jay_message_filter</key>
|
||||
<category>[jay]</category>
|
||||
<import>import jay</import>
|
||||
<make>jay.message_filter()</make>
|
||||
<make>jay.message_filter($filterString, $substString)</make>
|
||||
<param>
|
||||
<name>Filter String</name>
|
||||
<key>filterString</key>
|
||||
<value>freq_rel_Hz</value>
|
||||
<type>string</type>
|
||||
</param>
|
||||
<param>
|
||||
<name>Substitute String</name>
|
||||
<key>substString</key>
|
||||
<value>freq</value>
|
||||
<type>string</type>
|
||||
</param>
|
||||
<sink>
|
||||
<name>in</name>
|
||||
<type>message</type>
|
||||
<optional>1</optional>
|
||||
</sink>
|
||||
|
||||
<source>
|
||||
<name>out</name>
|
||||
<type>message</type>
|
||||
|
||||
@@ -27,13 +27,14 @@ class message_filter(gr.basic_block):
|
||||
"""
|
||||
docstring for block message_filter
|
||||
"""
|
||||
def __init__(self, filter='freq'):
|
||||
def __init__(self, filter, subst=''):
|
||||
gr.basic_block.__init__(self,
|
||||
name="message_filter",
|
||||
in_sig=None,
|
||||
out_sig=None)
|
||||
|
||||
self.filter = filter
|
||||
self.subst = subst
|
||||
|
||||
# Register in / out message ports
|
||||
self.port_in = pmt.intern("in")
|
||||
@@ -47,9 +48,13 @@ class message_filter(gr.basic_block):
|
||||
|
||||
def delegate_pair(self, pair):
|
||||
key = pmt.car(pair)
|
||||
val = pmt.cdr(pair)
|
||||
key_str = pmt.symbol_to_string(key)
|
||||
|
||||
if self.filter in key_str:
|
||||
if len(self.subst):
|
||||
pair = pmt.cons(pmt.string_to_symbol(self.subst), val)
|
||||
|
||||
self.message_port_pub(self.port_out, pair)
|
||||
|
||||
def msg_handler(self, msg):
|
||||
|
||||
Reference in New Issue
Block a user