2020-04-26 13:17:03 +00:00
|
|
|
from owrx.feature import FeatureDetector
|
|
|
|
from functools import reduce
|
|
|
|
|
|
|
|
|
2020-04-26 16:45:41 +00:00
|
|
|
class Bandpass(object):
|
|
|
|
def __init__(self, low_cut, high_cut):
|
|
|
|
self.low_cut = low_cut
|
|
|
|
self.high_cut = high_cut
|
|
|
|
|
|
|
|
|
2020-04-26 13:17:03 +00:00
|
|
|
class Mode(object):
|
2020-05-03 17:55:48 +00:00
|
|
|
def __init__(self, modulation, name, bandpass: Bandpass = None, requirements=None, service=False, squelch=True):
|
2020-04-26 13:17:03 +00:00
|
|
|
self.modulation = modulation
|
|
|
|
self.name = name
|
|
|
|
self.requirements = requirements if requirements is not None else []
|
|
|
|
self.service = service
|
2020-04-26 16:45:41 +00:00
|
|
|
self.bandpass = bandpass
|
2020-05-03 17:55:48 +00:00
|
|
|
self.squelch = squelch
|
2020-04-26 13:17:03 +00:00
|
|
|
|
|
|
|
def is_available(self):
|
|
|
|
fd = FeatureDetector()
|
2020-05-03 17:55:48 +00:00
|
|
|
return reduce(lambda a, b: a and b, [fd.is_available(r) for r in self.requirements], True)
|
2020-04-26 13:17:03 +00:00
|
|
|
|
|
|
|
def is_service(self):
|
|
|
|
return self.service
|
|
|
|
|
|
|
|
|
2020-04-26 16:45:41 +00:00
|
|
|
class AnalogMode(Mode):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class DigitalMode(Mode):
|
2020-05-03 17:55:48 +00:00
|
|
|
def __init__(
|
|
|
|
self, modulation, name, underlying, bandpass: Bandpass = None, requirements=None, service=False, squelch=True
|
|
|
|
):
|
|
|
|
super().__init__(modulation, name, bandpass, requirements, service, squelch)
|
2020-04-26 16:45:41 +00:00
|
|
|
self.underlying = underlying
|
|
|
|
|
|
|
|
|
2020-04-26 13:17:03 +00:00
|
|
|
class Modes(object):
|
|
|
|
mappings = [
|
2020-04-26 16:45:41 +00:00
|
|
|
AnalogMode("nfm", "FM", bandpass=Bandpass(-4000, 4000)),
|
2020-08-08 20:04:28 +00:00
|
|
|
AnalogMode("wfm", "WFM", bandpass=Bandpass(-50000, 50000)),
|
2020-04-26 16:45:41 +00:00
|
|
|
AnalogMode("am", "AM", bandpass=Bandpass(-4000, 4000)),
|
|
|
|
AnalogMode("lsb", "LSB", bandpass=Bandpass(-3000, -300)),
|
|
|
|
AnalogMode("usb", "USB", bandpass=Bandpass(300, 3000)),
|
|
|
|
AnalogMode("cw", "CW", bandpass=Bandpass(700, 900)),
|
2020-05-03 17:55:48 +00:00
|
|
|
AnalogMode("dmr", "DMR", bandpass=Bandpass(-4000, 4000), requirements=["digital_voice_digiham"], squelch=False),
|
2020-08-12 19:41:06 +00:00
|
|
|
AnalogMode("dstar", "D-Star", bandpass=Bandpass(-3250, 3250), requirements=["digital_voice_dsd"], squelch=False),
|
2020-05-03 17:55:48 +00:00
|
|
|
AnalogMode("nxdn", "NXDN", bandpass=Bandpass(-3250, 3250), requirements=["digital_voice_dsd"], squelch=False),
|
|
|
|
AnalogMode("ysf", "YSF", bandpass=Bandpass(-4000, 4000), requirements=["digital_voice_digiham"], squelch=False),
|
2020-08-12 19:41:06 +00:00
|
|
|
AnalogMode("freedv", "FreeDV", bandpass=Bandpass(300, 3000), requirements=["digital_voice_freedv"], squelch=False),
|
2020-04-26 16:45:41 +00:00
|
|
|
DigitalMode("bpsk31", "BPSK31", underlying=["usb"]),
|
|
|
|
DigitalMode("bpsk63", "BPSK63", underlying=["usb"]),
|
|
|
|
DigitalMode("ft8", "FT8", underlying=["usb"], requirements=["wsjt-x"], service=True),
|
|
|
|
DigitalMode("ft4", "FT4", underlying=["usb"], requirements=["wsjt-x"], service=True),
|
|
|
|
DigitalMode("jt65", "JT65", underlying=["usb"], requirements=["wsjt-x"], service=True),
|
|
|
|
DigitalMode("jt9", "JT9", underlying=["usb"], requirements=["wsjt-x"], service=True),
|
2020-05-03 17:55:48 +00:00
|
|
|
DigitalMode(
|
|
|
|
"wspr", "WSPR", underlying=["usb"], bandpass=Bandpass(1350, 1650), requirements=["wsjt-x"], service=True
|
|
|
|
),
|
2020-04-26 16:45:41 +00:00
|
|
|
DigitalMode("js8", "JS8Call", underlying=["usb"], requirements=["js8call"], service=True),
|
2020-05-03 17:55:48 +00:00
|
|
|
DigitalMode(
|
|
|
|
"packet", "Packet", underlying=["nfm", "usb", "lsb"], requirements=["packet"], service=True, squelch=False
|
|
|
|
),
|
|
|
|
DigitalMode(
|
|
|
|
"pocsag",
|
|
|
|
"Pocsag",
|
|
|
|
underlying=["nfm"],
|
|
|
|
bandpass=Bandpass(-6000, 6000),
|
|
|
|
requirements=["pocsag"],
|
|
|
|
squelch=False,
|
|
|
|
),
|
2020-04-26 13:17:03 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def getModes():
|
|
|
|
return Modes.mappings
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def getAvailableModes():
|
|
|
|
return [m for m in Modes.getModes() if m.is_available()]
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def getAvailableServices():
|
|
|
|
return [m for m in Modes.getAvailableModes() if m.is_service()]
|
2020-04-26 20:46:30 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def findByModulation(modulation):
|
|
|
|
modes = [m for m in Modes.getAvailableModes() if m.modulation == modulation]
|
|
|
|
if modes:
|
2020-05-03 17:55:48 +00:00
|
|
|
return modes[0]
|