openwebrx-clone/owrx/source/runds.py

52 lines
1.5 KiB
Python
Raw Normal View History

2021-02-20 17:09:24 +00:00
from owrx.source.connector import ConnectorSource, ConnectorDeviceDescription
2021-02-03 02:21:09 +00:00
from owrx.command import Argument, Flag, Option
2021-02-20 18:20:31 +00:00
from owrx.form import Input, DropdownInput, DropdownEnum, CheckboxInput
from owrx.form.device import RemoteInput
from typing import List
2020-11-29 23:34:44 +00:00
2021-02-03 02:21:09 +00:00
class RundsSource(ConnectorSource):
2020-11-29 23:34:44 +00:00
def getCommandMapper(self):
return (
super()
.getCommandMapper()
2021-02-03 02:21:09 +00:00
.setBase("runds_connector")
2021-01-20 16:01:46 +00:00
.setMappings(
{
"long": Flag("-l"),
"remote": Argument(),
2021-02-03 02:21:09 +00:00
"protocol": Option("-m"),
2021-01-20 16:01:46 +00:00
}
)
2020-11-29 23:34:44 +00:00
)
2021-02-20 17:09:24 +00:00
2021-02-20 18:20:31 +00:00
class ProtocolOptions(DropdownEnum):
PROTOCOL_EB200 = ("eb200", "EB200 protocol")
PROTOCOL_AMMOS = ("ammos", "Ammos protocol")
def __new__(cls, *args, **kwargs):
value, description = args
obj = object.__new__(cls)
obj._value_ = value
obj.description = description
return obj
def __str__(self):
return self.description
2021-02-20 17:09:24 +00:00
class RundsDeviceDescription(ConnectorDeviceDescription):
2021-02-20 18:20:31 +00:00
def getInputs(self) -> List[Input]:
return super().getInputs() + [
RemoteInput(),
DropdownInput("protocol", "Protocol", ProtocolOptions),
CheckboxInput("long", "Use 32-bit sample size (LONG)"),
]
def getMandatoryKeys(self):
return super().getMandatoryKeys() + ["device"]
def getOptionalKeys(self):
return super().getOptionalKeys() + ["protocol", "long"]