Introduced way to get available profile names in order.

This commit is contained in:
Marat Fayzullin 2024-03-24 12:58:17 -04:00
parent e2c3a4a150
commit 772f4136b3
2 changed files with 14 additions and 1 deletions

View File

@ -290,7 +290,8 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
self.setSdr()
def _sendProfiles(self, *args):
profiles = [{"id": pid, "name": name} for pid, name in SdrService.getAvailableProfiles().items()]
# profiles = [{"id": pid, "name": name} for pid, name in SdrService.getAvailableProfiles().items()]
profiles = [{"id": pid, "name": name} for pid, name in SdrService.getAvailableProfileNames().items()]
self.write_profiles(profiles)
def handleTextMessage(self, conn, message):

View File

@ -272,3 +272,15 @@ class SdrService(object):
def stopAllSources():
for source in SdrService.getAllSources().values():
source.stop()
# This function always returns sources and profiles in the same order
# they are stored in the corresponding property layers, as opposed to
# the AvailableProfiles class.
@staticmethod
def getAvailableProfileNames():
result = {}
for s_id, source in SdrService.getAllSources().items():
if source.isEnabled() and not source.isFailed():
for p_id, profile in source.getProfiles().items():
result["{}|{}".format(s_id, p_id)] = "{} {}".format(source.getName(), profile["name"])
return result