make the sdr type dropdown show beautiful names
This commit is contained in:
parent
4993a56235
commit
68739724d4
@ -48,10 +48,11 @@ class SdrDeviceListController(AuthorizationMixin, WebpageController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
state_info = ", ".join(
|
state_info = ", ".join(
|
||||||
s for s in [
|
s
|
||||||
|
for s in [
|
||||||
str(source.getState()),
|
str(source.getState()),
|
||||||
None if source.isEnabled() else "Disabled",
|
None if source.isEnabled() else "Disabled",
|
||||||
"Failed" if source.isFailed() else None
|
"Failed" if source.isFailed() else None,
|
||||||
]
|
]
|
||||||
if s is not None
|
if s is not None
|
||||||
)
|
)
|
||||||
@ -276,7 +277,11 @@ class NewSdrDeviceController(SettingsFormController):
|
|||||||
Section(
|
Section(
|
||||||
"New device settings",
|
"New device settings",
|
||||||
TextInput("name", "Device name", validator=RequiredValidator()),
|
TextInput("name", "Device name", validator=RequiredValidator()),
|
||||||
DropdownInput("type", "Device type", [Option(name, name) for name in SdrDeviceDescription.getTypes()]),
|
DropdownInput(
|
||||||
|
"type",
|
||||||
|
"Device type",
|
||||||
|
[Option(sdr_type, name) for sdr_type, name in SdrDeviceDescription.getTypes().items()],
|
||||||
|
),
|
||||||
TextInput("id", "Device ID", validator=RequiredValidator()),
|
TextInput("id", "Device ID", validator=RequiredValidator()),
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
@ -17,6 +17,7 @@ from owrx.form.converter import OptionalConverter
|
|||||||
from owrx.form.device import GainInput, SchedulerInput, WaterfallLevelsInput
|
from owrx.form.device import GainInput, SchedulerInput, WaterfallLevelsInput
|
||||||
from owrx.form.validator import RequiredValidator
|
from owrx.form.validator import RequiredValidator
|
||||||
from owrx.controllers.settings import Section
|
from owrx.controllers.settings import Section
|
||||||
|
from owrx.feature import FeatureDetector
|
||||||
from typing import List
|
from typing import List
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
@ -543,14 +544,27 @@ class SdrDeviceDescription(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getTypes():
|
def getTypes():
|
||||||
def has_description(module_name):
|
def get_description(module_name):
|
||||||
try:
|
try:
|
||||||
SdrDeviceDescription.getByType(module_name)
|
description = SdrDeviceDescription.getByType(module_name)
|
||||||
return True
|
return description.getName()
|
||||||
except SdrDeviceDescriptionMissing:
|
except SdrDeviceDescriptionMissing:
|
||||||
return False
|
return None
|
||||||
|
|
||||||
return [module_name for _, module_name, _ in pkgutil.walk_packages(__path__) if has_description(module_name)]
|
descriptions = {
|
||||||
|
module_name: get_description(module_name) for _, module_name, _ in pkgutil.walk_packages(__path__)
|
||||||
|
}
|
||||||
|
# filter out empty names and unavailable types
|
||||||
|
fd = FeatureDetector()
|
||||||
|
return {k: v for k, v in descriptions.items() if v is not None and fd.is_available(k)}
|
||||||
|
|
||||||
|
def getName(self):
|
||||||
|
"""
|
||||||
|
must be overridden with a textual representation of the device, to be used for device type selection
|
||||||
|
|
||||||
|
:return: str
|
||||||
|
"""
|
||||||
|
return None
|
||||||
|
|
||||||
def getDeviceInputs(self) -> List[Input]:
|
def getDeviceInputs(self) -> List[Input]:
|
||||||
keys = self.getDeviceMandatoryKeys() + self.getDeviceOptionalKeys()
|
keys = self.getDeviceMandatoryKeys() + self.getDeviceOptionalKeys()
|
||||||
|
@ -20,6 +20,9 @@ class AirspySource(SoapyConnectorSource):
|
|||||||
|
|
||||||
|
|
||||||
class AirspyDeviceDescription(SoapyConnectorDeviceDescription):
|
class AirspyDeviceDescription(SoapyConnectorDeviceDescription):
|
||||||
|
def getName(self):
|
||||||
|
return "Airspy R2 or Mini"
|
||||||
|
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return super().getInputs() + [
|
return super().getInputs() + [
|
||||||
BiasTeeInput(),
|
BiasTeeInput(),
|
||||||
|
@ -7,4 +7,5 @@ class AirspyhfSource(SoapyConnectorSource):
|
|||||||
|
|
||||||
|
|
||||||
class AirspyhfDeviceDescription(SoapyConnectorDeviceDescription):
|
class AirspyhfDeviceDescription(SoapyConnectorDeviceDescription):
|
||||||
pass
|
def getName(self):
|
||||||
|
return "Airspy HF+ or Discovery"
|
||||||
|
@ -7,4 +7,5 @@ class FcdppSource(SoapyConnectorSource):
|
|||||||
|
|
||||||
|
|
||||||
class FcdppDeviceDescription(SoapyConnectorDeviceDescription):
|
class FcdppDeviceDescription(SoapyConnectorDeviceDescription):
|
||||||
pass
|
def getName(self):
|
||||||
|
return "FunCube Dongle Pro+"
|
||||||
|
@ -40,4 +40,5 @@ class FifiSdrSource(DirectSource):
|
|||||||
|
|
||||||
|
|
||||||
class FifiSdrDeviceDescription(DirectSourceDeviceDescription):
|
class FifiSdrDeviceDescription(DirectSourceDeviceDescription):
|
||||||
pass
|
def getName(self):
|
||||||
|
return "FiFi SDR"
|
||||||
|
@ -15,6 +15,9 @@ class HackrfSource(SoapyConnectorSource):
|
|||||||
|
|
||||||
|
|
||||||
class HackrfDeviceDescription(SoapyConnectorDeviceDescription):
|
class HackrfDeviceDescription(SoapyConnectorDeviceDescription):
|
||||||
|
def getName(self):
|
||||||
|
return "HackRF"
|
||||||
|
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return super().getInputs() + [BiasTeeInput()]
|
return super().getInputs() + [BiasTeeInput()]
|
||||||
|
|
||||||
|
@ -36,4 +36,5 @@ class HpsdrSource(ConnectorSource):
|
|||||||
|
|
||||||
|
|
||||||
class HpsdrDeviceDescription(ConnectorDeviceDescription):
|
class HpsdrDeviceDescription(ConnectorDeviceDescription):
|
||||||
pass
|
def getName(self):
|
||||||
|
return "HPSDR devices (Hermes / Hermes Lite 2 / Red Pitaya)"
|
||||||
|
@ -7,4 +7,5 @@ class LimeSdrSource(SoapyConnectorSource):
|
|||||||
|
|
||||||
|
|
||||||
class LimeSdrDeviceDescription(SoapyConnectorDeviceDescription):
|
class LimeSdrDeviceDescription(SoapyConnectorDeviceDescription):
|
||||||
pass
|
def getName(self):
|
||||||
|
return "LimeSDR device"
|
||||||
|
@ -50,6 +50,9 @@ class AttenuatorOptions(DropdownEnum):
|
|||||||
|
|
||||||
|
|
||||||
class PerseussdrDeviceDescription(DirectSourceDeviceDescription):
|
class PerseussdrDeviceDescription(DirectSourceDeviceDescription):
|
||||||
|
def getName(self):
|
||||||
|
return "Perseus SDR"
|
||||||
|
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return super().getInputs() + [
|
return super().getInputs() + [
|
||||||
DropdownInput("attenuator", "Attenuator", options=AttenuatorOptions),
|
DropdownInput("attenuator", "Attenuator", options=AttenuatorOptions),
|
||||||
|
@ -7,4 +7,5 @@ class PlutoSdrSource(SoapyConnectorSource):
|
|||||||
|
|
||||||
|
|
||||||
class PlutoSdrDeviceDescription(SoapyConnectorDeviceDescription):
|
class PlutoSdrDeviceDescription(SoapyConnectorDeviceDescription):
|
||||||
pass
|
def getName(self):
|
||||||
|
return "PlutoSDR"
|
||||||
|
@ -7,4 +7,5 @@ class RadioberrySource(SoapyConnectorSource):
|
|||||||
|
|
||||||
|
|
||||||
class RadioberryDeviceDescription(SoapyConnectorDeviceDescription):
|
class RadioberryDeviceDescription(SoapyConnectorDeviceDescription):
|
||||||
pass
|
def getName(self):
|
||||||
|
return "RadioBerry"
|
||||||
|
@ -16,6 +16,9 @@ class RtlSdrSource(ConnectorSource):
|
|||||||
|
|
||||||
|
|
||||||
class RtlSdrDeviceDescription(ConnectorDeviceDescription):
|
class RtlSdrDeviceDescription(ConnectorDeviceDescription):
|
||||||
|
def getName(self):
|
||||||
|
return "RTL-SDR device"
|
||||||
|
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return super().getInputs() + [
|
return super().getInputs() + [
|
||||||
TextInput(
|
TextInput(
|
||||||
|
@ -15,6 +15,9 @@ class RtlSdrSoapySource(SoapyConnectorSource):
|
|||||||
|
|
||||||
|
|
||||||
class RtlSdrSoapyDeviceDescription(SoapyConnectorDeviceDescription):
|
class RtlSdrSoapyDeviceDescription(SoapyConnectorDeviceDescription):
|
||||||
|
def getName(self):
|
||||||
|
return "RTL-SDR device (via SoapySDR)"
|
||||||
|
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return super().getInputs() + [BiasTeeInput(), DirectSamplingInput()]
|
return super().getInputs() + [BiasTeeInput(), DirectSamplingInput()]
|
||||||
|
|
||||||
|
@ -22,6 +22,9 @@ class RtlTcpSource(ConnectorSource):
|
|||||||
|
|
||||||
|
|
||||||
class RtlTcpDeviceDescription(ConnectorDeviceDescription):
|
class RtlTcpDeviceDescription(ConnectorDeviceDescription):
|
||||||
|
def getName(self):
|
||||||
|
return "RTL-SDR device (via rtl_tcp)"
|
||||||
|
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return super().getInputs() + [RemoteInput()]
|
return super().getInputs() + [RemoteInput()]
|
||||||
|
|
||||||
|
@ -37,6 +37,9 @@ class ProtocolOptions(DropdownEnum):
|
|||||||
|
|
||||||
|
|
||||||
class RundsDeviceDescription(ConnectorDeviceDescription):
|
class RundsDeviceDescription(ConnectorDeviceDescription):
|
||||||
|
def getName(self):
|
||||||
|
return "R&S device using EB200 or Ammos protocol"
|
||||||
|
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return super().getInputs() + [
|
return super().getInputs() + [
|
||||||
RemoteInput(),
|
RemoteInput(),
|
||||||
|
@ -7,5 +7,8 @@ class SddcSource(ConnectorSource):
|
|||||||
|
|
||||||
|
|
||||||
class SddcDeviceDescription(ConnectorDeviceDescription):
|
class SddcDeviceDescription(ConnectorDeviceDescription):
|
||||||
|
def getName(self):
|
||||||
|
return "BBRF103 / RX666 / RX888 device (libsddc)"
|
||||||
|
|
||||||
def hasAgc(self):
|
def hasAgc(self):
|
||||||
return False
|
return False
|
||||||
|
@ -33,6 +33,9 @@ class IfModeOptions(DropdownEnum):
|
|||||||
|
|
||||||
|
|
||||||
class SdrplayDeviceDescription(SoapyConnectorDeviceDescription):
|
class SdrplayDeviceDescription(SoapyConnectorDeviceDescription):
|
||||||
|
def getName(self):
|
||||||
|
return "SDRPlay device (RSP1, RSP2, RSPDuo, RSPDx)"
|
||||||
|
|
||||||
def getGainStages(self):
|
def getGainStages(self):
|
||||||
return ["RFGR", "IFGR"]
|
return ["RFGR", "IFGR"]
|
||||||
|
|
||||||
|
@ -21,6 +21,9 @@ class SoapyRemoteSource(SoapyConnectorSource):
|
|||||||
|
|
||||||
|
|
||||||
class SoapyRemoteDeviceDescription(SoapyConnectorDeviceDescription):
|
class SoapyRemoteDeviceDescription(SoapyConnectorDeviceDescription):
|
||||||
|
def getName(self):
|
||||||
|
return "Device connected to a SoapyRemote server"
|
||||||
|
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return super().getInputs() + [
|
return super().getInputs() + [
|
||||||
RemoteInput(),
|
RemoteInput(),
|
||||||
|
@ -7,4 +7,5 @@ class UhdSource(SoapyConnectorSource):
|
|||||||
|
|
||||||
|
|
||||||
class UhdDeviceDescription(SoapyConnectorDeviceDescription):
|
class UhdDeviceDescription(SoapyConnectorDeviceDescription):
|
||||||
pass
|
def getName(self):
|
||||||
|
return "Ettus Research USRP device"
|
||||||
|
Loading…
Reference in New Issue
Block a user