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
|
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"]
|
||||||
|
@ -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"]
|
||||||
|
@ -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
|
||||||
|
@ -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):
|
||||||
|
@ -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):
|
||||||
|
@ -29,22 +29,22 @@ class ConnectorSource(SdrSource):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
def sendControlMessage(self, prop, value):
|
def sendControlMessage(self, changes):
|
||||||
logger.debug("sending property change over control socket: {0} changed to {1}".format(prop, value))
|
for prop, value in changes.items():
|
||||||
self.controlSocket.sendall("{prop}:{value}\n".format(prop=prop, value=value).encode())
|
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:
|
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...")
|
||||||
|
@ -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()
|
||||||
|
@ -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)
|
|
||||||
|
@ -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()
|
||||||
|
@ -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()
|
||||||
if prop in mappings.keys():
|
settings = {}
|
||||||
value = "{0}={1}".format(mappings[prop], self.convertSoapySettingsValue(value))
|
for prop, value in changes.items():
|
||||||
prop = "settings"
|
if prop in mappings.keys():
|
||||||
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