adopt to updated api
This commit is contained in:
parent
5e7a0a38aa
commit
320521a74a
@ -1,11 +1,10 @@
|
|||||||
from pycsdr.modules import Buffer
|
from pycsdr.modules import Buffer
|
||||||
from pycsdr.api import Flow
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Chain(Flow):
|
class Chain:
|
||||||
def __init__(self, *workers):
|
def __init__(self, *workers):
|
||||||
self.input = None
|
self.input = None
|
||||||
self.output = None
|
self.output = None
|
||||||
@ -14,7 +13,7 @@ class Chain(Flow):
|
|||||||
self._connect(self.workers[i - 1], self.workers[i])
|
self._connect(self.workers[i - 1], self.workers[i])
|
||||||
|
|
||||||
def _connect(self, w1, w2):
|
def _connect(self, w1, w2):
|
||||||
buffer = Buffer()
|
buffer = Buffer(w1.getOutputFormat())
|
||||||
w1.setOutput(buffer)
|
w1.setOutput(buffer)
|
||||||
w2.setInput(buffer)
|
w2.setInput(buffer)
|
||||||
|
|
||||||
@ -36,9 +35,12 @@ class Chain(Flow):
|
|||||||
self.output = buffer
|
self.output = buffer
|
||||||
self.workers[-1].setOutput(buffer)
|
self.workers[-1].setOutput(buffer)
|
||||||
|
|
||||||
|
def getOutputFormat(self):
|
||||||
|
return self.workers[-1].getOutputFormat()
|
||||||
|
|
||||||
def pump(self, write):
|
def pump(self, write):
|
||||||
if self.output is None:
|
if self.output is None:
|
||||||
self.setOutput(Buffer())
|
self.setOutput(Buffer(self.getOutputFormat()))
|
||||||
|
|
||||||
def copy():
|
def copy():
|
||||||
run = True
|
run = True
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from csdr.chain import Chain
|
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
|
import logging
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -37,7 +37,7 @@ class FftAverager(Chain):
|
|||||||
if self.input is not None:
|
if self.input is not None:
|
||||||
self.worker.setInput(self.input)
|
self.worker.setInput(self.input)
|
||||||
else:
|
else:
|
||||||
self.worker.setFftAverages(avg_number=fft_averages)
|
self.worker.setAvgNumber(avg_number=fft_averages)
|
||||||
self.workers = [self.worker]
|
self.workers = [self.worker]
|
||||||
self.fftAverages = fft_averages
|
self.fftAverages = fft_averages
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class FftChain(Chain):
|
|||||||
|
|
||||||
self.fft = Fft(size=self.size, every_n_samples=self.blockSize)
|
self.fft = Fft(size=self.size, every_n_samples=self.blockSize)
|
||||||
self.averager = FftAverager(fft_size=self.size, fft_averages=10)
|
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 = [
|
workers = [
|
||||||
self.fft,
|
self.fft,
|
||||||
self.averager,
|
self.averager,
|
||||||
@ -61,7 +61,7 @@ class FftChain(Chain):
|
|||||||
]
|
]
|
||||||
self.compressFftAdpcm = None
|
self.compressFftAdpcm = None
|
||||||
if fft_compression == "adpcm":
|
if fft_compression == "adpcm":
|
||||||
self.compressFftAdpcm = CompressFftAdpcm(fft_size=self.size)
|
self.compressFftAdpcm = FftAdpcm(fft_size=self.size)
|
||||||
workers += [self.compressFftAdpcm]
|
workers += [self.compressFftAdpcm]
|
||||||
|
|
||||||
self._updateParameters()
|
self._updateParameters()
|
||||||
|
@ -21,7 +21,8 @@ from owrx.feature import FeatureDetector
|
|||||||
from typing import List
|
from typing import List
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
from pycsdr.modules import SocketClient, Buffer
|
from pycsdr.modules import TcpSource, Buffer
|
||||||
|
from pycsdr.types import Format
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -111,7 +112,7 @@ class SdrSource(ABC):
|
|||||||
self.id = id
|
self.id = id
|
||||||
|
|
||||||
self.commandMapper = None
|
self.commandMapper = None
|
||||||
self.socketClient = None
|
self.tcpSource = None
|
||||||
self.buffer = None
|
self.buffer = None
|
||||||
|
|
||||||
self.props = PropertyStack()
|
self.props = PropertyStack()
|
||||||
@ -248,16 +249,16 @@ class SdrSource(ABC):
|
|||||||
def getPort(self):
|
def getPort(self):
|
||||||
return self.port
|
return self.port
|
||||||
|
|
||||||
def _getSocketCLient(self):
|
def _getTcpSource(self):
|
||||||
with self.modificationLock:
|
with self.modificationLock:
|
||||||
if self.socketClient is None:
|
if self.tcpSource is None:
|
||||||
self.socketClient = SocketClient(self.port)
|
self.tcpSource = TcpSource(self.port)
|
||||||
return self.socketClient
|
return self.tcpSource
|
||||||
|
|
||||||
def getBuffer(self):
|
def getBuffer(self):
|
||||||
if self.buffer is None:
|
if self.buffer is None:
|
||||||
self.buffer = Buffer()
|
self.buffer = Buffer(Format.COMPLEX_FLOAT)
|
||||||
self._getSocketCLient().setOutput(self.buffer)
|
self._getTcpSource().setOutput(self.buffer)
|
||||||
return self.buffer
|
return self.buffer
|
||||||
|
|
||||||
def getCommandValues(self):
|
def getCommandValues(self):
|
||||||
@ -369,9 +370,9 @@ class SdrSource(ABC):
|
|||||||
pass
|
pass
|
||||||
if self.monitor:
|
if self.monitor:
|
||||||
self.monitor.join()
|
self.monitor.join()
|
||||||
if self.socketClient is not None:
|
if self.tcpSource is not None:
|
||||||
self.socketClient.stop()
|
self.tcpSource.stop()
|
||||||
self.socketClient = None
|
self.tcpSource = None
|
||||||
self.buffer = None
|
self.buffer = None
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user