adopt to updated api

This commit is contained in:
Jakob Ketterl 2021-07-16 16:12:16 +02:00
parent 5e7a0a38aa
commit 320521a74a
3 changed files with 22 additions and 19 deletions

View File

@ -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

View File

@ -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()

View File

@ -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):