From 364c7eb5050492514edb325ae85cf5c966190303 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Thu, 18 Mar 2021 21:53:59 +0100 Subject: [PATCH] show more information on the sdr settings page --- owrx/__main__.py | 2 +- owrx/connection.py | 2 +- owrx/controllers/settings/sdr.py | 16 +++++++++++++--- owrx/controllers/status.py | 2 +- owrx/sdr.py | 12 ++++++++---- owrx/service/__init__.py | 4 ++-- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/owrx/__main__.py b/owrx/__main__.py index 1bc62c6..c6598bb 100644 --- a/owrx/__main__.py +++ b/owrx/__main__.py @@ -64,7 +64,7 @@ Support and info: https://groups.io/g/openwebrx # Get error messages about unknown / unavailable features as soon as possible # start up "always-on" sources right away - SdrService.getSources() + SdrService.getAllSources() Services.start() diff --git a/owrx/connection.py b/owrx/connection.py index 5cf291a..6ed86c5 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -236,7 +236,7 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient): def __sendProfiles(self): profiles = [ {"name": s.getName() + " " + p["name"], "id": sid + "|" + pid} - for (sid, s) in SdrService.getSources().items() + for (sid, s) in SdrService.getActiveSources().items() for (pid, p) in s.getProfiles().items() ] self.write_profiles(profiles) diff --git a/owrx/controllers/settings/sdr.py b/owrx/controllers/settings/sdr.py index a280a34..0243850 100644 --- a/owrx/controllers/settings/sdr.py +++ b/owrx/controllers/settings/sdr.py @@ -22,10 +22,11 @@ class SdrDeviceListController(AuthorizationMixin, WebpageController): def render_devices(self): def render_device(device_id, config): - # TODO: this only returns non-failed sources... - source = SdrService.getSource(device_id) + sources = SdrService.getAllSources() + source = sources[device_id] if device_id in sources else None additional_info = "" + state_info = "Unknown" if source is not None: profiles = source.getProfiles() @@ -45,6 +46,15 @@ class SdrDeviceListController(AuthorizationMixin, WebpageController): connections=connections, ) + state_info = ", ".join( + s for s in [ + str(source.getState()), + None if source.isEnabled() else "Disabled", + "Failed" if source.isFailed() else None + ] + if s is not None + ) + return """
  • @@ -62,7 +72,7 @@ class SdrDeviceListController(AuthorizationMixin, WebpageController): """.format( device_name=config["name"], device_link="{}/{}".format(self.request.path, quote(device_id)), - state="Unknown" if source is None else source.getState(), + state=state_info, additional_info=additional_info, newprofile_link="{}settings/sdr/{}/newprofile".format(self.get_document_root(), quote(device_id)), ) diff --git a/owrx/controllers/status.py b/owrx/controllers/status.py index 05cacd1..b45292a 100644 --- a/owrx/controllers/status.py +++ b/owrx/controllers/status.py @@ -39,6 +39,6 @@ class StatusController(ReceiverIdController): }, "max_clients": pm["max_clients"], "version": openwebrx_version, - "sdrs": [self.getReceiverStats(r) for r in SdrService.getSources().values()], + "sdrs": [self.getReceiverStats(r) for r in SdrService.getActiveSources().values()], } self.send_response(json.dumps(status, cls=Encoder), content_type="application/json") diff --git a/owrx/sdr.py b/owrx/sdr.py index f0bbe07..73c1ee7 100644 --- a/owrx/sdr.py +++ b/owrx/sdr.py @@ -91,7 +91,7 @@ class SdrService(object): @staticmethod def getFirstSource(): - sources = SdrService.getSources() + sources = SdrService.getActiveSources() if not sources: return None # TODO: configure default sdr in config? right now it will pick the first one off the list. @@ -99,7 +99,7 @@ class SdrService(object): @staticmethod def getSource(id): - sources = SdrService.getSources() + sources = SdrService.getActiveSources() if not sources: return None if id not in sources: @@ -107,11 +107,15 @@ class SdrService(object): return sources[id] @staticmethod - def getSources(): + def getAllSources(): if SdrService.sources is None: SdrService.sources = MappedSdrSources(Config.get()["sdrs"]) + return SdrService.sources + + @staticmethod + def getActiveSources(): return { key: s - for key, s in SdrService.sources.items() + for key, s in SdrService.getAllSources().items() if not s.isFailed() and s.isEnabled() } diff --git a/owrx/service/__init__.py b/owrx/service/__init__.py index fe696cb..5072fd5 100644 --- a/owrx/service/__init__.py +++ b/owrx/service/__init__.py @@ -322,13 +322,13 @@ class Services(object): def start(): config = Config.get() config.wireProperty("services_enabled", Services._receiveEvent) - for source in SdrService.getSources().values(): + for source in SdrService.getActiveSources().values(): Services.schedulers.append(ServiceScheduler(source)) @staticmethod def _receiveEvent(state): if state: - for source in SdrService.getSources().values(): + for source in SdrService.getActiveSources().values(): Services.handlers.append(ServiceHandler(source)) else: while Services.handlers: