[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:
@@ -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