show more information on the sdr settings page

This commit is contained in:
Jakob Ketterl 2021-03-18 21:53:59 +01:00
parent 9dcf342b13
commit 364c7eb505
6 changed files with 26 additions and 12 deletions

View File

@ -64,7 +64,7 @@ Support and info: https://groups.io/g/openwebrx
# Get error messages about unknown / unavailable features as soon as possible # Get error messages about unknown / unavailable features as soon as possible
# start up "always-on" sources right away # start up "always-on" sources right away
SdrService.getSources() SdrService.getAllSources()
Services.start() Services.start()

View File

@ -236,7 +236,7 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
def __sendProfiles(self): def __sendProfiles(self):
profiles = [ profiles = [
{"name": s.getName() + " " + p["name"], "id": sid + "|" + pid} {"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() for (pid, p) in s.getProfiles().items()
] ]
self.write_profiles(profiles) self.write_profiles(profiles)

View File

@ -22,10 +22,11 @@ class SdrDeviceListController(AuthorizationMixin, WebpageController):
def render_devices(self): def render_devices(self):
def render_device(device_id, config): def render_device(device_id, config):
# TODO: this only returns non-failed sources... sources = SdrService.getAllSources()
source = SdrService.getSource(device_id) source = sources[device_id] if device_id in sources else None
additional_info = "" additional_info = ""
state_info = "Unknown"
if source is not None: if source is not None:
profiles = source.getProfiles() profiles = source.getProfiles()
@ -45,6 +46,15 @@ class SdrDeviceListController(AuthorizationMixin, WebpageController):
connections=connections, 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 """ return """
<li class="list-group-item"> <li class="list-group-item">
<div class="row"> <div class="row">
@ -62,7 +72,7 @@ class SdrDeviceListController(AuthorizationMixin, WebpageController):
""".format( """.format(
device_name=config["name"], device_name=config["name"],
device_link="{}/{}".format(self.request.path, quote(device_id)), 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, additional_info=additional_info,
newprofile_link="{}settings/sdr/{}/newprofile".format(self.get_document_root(), quote(device_id)), newprofile_link="{}settings/sdr/{}/newprofile".format(self.get_document_root(), quote(device_id)),
) )

View File

@ -39,6 +39,6 @@ class StatusController(ReceiverIdController):
}, },
"max_clients": pm["max_clients"], "max_clients": pm["max_clients"],
"version": openwebrx_version, "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") self.send_response(json.dumps(status, cls=Encoder), content_type="application/json")

View File

@ -91,7 +91,7 @@ class SdrService(object):
@staticmethod @staticmethod
def getFirstSource(): def getFirstSource():
sources = SdrService.getSources() sources = SdrService.getActiveSources()
if not sources: if not sources:
return None return None
# TODO: configure default sdr in config? right now it will pick the first one off the list. # 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 @staticmethod
def getSource(id): def getSource(id):
sources = SdrService.getSources() sources = SdrService.getActiveSources()
if not sources: if not sources:
return None return None
if id not in sources: if id not in sources:
@ -107,11 +107,15 @@ class SdrService(object):
return sources[id] return sources[id]
@staticmethod @staticmethod
def getSources(): def getAllSources():
if SdrService.sources is None: if SdrService.sources is None:
SdrService.sources = MappedSdrSources(Config.get()["sdrs"]) SdrService.sources = MappedSdrSources(Config.get()["sdrs"])
return SdrService.sources
@staticmethod
def getActiveSources():
return { return {
key: s key: s
for key, s in SdrService.sources.items() for key, s in SdrService.getAllSources().items()
if not s.isFailed() and s.isEnabled() if not s.isFailed() and s.isEnabled()
} }

View File

@ -322,13 +322,13 @@ class Services(object):
def start(): def start():
config = Config.get() config = Config.get()
config.wireProperty("services_enabled", Services._receiveEvent) config.wireProperty("services_enabled", Services._receiveEvent)
for source in SdrService.getSources().values(): for source in SdrService.getActiveSources().values():
Services.schedulers.append(ServiceScheduler(source)) Services.schedulers.append(ServiceScheduler(source))
@staticmethod @staticmethod
def _receiveEvent(state): def _receiveEvent(state):
if state: if state:
for source in SdrService.getSources().values(): for source in SdrService.getActiveSources().values():
Services.handlers.append(ServiceHandler(source)) Services.handlers.append(ServiceHandler(source))
else: else:
while Services.handlers: while Services.handlers: