introduce the basic concept of optional keys
This commit is contained in:
parent
683a711b49
commit
770fd749cd
@ -71,7 +71,7 @@ class SdrDeviceController(SettingsFormController):
|
|||||||
def getSections(self):
|
def getSections(self):
|
||||||
try:
|
try:
|
||||||
description = SdrDeviceDescription.getByType(self.device["type"])
|
description = SdrDeviceDescription.getByType(self.device["type"])
|
||||||
return [description.getSection()]
|
return [description.getSection(self.device)]
|
||||||
except SdrDeviceDescriptionMissing:
|
except SdrDeviceDescriptionMissing:
|
||||||
# TODO provide a generic interface that allows to switch the type
|
# TODO provide a generic interface that allows to switch the type
|
||||||
return []
|
return []
|
||||||
|
@ -376,6 +376,9 @@ class SdrDeviceDescriptionMissing(Exception):
|
|||||||
|
|
||||||
|
|
||||||
class SdrDeviceDescription(object):
|
class SdrDeviceDescription(object):
|
||||||
|
def __init__(self):
|
||||||
|
self.indexedInputs = {input.id: input for input in self.getInputs()}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getByType(sdr_type: str) -> "SdrDeviceDescription":
|
def getByType(sdr_type: str) -> "SdrDeviceDescription":
|
||||||
try:
|
try:
|
||||||
@ -423,10 +426,14 @@ class SdrDeviceDescription(object):
|
|||||||
# TODO `schedule`
|
# TODO `schedule`
|
||||||
]
|
]
|
||||||
|
|
||||||
def mergeInputs(self, *args):
|
def getMandatoryKeys(self):
|
||||||
# build a dictionary indexed by the input id to make sure every id only exists once
|
return ["name", "enabled"]
|
||||||
inputs = {input.id: input for input_list in args for input in input_list}
|
|
||||||
return inputs.values()
|
|
||||||
|
|
||||||
def getSection(self):
|
def getOptionalKeys(self):
|
||||||
return Section("Device settings", *self.getInputs())
|
return ["ppm", "always-on", "services", "rf_gain", "lfo_offset", "waterfall_min_level", "waterfall_max_level"]
|
||||||
|
|
||||||
|
def getSection(self, data):
|
||||||
|
visible_keys = set(self.getMandatoryKeys() + [k for k in self.getOptionalKeys() if k in data])
|
||||||
|
inputs = [input for k, input in self.indexedInputs.items() if k in visible_keys]
|
||||||
|
# TODO: render remaining keys in optional area
|
||||||
|
return Section("Device settings", *inputs)
|
||||||
|
@ -22,9 +22,7 @@ class AirspySource(SoapyConnectorSource):
|
|||||||
|
|
||||||
class AirspyDeviceDescription(SoapyConnectorDeviceDescription):
|
class AirspyDeviceDescription(SoapyConnectorDeviceDescription):
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return self.mergeInputs(
|
return super().getInputs() + [
|
||||||
super().getInputs(),
|
|
||||||
[
|
|
||||||
BiasTeeInput(),
|
BiasTeeInput(),
|
||||||
CheckboxInput(
|
CheckboxInput(
|
||||||
"bitpack",
|
"bitpack",
|
||||||
@ -34,5 +32,11 @@ class AirspyDeviceDescription(SoapyConnectorDeviceDescription):
|
|||||||
+ " Lowers USB bandwidth consumption, increases CPU load",
|
+ " Lowers USB bandwidth consumption, increases CPU load",
|
||||||
converter=OptionalConverter(defaultFormValue=False),
|
converter=OptionalConverter(defaultFormValue=False),
|
||||||
),
|
),
|
||||||
],
|
]
|
||||||
)
|
|
||||||
|
def getOptionalKeys(self):
|
||||||
|
return super().getOptionalKeys() + ["bias_tee", "bitpack"]
|
||||||
|
|
||||||
|
# TODO: find actual gain stages for airspay
|
||||||
|
# def getGainStages(self):
|
||||||
|
# return None
|
||||||
|
@ -76,9 +76,7 @@ class ConnectorSource(SdrSource):
|
|||||||
|
|
||||||
class ConnectorDeviceDescription(SdrDeviceDescription):
|
class ConnectorDeviceDescription(SdrDeviceDescription):
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return self.mergeInputs(
|
return super().getInputs() + [
|
||||||
super().getInputs(),
|
|
||||||
[
|
|
||||||
NumberInput(
|
NumberInput(
|
||||||
"rtltcp_compat",
|
"rtltcp_compat",
|
||||||
"Port for rtl_tcp compatible data",
|
"Port for rtl_tcp compatible data",
|
||||||
@ -94,5 +92,7 @@ class ConnectorDeviceDescription(SdrDeviceDescription):
|
|||||||
infotext="Swapping inverts the spectrum, so this is useful in combination with an inverting mixer",
|
infotext="Swapping inverts the spectrum, so this is useful in combination with an inverting mixer",
|
||||||
converter=OptionalConverter(defaultFormValue=False),
|
converter=OptionalConverter(defaultFormValue=False),
|
||||||
),
|
),
|
||||||
],
|
]
|
||||||
)
|
|
||||||
|
def getOptionalKeys(self):
|
||||||
|
return super().getOptionalKeys() + ["rtltcp_compat", "iqswap"]
|
||||||
|
@ -16,4 +16,11 @@ class HackrfSource(SoapyConnectorSource):
|
|||||||
|
|
||||||
class HackrfDeviceDescription(SoapyConnectorDeviceDescription):
|
class HackrfDeviceDescription(SoapyConnectorDeviceDescription):
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return self.mergeInputs(super().getInputs(), [BiasTeeInput()])
|
return super().getInputs() + [BiasTeeInput()]
|
||||||
|
|
||||||
|
def getOptionalKeys(self):
|
||||||
|
return super().getOptionalKeys() + ["bias_tee"]
|
||||||
|
|
||||||
|
# TODO: find actual gain stages for hackrf
|
||||||
|
# def getGainStages(self):
|
||||||
|
# return None
|
||||||
|
@ -18,9 +18,7 @@ class RtlSdrSource(ConnectorSource):
|
|||||||
|
|
||||||
class RtlSdrDeviceDescription(ConnectorDeviceDescription):
|
class RtlSdrDeviceDescription(ConnectorDeviceDescription):
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return self.mergeInputs(
|
return super().getInputs() + [
|
||||||
super().getInputs(),
|
|
||||||
[
|
|
||||||
TextInput(
|
TextInput(
|
||||||
"device",
|
"device",
|
||||||
"Device identifier",
|
"Device identifier",
|
||||||
@ -29,5 +27,7 @@ class RtlSdrDeviceDescription(ConnectorDeviceDescription):
|
|||||||
),
|
),
|
||||||
BiasTeeInput(),
|
BiasTeeInput(),
|
||||||
DirectSamplingInput()
|
DirectSamplingInput()
|
||||||
],
|
]
|
||||||
)
|
|
||||||
|
def getOptionalKeys(self):
|
||||||
|
return super().getOptionalKeys() + ["device", "bias_tee", "direct_sampling"]
|
||||||
|
@ -16,4 +16,7 @@ class RtlSdrSoapySource(SoapyConnectorSource):
|
|||||||
|
|
||||||
class RtlSdrSoapyDeviceDescription(SoapyConnectorDeviceDescription):
|
class RtlSdrSoapyDeviceDescription(SoapyConnectorDeviceDescription):
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return self.mergeInputs(super().getInputs(), [BiasTeeInput(), DirectSamplingInput()])
|
return super().getInputs() + [BiasTeeInput(), DirectSamplingInput()]
|
||||||
|
|
||||||
|
def getOptionalKeys(self):
|
||||||
|
return super().getOptionalKeys() + ["bias_tee", "direct_sampling"]
|
||||||
|
@ -23,4 +23,7 @@ class RtlTcpSource(ConnectorSource):
|
|||||||
|
|
||||||
class RtlTcpDeviceDescription(ConnectorDeviceDescription):
|
class RtlTcpDeviceDescription(ConnectorDeviceDescription):
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return self.mergeInputs(super().getInputs(), [RemoteInput()])
|
return super().getInputs() + [RemoteInput()]
|
||||||
|
|
||||||
|
def getMandatoryKeys(self):
|
||||||
|
return super().getMandatoryKeys() + ["device"]
|
||||||
|
@ -39,13 +39,13 @@ class ProtocolOptions(DropdownEnum):
|
|||||||
|
|
||||||
class RundsDeviceDescription(ConnectorDeviceDescription):
|
class RundsDeviceDescription(ConnectorDeviceDescription):
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return self.mergeInputs(
|
return super().getInputs() + [
|
||||||
super().getInputs(),
|
|
||||||
[
|
|
||||||
RemoteInput(),
|
RemoteInput(),
|
||||||
DropdownInput("protocol", "Protocol", ProtocolOptions),
|
DropdownInput("protocol", "Protocol", ProtocolOptions),
|
||||||
CheckboxInput(
|
CheckboxInput(
|
||||||
"long", "", "Use 32-bit sample size (LONG)", converter=OptionalConverter(defaultFormValue=False)
|
"long", "", "Use 32-bit sample size (LONG)", converter=OptionalConverter(defaultFormValue=False)
|
||||||
),
|
),
|
||||||
],
|
]
|
||||||
)
|
|
||||||
|
def getMandatoryKeys(self):
|
||||||
|
return super().getMandatoryKeys() + ["device"]
|
||||||
|
@ -38,9 +38,7 @@ class SdrplayDeviceDescription(SoapyConnectorDeviceDescription):
|
|||||||
return ["RFGR", "IFGR"]
|
return ["RFGR", "IFGR"]
|
||||||
|
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return self.mergeInputs(
|
return super().getInputs() + [
|
||||||
super().getInputs(),
|
|
||||||
[
|
|
||||||
BiasTeeInput(),
|
BiasTeeInput(),
|
||||||
CheckboxInput(
|
CheckboxInput(
|
||||||
"rf_notch",
|
"rf_notch",
|
||||||
@ -62,5 +60,7 @@ class SdrplayDeviceDescription(SoapyConnectorDeviceDescription):
|
|||||||
EnumConverter(IfModeOptions), defaultFormValue=IfModeOptions.IFMODE_ZERO_IF.name
|
EnumConverter(IfModeOptions), defaultFormValue=IfModeOptions.IFMODE_ZERO_IF.name
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
]
|
||||||
)
|
|
||||||
|
def getOptionalKeys(self):
|
||||||
|
return super().getOptionalKeys() + ["bias_tee", "rf_notch", "dab_notch", "if_mode"]
|
||||||
|
@ -84,9 +84,7 @@ class SoapyConnectorSource(ConnectorSource, metaclass=ABCMeta):
|
|||||||
|
|
||||||
class SoapyConnectorDeviceDescription(ConnectorDeviceDescription):
|
class SoapyConnectorDeviceDescription(ConnectorDeviceDescription):
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return self.mergeInputs(
|
return super().getInputs() + [
|
||||||
super().getInputs(),
|
|
||||||
[
|
|
||||||
TextInput(
|
TextInput(
|
||||||
"device",
|
"device",
|
||||||
"Device Identifier",
|
"Device Identifier",
|
||||||
@ -103,8 +101,10 @@ class SoapyConnectorDeviceDescription(ConnectorDeviceDescription):
|
|||||||
"Antenna",
|
"Antenna",
|
||||||
converter=OptionalConverter(),
|
converter=OptionalConverter(),
|
||||||
),
|
),
|
||||||
],
|
]
|
||||||
)
|
|
||||||
|
def getOptionalKeys(self):
|
||||||
|
return super().getOptionalKeys() + ["device", "rf_gain", "antenna"]
|
||||||
|
|
||||||
def getGainStages(self):
|
def getGainStages(self):
|
||||||
return None
|
return None
|
||||||
|
@ -22,12 +22,12 @@ class SoapyRemoteSource(SoapyConnectorSource):
|
|||||||
|
|
||||||
class SoapyRemoteDeviceDescription(SoapyConnectorDeviceDescription):
|
class SoapyRemoteDeviceDescription(SoapyConnectorDeviceDescription):
|
||||||
def getInputs(self) -> List[Input]:
|
def getInputs(self) -> List[Input]:
|
||||||
return self.mergeInputs(
|
return super().getInputs() + [
|
||||||
super().getInputs(),
|
|
||||||
[
|
|
||||||
RemoteInput(),
|
RemoteInput(),
|
||||||
TextInput(
|
TextInput(
|
||||||
"remote_driver", "Remote driver", infotext="SoapySDR driver to be used on the remote SoapySDRServer"
|
"remote_driver", "Remote driver", infotext="SoapySDR driver to be used on the remote SoapySDRServer"
|
||||||
),
|
),
|
||||||
],
|
]
|
||||||
)
|
|
||||||
|
def getOptionalKeys(self):
|
||||||
|
return super().getOptionalKeys() + ["remote_driver"]
|
||||||
|
Loading…
Reference in New Issue
Block a user