We have successfully used a GUI block to open (or close) a valve by
pressing the mouse button.
Now we want to open (or close) the valve from a Python block that we
are writing after comparing two messages. If the messages are the same,
we want to open the valve, otherwise the valve should remain closed.
Below is the xml definition of our Python block as well as the Python
code. The problem we are having is that GRC does not allow us to compile
the code. The variable beacon_tx is not recognized by the valve block.
Can somebody help u with this issue?
<?xml version="1.0"?> compare conditions_compare conditions import conditions conditions.compare() in int
from gnuradio import gr
docstring for block compare
def work(self, input_items, output_items): in0 = input_items in1 = input_items if numpy.array_equal(in0,in1): self.beacon_tx = True pr.sync_block): """ docstring for block compare """ def __init__(self): gr.sync_block.__init__(self, name="compare", in_sig=[numpy.int,numpy.int], out_sig=None) def work(self, input_items, output_items): in0 = input_items in1 = input_items if numpy.array_equal(in0,in1): self.beacon_tx = True print True else: self.beacon_tx = False print False # <+signal processing here+> return len(self.beacon_tx)