remove implicit optional handling for optional fields
This commit is contained in:
parent
436010ffe3
commit
d15d9d8c76
@ -32,7 +32,7 @@ class GainInput(Input):
|
||||
label=self.label,
|
||||
options=self.render_options(value),
|
||||
stageoption="" if self.gain_stages is None else self.render_stage_option(value),
|
||||
disabled="disabled" if self.disabled else ""
|
||||
disabled="disabled" if self.disabled else "",
|
||||
)
|
||||
|
||||
def render_options(self, value):
|
||||
@ -105,6 +105,8 @@ class GainInput(Input):
|
||||
|
||||
select_id = "{id}-select".format(id=self.id)
|
||||
if select_id in data:
|
||||
if data[select_id][0] == "auto":
|
||||
return {self.id: "auto"}
|
||||
if data[select_id][0] == "manual":
|
||||
input_id = "{id}-manual".format(id=self.id)
|
||||
value = 0.0
|
||||
@ -120,14 +122,12 @@ class GainInput(Input):
|
||||
settings_dict = [s for s in settings_dict if next(iter(s.values()))]
|
||||
return {self.id: SoapySettings.encode(settings_dict)}
|
||||
|
||||
return {self.id: None}
|
||||
return {}
|
||||
|
||||
|
||||
class BiasTeeInput(CheckboxInput):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
"bias_tee", "Enable Bias-Tee power supply", converter=OptionalConverter(defaultFormValue=False)
|
||||
)
|
||||
super().__init__("bias_tee", "Enable Bias-Tee power supply")
|
||||
|
||||
|
||||
class DirectSamplingOptions(DropdownEnum):
|
||||
@ -152,10 +152,6 @@ class DirectSamplingInput(DropdownInput):
|
||||
"direct_sampling",
|
||||
"Direct Sampling",
|
||||
DirectSamplingOptions,
|
||||
converter=OptionalConverter(
|
||||
EnumConverter(DirectSamplingOptions),
|
||||
defaultFormValue=DirectSamplingOptions.DIRECT_SAMPLING_OFF.name,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
@ -11,7 +11,7 @@ from owrx.command import CommandMapper
|
||||
from owrx.socket import getAvailablePort
|
||||
from owrx.property import PropertyStack, PropertyLayer
|
||||
from owrx.form import Input, TextInput, NumberInput, CheckboxInput
|
||||
from owrx.form.converter import IntConverter, OptionalConverter
|
||||
from owrx.form.converter import OptionalConverter
|
||||
from owrx.form.device import GainInput
|
||||
from owrx.controllers.settings import Section
|
||||
from typing import List
|
||||
@ -471,18 +471,15 @@ class SdrDeviceDescription(object):
|
||||
"ppm",
|
||||
"Frequency correction",
|
||||
append="ppm",
|
||||
converter=OptionalConverter(IntConverter(), defaultFormValue="0"),
|
||||
),
|
||||
CheckboxInput(
|
||||
"always-on",
|
||||
"Keep device running at all times",
|
||||
infotext="Prevents shutdown of the device when idle. Useful for devices with unreliable startup.",
|
||||
converter=OptionalConverter(defaultFormValue=False),
|
||||
),
|
||||
CheckboxInput(
|
||||
"services",
|
||||
"Run background services on this device",
|
||||
converter=OptionalConverter(defaultFormValue=True),
|
||||
),
|
||||
GainInput("rf_gain", "Device gain"),
|
||||
NumberInput(
|
||||
@ -491,10 +488,9 @@ class SdrDeviceDescription(object):
|
||||
append="Hz",
|
||||
infotext="Use this when the actual receiving frequency differs from the frequency to be tuned on the"
|
||||
+ " device. <br/> Formula: Center frequency + oscillator offset = sdr tune frequency",
|
||||
converter=OptionalConverter(),
|
||||
),
|
||||
NumberInput("waterfall_min_level", "Lowest waterfall level", append="dBFS", converter=OptionalConverter()),
|
||||
NumberInput("waterfall_max_level", "Highest waterfall level", append="dBFS", converter=OptionalConverter()),
|
||||
NumberInput("waterfall_min_level", "Lowest waterfall level", append="dBFS"),
|
||||
NumberInput("waterfall_max_level", "Highest waterfall level", append="dBFS"),
|
||||
# TODO `schedule`
|
||||
]
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
from owrx.source.soapy import SoapyConnectorSource, SoapyConnectorDeviceDescription
|
||||
from owrx.form import Input, CheckboxInput
|
||||
from owrx.form.device import BiasTeeInput
|
||||
from owrx.form.converter import OptionalConverter
|
||||
from typing import List
|
||||
|
||||
|
||||
@ -29,7 +28,6 @@ class AirspyDeviceDescription(SoapyConnectorDeviceDescription):
|
||||
"Enable bit-packing",
|
||||
infotext="Packs two 12-bit samples into 3 bytes."
|
||||
+ " Lowers USB bandwidth consumption, increases CPU load",
|
||||
converter=OptionalConverter(defaultFormValue=False),
|
||||
),
|
||||
]
|
||||
|
||||
|
@ -4,7 +4,6 @@ import socket
|
||||
from owrx.command import Flag, Option
|
||||
from typing import List
|
||||
from owrx.form import Input, NumberInput, CheckboxInput
|
||||
from owrx.form.converter import OptionalConverter, IntConverter
|
||||
|
||||
import logging
|
||||
|
||||
@ -83,13 +82,11 @@ class ConnectorDeviceDescription(SdrDeviceDescription):
|
||||
infotext="Activate an rtl_tcp compatible interface on the port number specified.<br />"
|
||||
+ "Note: Port is only available on the local machine, not on the network.<br />"
|
||||
+ "Note: IQ data may be degraded by the downsampling process to 8 bits.",
|
||||
converter=OptionalConverter(IntConverter()),
|
||||
),
|
||||
CheckboxInput(
|
||||
"iqswap",
|
||||
"Swap I and Q channels",
|
||||
infotext="Swapping inverts the spectrum, so this is useful in combination with an inverting mixer",
|
||||
converter=OptionalConverter(defaultFormValue=False),
|
||||
),
|
||||
]
|
||||
|
||||
|
@ -2,7 +2,6 @@ from owrx.source.connector import ConnectorSource, ConnectorDeviceDescription
|
||||
from owrx.command import Flag, Option
|
||||
from typing import List
|
||||
from owrx.form import Input, TextInput
|
||||
from owrx.form.converter import OptionalConverter
|
||||
from owrx.form.device import BiasTeeInput, DirectSamplingInput
|
||||
|
||||
|
||||
@ -23,10 +22,9 @@ class RtlSdrDeviceDescription(ConnectorDeviceDescription):
|
||||
"device",
|
||||
"Device identifier",
|
||||
infotext="Device serial number or index",
|
||||
converter=OptionalConverter(),
|
||||
),
|
||||
BiasTeeInput(),
|
||||
DirectSamplingInput()
|
||||
DirectSamplingInput(),
|
||||
]
|
||||
|
||||
def getOptionalKeys(self):
|
||||
|
@ -2,7 +2,6 @@ from owrx.source.connector import ConnectorSource, ConnectorDeviceDescription
|
||||
from owrx.command import Argument, Flag, Option
|
||||
from owrx.form import Input, DropdownInput, DropdownEnum, CheckboxInput
|
||||
from owrx.form.device import RemoteInput
|
||||
from owrx.form.converter import OptionalConverter
|
||||
from typing import List
|
||||
|
||||
|
||||
@ -42,10 +41,11 @@ class RundsDeviceDescription(ConnectorDeviceDescription):
|
||||
return super().getInputs() + [
|
||||
RemoteInput(),
|
||||
DropdownInput("protocol", "Protocol", ProtocolOptions),
|
||||
CheckboxInput(
|
||||
"long", "", "Use 32-bit sample size (LONG)", converter=OptionalConverter(defaultFormValue=False)
|
||||
),
|
||||
CheckboxInput("long", "Use 32-bit sample size (LONG)"),
|
||||
]
|
||||
|
||||
def getMandatoryKeys(self):
|
||||
return super().getMandatoryKeys() + ["device"]
|
||||
|
||||
def getOptionalKeys(self):
|
||||
return super().getOptionalKeys() + ["protocol", "long"]
|
||||
|
@ -1,7 +1,6 @@
|
||||
from owrx.source.soapy import SoapyConnectorSource, SoapyConnectorDeviceDescription
|
||||
from owrx.form import Input, CheckboxInput, DropdownInput, DropdownEnum
|
||||
from owrx.form.device import BiasTeeInput
|
||||
from owrx.form.converter import OptionalConverter, EnumConverter
|
||||
from typing import List
|
||||
|
||||
|
||||
@ -43,20 +42,15 @@ class SdrplayDeviceDescription(SoapyConnectorDeviceDescription):
|
||||
CheckboxInput(
|
||||
"rf_notch",
|
||||
"Enable RF notch filter",
|
||||
converter=OptionalConverter(defaultFormValue=True),
|
||||
),
|
||||
CheckboxInput(
|
||||
"dab_notch",
|
||||
"Enable DAB notch filter",
|
||||
converter=OptionalConverter(defaultFormValue=True),
|
||||
),
|
||||
DropdownInput(
|
||||
"if_mode",
|
||||
"IF Mode",
|
||||
IfModeOptions,
|
||||
converter=OptionalConverter(
|
||||
EnumConverter(IfModeOptions), defaultFormValue=IfModeOptions.IFMODE_ZERO_IF.name
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
|
@ -3,7 +3,6 @@ from owrx.command import Option
|
||||
from owrx.source.connector import ConnectorSource, ConnectorDeviceDescription
|
||||
from typing import List
|
||||
from owrx.form import Input, TextInput
|
||||
from owrx.form.converter import OptionalConverter
|
||||
from owrx.form.device import GainInput
|
||||
from owrx.soapy import SoapySettings
|
||||
|
||||
@ -89,18 +88,13 @@ class SoapyConnectorDeviceDescription(ConnectorDeviceDescription):
|
||||
"device",
|
||||
"Device Identifier",
|
||||
infotext='SoapySDR device identifier string (example: "serial=123456789")',
|
||||
converter=OptionalConverter()
|
||||
),
|
||||
GainInput(
|
||||
"rf_gain",
|
||||
"Device Gain",
|
||||
gain_stages=self.getGainStages(),
|
||||
),
|
||||
TextInput(
|
||||
"antenna",
|
||||
"Antenna",
|
||||
converter=OptionalConverter(),
|
||||
),
|
||||
TextInput("antenna", "Antenna"),
|
||||
]
|
||||
|
||||
def getOptionalKeys(self):
|
||||
|
Loading…
Reference in New Issue
Block a user