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
# start up "always-on" sources right away
SdrService.getSources()
SdrService.getAllSources()
Services.start()

View File

@ -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)

View File

@ -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 """
<li class="list-group-item">
<div class="row">
@ -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)),
)

View File

@ -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")

View File

@ -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()
}

View File

@ -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: