You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.3 KiB
36 lines
1.3 KiB
# WARNING: DO NOT EDIT "block_shift.py" DIRECTLY! IT IS AUTOGENERATED BY GNURADIO!
|
|
# INSTEAD, OPEN GNURADIO, DOUBLE-CLICK THE BLOCK, AND CLICK ON "Open in Editor"!
|
|
|
|
"""
|
|
Keeps a copy of the last N signals and outputs them at a constant rate,
|
|
so that you can use QT GUI sinks in a "rolling" mode.
|
|
"""
|
|
|
|
import numpy as np
|
|
from gnuradio import gr
|
|
|
|
|
|
CHANNELS = 14
|
|
|
|
|
|
class ShiftBlock(gr.interp_block):
|
|
def __init__(self, number_of_points=1024):
|
|
gr.interp_block.__init__(
|
|
self,
|
|
name='Shifting Block',
|
|
interp=10 * number_of_points, # a large number to ensure that output_items is large enough
|
|
in_sig=[np.float32] * CHANNELS,
|
|
out_sig=[np.float32] * CHANNELS,
|
|
)
|
|
self.number_of_points = number_of_points
|
|
self.buffer = np.zeros((CHANNELS, self.number_of_points), dtype=np.float64)
|
|
|
|
def work(self, input_items, output_items):
|
|
n_inputs = min(self.number_of_points, len(input_items[0]))
|
|
self.buffer = np.roll(self.buffer, shift=-n_inputs, axis=1)
|
|
for channel in range(CHANNELS):
|
|
self.buffer[channel][-n_inputs:] = input_items[channel][:n_inputs]
|
|
output_items[channel][:self.number_of_points] = self.buffer[channel]
|
|
self.consume(channel, n_inputs)
|
|
return self.number_of_points
|