adapt to config event api changes
This commit is contained in:
parent
29703d10b2
commit
cf0c6e7f9d
@ -71,7 +71,7 @@ class DspManager(csdr.output, SdrSourceEventClient):
|
||||
bpf[1] = cut
|
||||
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:
|
||||
return
|
||||
freq = self.props["center_freq"] + self.props["offset_freq"]
|
||||
|
@ -33,7 +33,7 @@ class SpectrumThread(csdr.output, SdrSourceEventClient):
|
||||
dsp.nc_port = self.sdrSource.getPort()
|
||||
dsp.set_demodulator("fft")
|
||||
|
||||
def set_fft_averages(key, value):
|
||||
def set_fft_averages(changes=None):
|
||||
samp_rate = props["samp_rate"]
|
||||
fft_size = props["fft_size"]
|
||||
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),
|
||||
]
|
||||
|
||||
set_fft_averages(None, None)
|
||||
set_fft_averages()
|
||||
|
||||
dsp.csdr_dynamic_bufsize = props["csdr_dynamic_bufsize"]
|
||||
dsp.csdr_print_bufsizes = props["csdr_print_bufsizes"]
|
||||
|
@ -111,7 +111,7 @@ class ServiceHandler(SdrSourceEventClient):
|
||||
for service in services:
|
||||
service.stop()
|
||||
|
||||
def onFrequencyChange(self, key, value):
|
||||
def onFrequencyChange(self, changes):
|
||||
self.stopServices()
|
||||
if not self.source.isAvailable():
|
||||
return
|
||||
|
@ -246,7 +246,7 @@ class ServiceScheduler(SdrSourceEventClient):
|
||||
if state == SdrSource.BUSYSTATE_IDLE:
|
||||
self.scheduleSelection()
|
||||
|
||||
def onFrequencyChange(self, name, value):
|
||||
def onFrequencyChange(self, changes):
|
||||
self.scheduleSelection()
|
||||
|
||||
def selectProfile(self):
|
||||
|
@ -92,7 +92,7 @@ class SdrSource(ABC):
|
||||
return self.commandMapper
|
||||
|
||||
@abstractmethod
|
||||
def onPropertyChange(self, name, value):
|
||||
def onPropertyChange(self, changes):
|
||||
pass
|
||||
|
||||
def wireEvents(self):
|
||||
|
@ -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))
|
||||
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:
|
||||
return
|
||||
if (
|
||||
(prop == "center_freq" or prop == "lfo_offset")
|
||||
("center_freq" in changes or "lfo_offset" in changes)
|
||||
and "lfo_offset" in self.sdrProps
|
||||
and self.sdrProps["lfo_offset"] is not None
|
||||
):
|
||||
freq = self.sdrProps["center_freq"] + self.sdrProps["lfo_offset"]
|
||||
self.sendControlMessage("center_freq", freq)
|
||||
else:
|
||||
self.sendControlMessage(prop, value)
|
||||
changes["center_freq"] = self.sdrProps["center_freq"] + self.sdrProps["lfo_offset"]
|
||||
changes.pop("lfo_offset", None)
|
||||
self.sendControlMessage(changes)
|
||||
|
||||
def postStart(self):
|
||||
logger.debug("opening control socket...")
|
||||
|
@ -7,12 +7,8 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DirectSource(SdrSource, metaclass=ABCMeta):
|
||||
def onPropertyChange(self, name, value):
|
||||
logger.debug(
|
||||
"restarting sdr source due to property change: {0} changed to {1}".format(
|
||||
name, value
|
||||
)
|
||||
)
|
||||
def onPropertyChange(self, changes):
|
||||
logger.debug("restarting sdr source due to property changes: {0}".format(changes))
|
||||
self.stop()
|
||||
self.sleepOnRestart()
|
||||
self.start()
|
||||
|
@ -30,7 +30,6 @@ class FifiSdrSource(DirectSource):
|
||||
values = self.getCommandValues()
|
||||
self.sendRockProgFrequency(values["tuner_freq"])
|
||||
|
||||
def onPropertyChange(self, name, value):
|
||||
if name != "center_freq":
|
||||
return
|
||||
self.sendRockProgFrequency(value)
|
||||
def onPropertyChange(self, changes):
|
||||
if "center_freq" in changes:
|
||||
self.sendRockProgFrequency(changes["center_freq"])
|
||||
|
@ -6,8 +6,8 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Resampler(DirectSource):
|
||||
def onPropertyChange(self, name, value):
|
||||
logger.warning("Resampler is unable to handle property change ({0} changed to {1})".format(name, value))
|
||||
def onPropertyChange(self, changes):
|
||||
logger.warning("Resampler is unable to handle property changes: {0}".format(changes))
|
||||
|
||||
def __init__(self, props, sdr):
|
||||
sdrProps = sdr.getProps()
|
||||
|
@ -80,9 +80,12 @@ class SoapyConnectorSource(ConnectorSource, metaclass=ABCMeta):
|
||||
values["soapy_settings"] = settings
|
||||
return values
|
||||
|
||||
def onPropertyChange(self, prop, value):
|
||||
def onPropertyChange(self, changes):
|
||||
mappings = self.getSoapySettingsMappings()
|
||||
settings = {}
|
||||
for prop, value in changes.items():
|
||||
if prop in mappings.keys():
|
||||
value = "{0}={1}".format(mappings[prop], self.convertSoapySettingsValue(value))
|
||||
prop = "settings"
|
||||
super().onPropertyChange(prop, value)
|
||||
settings[mappings[prop]] = self.convertSoapySettingsValue(value)
|
||||
if settings:
|
||||
changes["settings"] = ",".join("{0}={1}".format(k, v) for k, v in settings.items())
|
||||
super().onPropertyChange(changes)
|
||||
|
Loading…
Reference in New Issue
Block a user