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]:
|
2021-02-21 23:35:47 +00:00
|
|
|
return super().getInputs() + [
|
|
|
|
RemoteInput(),
|
|
|
|
DropdownInput("protocol", "Protocol", ProtocolOptions),
|
2021-02-22 23:27:29 +00:00
|
|
|
CheckboxInput("long", "Use 32-bit sample size (LONG)"),
|
2021-02-21 23:35:47 +00:00
|
|
|
]
|
|
|
|
|
2021-03-24 22:17:50 +00:00
|
|
|
def getDeviceMandatoryKeys(self):
|
2021-04-02 19:44:51 +00:00
|
|
|
return super().getDeviceMandatoryKeys() + ["remote"]
|
2021-02-22 23:27:29 +00:00
|
|
|
|
2021-03-24 22:17:50 +00:00
|
|
|
def getDeviceOptionalKeys(self):
|
|
|
|
return super().getDeviceOptionalKeys() + ["protocol", "long"]
|