put the socketclient on the source so it can be shared

This commit is contained in:
Jakob Ketterl
2020-12-19 16:28:18 +01:00
parent 1bd6aa73f3
commit efe80a75f5
5 changed files with 27 additions and 4 deletions

View File

@ -31,6 +31,7 @@ class SpectrumThread(csdr.output, SdrSourceEventClient):
self.dsp = dsp = csdr.dsp(self)
dsp.nc_port = self.sdrSource.getPort()
dsp.setSocketClient(self.sdrSource.getSocketClient())
dsp.set_demodulator("fft")
def set_fft_averages(key, value):

View File

@ -11,6 +11,8 @@ from owrx.command import CommandMapper
from owrx.socket import getAvailablePort
from owrx.property import PropertyStack, PropertyLayer
from pycsdr import SocketClient
import logging
logger = logging.getLogger(__name__)
@ -48,6 +50,7 @@ class SdrSource(ABC):
self.id = id
self.commandMapper = None
self.socketClient = None
self.props = PropertyStack()
# layer 0 reserved for profile properties
@ -141,6 +144,12 @@ class SdrSource(ABC):
def getPort(self):
return self.port
def getSocketClient(self):
with self.modificationLock:
if self.socketClient is None:
self.socketClient = SocketClient(self.port)
return self.socketClient
def getCommandValues(self):
dict = self.sdrProps.__dict__()
if "lfo_offset" in dict and dict["lfo_offset"] is not None:
@ -249,6 +258,9 @@ class SdrSource(ABC):
pass
if self.monitor:
self.monitor.join()
if self.socketClient is not None:
self.socketClient.stop()
self.socketClient = None
def hasClients(self, *args):
clients = [c for c in self.clients if c.getClientClass() in args]