adapt to config event api changes

This commit is contained in:
Jakob Ketterl 2020-12-30 17:18:46 +01:00
parent 29703d10b2
commit cf0c6e7f9d
10 changed files with 30 additions and 32 deletions

View File

@ -71,7 +71,7 @@ class DspManager(csdr.output, SdrSourceEventClient):
bpf[1] = cut bpf[1] = cut
self.dsp.set_bpf(*bpf) self.dsp.set_bpf(*bpf)
def set_dial_freq(key, value): def set_dial_freq(changes):
if self.props["center_freq"] is None or self.props["offset_freq"] is None: if self.props["center_freq"] is None or self.props["offset_freq"] is None:
return return
freq = self.props["center_freq"] + self.props["offset_freq"] freq = self.props["center_freq"] + self.props["offset_freq"]

View File

@ -33,7 +33,7 @@ class SpectrumThread(csdr.output, SdrSourceEventClient):
dsp.nc_port = self.sdrSource.getPort() dsp.nc_port = self.sdrSource.getPort()
dsp.set_demodulator("fft") dsp.set_demodulator("fft")
def set_fft_averages(key, value): def set_fft_averages(changes=None):
samp_rate = props["samp_rate"] samp_rate = props["samp_rate"]
fft_size = props["fft_size"] fft_size = props["fft_size"]
fft_fps = props["fft_fps"] fft_fps = props["fft_fps"]
@ -54,7 +54,7 @@ class SpectrumThread(csdr.output, SdrSourceEventClient):
props.filter("samp_rate", "fft_size", "fft_fps", "fft_voverlap_factor").wire(set_fft_averages), props.filter("samp_rate", "fft_size", "fft_fps", "fft_voverlap_factor").wire(set_fft_averages),
] ]
set_fft_averages(None, None) set_fft_averages()
dsp.csdr_dynamic_bufsize = props["csdr_dynamic_bufsize"] dsp.csdr_dynamic_bufsize = props["csdr_dynamic_bufsize"]
dsp.csdr_print_bufsizes = props["csdr_print_bufsizes"] dsp.csdr_print_bufsizes = props["csdr_print_bufsizes"]

View File

@ -111,7 +111,7 @@ class ServiceHandler(SdrSourceEventClient):
for service in services: for service in services:
service.stop() service.stop()
def onFrequencyChange(self, key, value): def onFrequencyChange(self, changes):
self.stopServices() self.stopServices()
if not self.source.isAvailable(): if not self.source.isAvailable():
return return

View File

@ -246,7 +246,7 @@ class ServiceScheduler(SdrSourceEventClient):
if state == SdrSource.BUSYSTATE_IDLE: if state == SdrSource.BUSYSTATE_IDLE:
self.scheduleSelection() self.scheduleSelection()
def onFrequencyChange(self, name, value): def onFrequencyChange(self, changes):
self.scheduleSelection() self.scheduleSelection()
def selectProfile(self): def selectProfile(self):

View File

@ -92,7 +92,7 @@ class SdrSource(ABC):
return self.commandMapper return self.commandMapper
@abstractmethod @abstractmethod
def onPropertyChange(self, name, value): def onPropertyChange(self, changes):
pass pass
def wireEvents(self): def wireEvents(self):

View File

@ -29,22 +29,22 @@ class ConnectorSource(SdrSource):
} }
) )
def sendControlMessage(self, prop, value): def sendControlMessage(self, changes):
for prop, value in changes.items():
logger.debug("sending property change over control socket: {0} changed to {1}".format(prop, value)) logger.debug("sending property change over control socket: {0} changed to {1}".format(prop, value))
self.controlSocket.sendall("{prop}:{value}\n".format(prop=prop, value=value).encode()) self.controlSocket.sendall("{prop}:{value}\n".format(prop=prop, value=value).encode())
def onPropertyChange(self, prop, value): def onPropertyChange(self, changes):
if self.monitor is None: if self.monitor is None:
return return
if ( if (
(prop == "center_freq" or prop == "lfo_offset") ("center_freq" in changes or "lfo_offset" in changes)
and "lfo_offset" in self.sdrProps and "lfo_offset" in self.sdrProps
and self.sdrProps["lfo_offset"] is not None and self.sdrProps["lfo_offset"] is not None
): ):
freq = self.sdrProps["center_freq"] + self.sdrProps["lfo_offset"] changes["center_freq"] = self.sdrProps["center_freq"] + self.sdrProps["lfo_offset"]
self.sendControlMessage("center_freq", freq) changes.pop("lfo_offset", None)
else: self.sendControlMessage(changes)
self.sendControlMessage(prop, value)
def postStart(self): def postStart(self):
logger.debug("opening control socket...") logger.debug("opening control socket...")

View File

@ -7,12 +7,8 @@ logger = logging.getLogger(__name__)
class DirectSource(SdrSource, metaclass=ABCMeta): class DirectSource(SdrSource, metaclass=ABCMeta):
def onPropertyChange(self, name, value): def onPropertyChange(self, changes):
logger.debug( logger.debug("restarting sdr source due to property changes: {0}".format(changes))
"restarting sdr source due to property change: {0} changed to {1}".format(
name, value
)
)
self.stop() self.stop()
self.sleepOnRestart() self.sleepOnRestart()
self.start() self.start()

View File

@ -30,7 +30,6 @@ class FifiSdrSource(DirectSource):
values = self.getCommandValues() values = self.getCommandValues()
self.sendRockProgFrequency(values["tuner_freq"]) self.sendRockProgFrequency(values["tuner_freq"])
def onPropertyChange(self, name, value): def onPropertyChange(self, changes):
if name != "center_freq": if "center_freq" in changes:
return self.sendRockProgFrequency(changes["center_freq"])
self.sendRockProgFrequency(value)

View File

@ -6,8 +6,8 @@ logger = logging.getLogger(__name__)
class Resampler(DirectSource): class Resampler(DirectSource):
def onPropertyChange(self, name, value): def onPropertyChange(self, changes):
logger.warning("Resampler is unable to handle property change ({0} changed to {1})".format(name, value)) logger.warning("Resampler is unable to handle property changes: {0}".format(changes))
def __init__(self, props, sdr): def __init__(self, props, sdr):
sdrProps = sdr.getProps() sdrProps = sdr.getProps()

View File

@ -80,9 +80,12 @@ class SoapyConnectorSource(ConnectorSource, metaclass=ABCMeta):
values["soapy_settings"] = settings values["soapy_settings"] = settings
return values return values
def onPropertyChange(self, prop, value): def onPropertyChange(self, changes):
mappings = self.getSoapySettingsMappings() mappings = self.getSoapySettingsMappings()
settings = {}
for prop, value in changes.items():
if prop in mappings.keys(): if prop in mappings.keys():
value = "{0}={1}".format(mappings[prop], self.convertSoapySettingsValue(value)) settings[mappings[prop]] = self.convertSoapySettingsValue(value)
prop = "settings" if settings:
super().onPropertyChange(prop, value) changes["settings"] = ",".join("{0}={1}".format(k, v) for k, v in settings.items())
super().onPropertyChange(changes)