add aprs_igate_symbol

This commit is contained in:
Jakob Ketterl 2021-02-08 00:43:39 +01:00
parent 23fceb2998
commit 4758672c94
2 changed files with 43 additions and 2 deletions

View File

@ -17,6 +17,8 @@ from owrx.form import (
WfmTauConverter, WfmTauConverter,
MultiCheckboxInput, MultiCheckboxInput,
OptionalConverter, OptionalConverter,
AprsBeaconSymbols,
EnumConverter,
) )
from urllib.parse import quote from urllib.parse import quote
from owrx.wsjt import Fst4Profile, Fst4wProfile from owrx.wsjt import Fst4Profile, Fst4wProfile
@ -268,9 +270,14 @@ class GeneralSettingsController(AdminController):
"aprs_igate_beacon", "aprs_igate_beacon",
"APRS beacon", "APRS beacon",
checkboxText="Send the receiver position to the APRS-IS network", checkboxText="Send the receiver position to the APRS-IS network",
infotext="Please check that your receiver location is setup correctly", infotext="Please check that your receiver location is setup correctly before enabling the beacon",
),
DropdownInput(
"aprs_igate_symbol",
"APRS beacon symbol",
[o.toOption() for o in AprsBeaconSymbols],
converter=EnumConverter(AprsBeaconSymbols),
), ),
# TODO: aprs_igate_symbol
TextInput( TextInput(
"aprs_igate_comment", "aprs_igate_comment",
"APRS beacon text", "APRS beacon text",

View File

@ -325,9 +325,43 @@ class WfmTauValues(Enum):
return Option(self.name, str(self)) return Option(self.name, str(self))
class EnumConverter(Converter):
def __init__(self, enumCls):
self.enumCls = enumCls
def convert_to_form(self, value):
return None if value is None else self.enumCls(value).name
def convert_from_form(self, value):
return self.enumCls[value].value
class WfmTauConverter(Converter): class WfmTauConverter(Converter):
def convert_to_form(self, value): def convert_to_form(self, value):
return WfmTauValues(value * 1e6).name return WfmTauValues(value * 1e6).name
def convert_from_form(self, value): def convert_from_form(self, value):
return WfmTauValues[value].value / 1e6 return WfmTauValues[value].value / 1e6
class AprsBeaconSymbols(Enum):
BEACON_RECEIVE_ONLY = ("R&", "Receive only IGate")
BEACON_HF_GATEWAY = ("/&", "HF Gateway")
BEACON_IGATE_GENERIC = ("I&", "Igate Generic (please use more specific overlay)")
BEACON_PSKMAIL = ("P&", "PSKmail node")
BEACON_TX_1 = ("T&", "TX IGate with path set to 1 hop")
BEACON_WIRES_X = ("W&", "Wires-X")
BEACON_TX_2 = ("2&", "TX IGate with path set to 2 hops")
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
def toOption(self):
return Option(self.name, "{description} ({symbol})".format(description=str(self), symbol=self.value))