From 4e67be8a3c92ccffe77ac8d31ac341de62da6123 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Thu, 23 Apr 2020 23:30:56 +0200 Subject: [PATCH] dynamic profiles --- config_webrx.py | 3 +++ csdr/csdr.py | 4 ++-- owrx/js8.py | 20 +++++++++++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/config_webrx.py b/config_webrx.py index f9ad9bc..1829211 100644 --- a/config_webrx.py +++ b/config_webrx.py @@ -301,6 +301,9 @@ wsjt_decoding_depth = 3 # jt65 seems to be somewhat prone to erroneous decodes, this setting handles that to some extent wsjt_decoding_depths = {"jt65": 1} +# JS8 comes in different speeds: normal, slow, fast, turbo. This setting controls which ones are enabled. +js8_enabled_profiles = ["normal", "slow"] + temporary_directory = "/tmp" services_enabled = False diff --git a/csdr/csdr.py b/csdr/csdr.py index 611ab19..76c4876 100644 --- a/csdr/csdr.py +++ b/csdr/csdr.py @@ -30,7 +30,7 @@ from functools import partial from owrx.kiss import KissClient, DirewolfConfig from owrx.wsjt import Ft8Profile, WsprProfile, Jt9Profile, Jt65Profile, Ft4Profile -from owrx.js8 import Js8NormalProfile, Js8SlowProfile, Js8FastProfile, Js8TurboProfile +from owrx.js8 import Js8Profiles from owrx.audio import AudioChopper import logging @@ -464,7 +464,7 @@ class dsp(object): elif smd == "ft4": chopper_profiles = [Ft4Profile()] elif smd == "js8": - chopper_profiles = [Js8NormalProfile(), Js8SlowProfile(), Js8FastProfile(), Js8TurboProfile()] + chopper_profiles = Js8Profiles.getEnabledProfiles() output_name = "js8_demod" if chopper_profiles is not None: chopper = AudioChopper(self, self.secondary_process_demod.stdout, *chopper_profiles) diff --git a/owrx/js8.py b/owrx/js8.py index 859c1d0..8b41ce2 100644 --- a/owrx/js8.py +++ b/owrx/js8.py @@ -3,9 +3,10 @@ from .parser import Parser import re from js8py import Js8 from js8py.frames import Js8FrameHeartbeat, Js8FrameCompound -from owrx.map import Map, LocatorLocation -from owrx.pskreporter import PskReporter -from owrx.metrics import Metrics, CounterMetric +from .map import Map, LocatorLocation +from .pskreporter import PskReporter +from .metrics import Metrics, CounterMetric +from .config import Config from abc import ABCMeta, abstractmethod import logging @@ -13,6 +14,19 @@ import logging logger = logging.getLogger(__name__) +class Js8Profiles(object): + @staticmethod + def getEnabledProfiles(): + config = Config.get() + profiles = config["js8_enabled_profiles"] if "js8_enabled_profiles" in config else [] + return [Js8Profiles.loadProfile(p) for p in profiles] + + @staticmethod + def loadProfile(profileName): + className = "Js8{0}Profile".format(profileName[0].upper() + profileName[1:].lower()) + return globals()[className]() + + class Js8Profile(AudioChopperProfile, metaclass=ABCMeta): def getFileTimestampFormat(self): return "%y%m%d_%H%M%S"