update profile dropdown box on changes

This commit is contained in:
Jakob Ketterl
2019-10-04 22:01:07 +02:00
parent 3e25f1ec42
commit b80fd9c023
3 changed files with 23 additions and 3 deletions

View File

@ -164,6 +164,8 @@ class OpenWebRxReceiverClient(Client):
config = dict((key, configProps[key]) for key in OpenWebRxReceiverClient.config_keys)
# TODO mathematical properties? hmmmm
config["start_offset_freq"] = configProps["start_freq"] - configProps["center_freq"]
# TODO this is a hack that only works because setting the profile always causes plenty of config change
config["profile_id"] = self.sdr.getId() + "|" + self.sdr.getProfileId()
self.write_config(config)
cf = configProps["center_freq"]

View File

@ -89,7 +89,7 @@ class SdrService(object):
props = SdrService.sdrProps[id]
className = "".join(x for x in props["type"].title() if x.isalnum()) + "Source"
cls = getattr(sys.modules[__name__], className)
SdrService.sources[id] = cls(props, SdrService.getNextPort())
SdrService.sources[id] = cls(id, props, SdrService.getNextPort())
return SdrService.sources
@ -98,8 +98,10 @@ class SdrSourceException(Exception):
class SdrSource(object):
def __init__(self, props, port):
def __init__(self, id, props, port):
self.id = id
self.props = props
self.profile_id = None
self.activateProfile()
self.rtlProps = self.props.collect(
"samp_rate", "nmux_memory", "center_freq", "ppm", "rf_gain", "lna_gain", "rf_amp", "antenna", "if_gain"
@ -131,7 +133,10 @@ class SdrSource(object):
profiles = self.props["profiles"]
if profile_id is None:
profile_id = list(profiles.keys())[0]
if profile_id == self.profile_id:
return;
logger.debug("activating profile {0}".format(profile_id))
self.profile_id = profile_id
profile = profiles[profile_id]
for (key, value) in profile.items():
# skip the name, that would overwrite the source name.
@ -139,6 +144,12 @@ class SdrSource(object):
continue
self.props[key] = value
def getId(self):
return self.id
def getProfileId(self):
return self.profile_id
def getProfiles(self):
return self.props["profiles"]
@ -291,7 +302,7 @@ class Resampler(SdrSource):
props["samp_rate"] = if_samp_rate
self.sdr = sdr
super().__init__(props, port)
super().__init__(None, props, port)
def start(self):
self.modificationLock.acquire()