Hi list, 

I'm trying to write a block in python.

What I want to do is create a block that passes the signal through some well
know blocks (such as FFT), do its processing and output the signal.

Basically, what I did so far is:

#####
class energy_detector(gr.hier_block2):
        class energy_calculator(gr.sync_block):
                """ Nested class
                """
                def __init__(self, fft_size):
                        gr.sync_block.__init__(
                                        self,
                                        name = "energy_detector",
                                        in_sig =  [np.dtype((np.float32, 
fft_size))], 
                                        out_sig = [np.float32]
                                        )

                        def work(self, input_items, output_items):
                                """ Work here
                                """

                                return len(out)
                        
                """
                Main block
                """ 
        def __init__(self, fft_size):
                """
                Constructor
                """

                """ Initialize our energy detector block
                        in_sig:  vector of fft_size elements
                        out_sig: one float for each input vector
                """
                gr.hier_block2.__init__(
                                self,
                                name = "energy_detector",
                                in_sig =  [np.dtype((np.float32, fft_size))], 
                                out_sig = [np.float32]
                                )

                #
                # Blocks
                # 
                self.fft  =  fft. fft_vcc(fft_size, True, [], False)
                self.v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_size)
                self.c2f = gr.complex_to_float()
                self.s2v = gr.stream_to_vector(gr.sizeof_float, fft_size)
                self.ec  = self.energy_calculator(fft_size)

                # Flow graph
                self.connect(self, self.fft, self.v2s, self.c2f, self.s2v, 
self.ec, self)
########

But it does not work. What can I do to achieve the result I need ?

Thanks



--
View this message in context: 
http://gnuradio.4.n7.nabble.com/Python-block-composed-of-other-blocks-tp39279.html
Sent from the GnuRadio mailing list archive at Nabble.com.

_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to