diff options
author | Nao Pross <np@0hm.ch> | 2021-11-20 17:05:23 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2021-11-20 17:05:23 +0100 |
commit | 2004febde3f7124acba0e0cc1697c7a0088b4a40 (patch) | |
tree | 260af2dd41be7a34fdf6730145ef90e3e6f96286 /simulation/QAM_Fading/epy_block_0.py | |
parent | Implement Frame Object (diff) | |
parent | FIR filter eigerner Block angefangen (diff) | |
download | Fading-2004febde3f7124acba0e0cc1697c7a0088b4a40.tar.gz Fading-2004febde3f7124acba0e0cc1697c7a0088b4a40.zip |
Merge branch 'master' of github.com:NaoPross/Fading
Diffstat (limited to 'simulation/QAM_Fading/epy_block_0.py')
-rw-r--r-- | simulation/QAM_Fading/epy_block_0.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/simulation/QAM_Fading/epy_block_0.py b/simulation/QAM_Fading/epy_block_0.py new file mode 100644 index 0000000..8c7e300 --- /dev/null +++ b/simulation/QAM_Fading/epy_block_0.py @@ -0,0 +1,50 @@ +""" +Embedded Python Blocks: + +Each time this file is saved, GRC will instantiate the first class it finds +to get ports and parameters of your block. The arguments to __init__ will +be the parameters. All of them are required to have default values! +""" + +import numpy as np +from gnuradio import gr + + +class blk(gr.sync_block): # other base classes are basic_block, decim_block, interp_block + """Embedded Python Block example - a simple multiply const""" + + def __init__(self, amplitudes=[], delays=[]): # only default arguments here + """arguments to this function show up as parameters in GRC""" + gr.sync_block.__init__( + self, + name='Embedded Python Block', # will show up in GRC + in_sig=[np.complex64], + out_sig=[np.complex64] + ) + # if an attribute with the same name as a parameter is found, + # a callback is registered (properties work, too). + self.amplitues = amplitudes + self.delays = delays + + #self.fir = + + def work(self, input_items, output_items): + """example: multiply with constant""" + inp = input_items[0] + oup = output_items[0] + amplitudes = [0.2, 0.5 ,0.8] + delays = [3,5,2] + i = len(amplitudes) + + outp[:] = [([1]+[0 for n in range (0,delays[i])]+[amplitudes[i]]) for i in range(0,i)] + + return len(output_items[0]) + + +if __name__ == '__main__': + ampl = [0.2, 0.5 ,0.8] + delays = [3,5,2] + i = len(ampl) + [([1]+[0 for n in range (0,delays[i])]+[ampl[i]]) for i in range(0,i)] + + |