From 320521a74a528f68b70cf6da444934d4be7f18b9 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Fri, 16 Jul 2021 16:12:16 +0200 Subject: [PATCH] adopt to updated api --- csdr/chain/__init__.py | 10 ++++++---- csdr/chain/fft.py | 8 ++++---- owrx/source/__init__.py | 23 ++++++++++++----------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/csdr/chain/__init__.py b/csdr/chain/__init__.py index bab0c0b..53afda0 100644 --- a/csdr/chain/__init__.py +++ b/csdr/chain/__init__.py @@ -1,11 +1,10 @@ from pycsdr.modules import Buffer -from pycsdr.api import Flow import logging logger = logging.getLogger(__name__) -class Chain(Flow): +class Chain: def __init__(self, *workers): self.input = None self.output = None @@ -14,7 +13,7 @@ class Chain(Flow): self._connect(self.workers[i - 1], self.workers[i]) def _connect(self, w1, w2): - buffer = Buffer() + buffer = Buffer(w1.getOutputFormat()) w1.setOutput(buffer) w2.setInput(buffer) @@ -36,9 +35,12 @@ class Chain(Flow): self.output = buffer self.workers[-1].setOutput(buffer) + def getOutputFormat(self): + return self.workers[-1].getOutputFormat() + def pump(self, write): if self.output is None: - self.setOutput(Buffer()) + self.setOutput(Buffer(self.getOutputFormat())) def copy(): run = True diff --git a/csdr/chain/fft.py b/csdr/chain/fft.py index e709b04..68d0379 100644 --- a/csdr/chain/fft.py +++ b/csdr/chain/fft.py @@ -1,5 +1,5 @@ from csdr.chain import Chain -from pycsdr.modules import Fft, LogPower, LogAveragePower, FftExchangeSides, CompressFftAdpcm +from pycsdr.modules import Fft, LogPower, LogAveragePower, FftSwap, FftAdpcm import logging logger = logging.getLogger(__name__) @@ -37,7 +37,7 @@ class FftAverager(Chain): if self.input is not None: self.worker.setInput(self.input) else: - self.worker.setFftAverages(avg_number=fft_averages) + self.worker.setAvgNumber(avg_number=fft_averages) self.workers = [self.worker] self.fftAverages = fft_averages @@ -53,7 +53,7 @@ class FftChain(Chain): self.fft = Fft(size=self.size, every_n_samples=self.blockSize) self.averager = FftAverager(fft_size=self.size, fft_averages=10) - self.fftExchangeSides = FftExchangeSides(fft_size=self.size) + self.fftExchangeSides = FftSwap(fft_size=self.size) workers = [ self.fft, self.averager, @@ -61,7 +61,7 @@ class FftChain(Chain): ] self.compressFftAdpcm = None if fft_compression == "adpcm": - self.compressFftAdpcm = CompressFftAdpcm(fft_size=self.size) + self.compressFftAdpcm = FftAdpcm(fft_size=self.size) workers += [self.compressFftAdpcm] self._updateParameters() diff --git a/owrx/source/__init__.py b/owrx/source/__init__.py index 691867c..ddd4f36 100644 --- a/owrx/source/__init__.py +++ b/owrx/source/__init__.py @@ -21,7 +21,8 @@ from owrx.feature import FeatureDetector from typing import List from enum import Enum -from pycsdr.modules import SocketClient, Buffer +from pycsdr.modules import TcpSource, Buffer +from pycsdr.types import Format import logging @@ -111,7 +112,7 @@ class SdrSource(ABC): self.id = id self.commandMapper = None - self.socketClient = None + self.tcpSource = None self.buffer = None self.props = PropertyStack() @@ -248,16 +249,16 @@ class SdrSource(ABC): def getPort(self): return self.port - def _getSocketCLient(self): + def _getTcpSource(self): with self.modificationLock: - if self.socketClient is None: - self.socketClient = SocketClient(self.port) - return self.socketClient + if self.tcpSource is None: + self.tcpSource = TcpSource(self.port) + return self.tcpSource def getBuffer(self): if self.buffer is None: - self.buffer = Buffer() - self._getSocketCLient().setOutput(self.buffer) + self.buffer = Buffer(Format.COMPLEX_FLOAT) + self._getTcpSource().setOutput(self.buffer) return self.buffer def getCommandValues(self): @@ -369,9 +370,9 @@ class SdrSource(ABC): pass if self.monitor: self.monitor.join() - if self.socketClient is not None: - self.socketClient.stop() - self.socketClient = None + if self.tcpSource is not None: + self.tcpSource.stop() + self.tcpSource = None self.buffer = None def shutdown(self):