parser typing
This commit is contained in:
parent
757ec01ea4
commit
25e2a8013e
@ -1,5 +1,5 @@
|
|||||||
from csdr.chain.demodulator import ServiceDemodulator, SecondaryDemodulator, DialFrequencyReceiver, SecondarySelectorChain
|
from csdr.chain.demodulator import ServiceDemodulator, SecondaryDemodulator, DialFrequencyReceiver, SecondarySelectorChain
|
||||||
from owrx.audio.chopper import AudioChopper
|
from owrx.audio.chopper import AudioChopper, AudioChopperParser
|
||||||
from owrx.aprs.kiss import KissDeframer
|
from owrx.aprs.kiss import KissDeframer
|
||||||
from owrx.aprs import Ax25Parser, AprsParser
|
from owrx.aprs import Ax25Parser, AprsParser
|
||||||
from pycsdr.modules import Convert, FmDemod, Agc, TimingRecovery, DBPskDecoder, VaricodeDecoder
|
from pycsdr.modules import Convert, FmDemod, Agc, TimingRecovery, DBPskDecoder, VaricodeDecoder
|
||||||
@ -10,8 +10,7 @@ from owrx.pocsag import PocsagParser
|
|||||||
|
|
||||||
|
|
||||||
class AudioChopperDemodulator(ServiceDemodulator, DialFrequencyReceiver):
|
class AudioChopperDemodulator(ServiceDemodulator, DialFrequencyReceiver):
|
||||||
# TODO parser typing
|
def __init__(self, mode: str, parser: AudioChopperParser):
|
||||||
def __init__(self, mode: str, parser):
|
|
||||||
self.chopper = AudioChopper(mode, parser)
|
self.chopper = AudioChopper(mode, parser)
|
||||||
workers = [Convert(Format.FLOAT, Format.SHORT), self.chopper]
|
workers = [Convert(Format.FLOAT, Format.SHORT), self.chopper]
|
||||||
super().__init__(workers)
|
super().__init__(workers)
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
from owrx.modes import Modes, AudioChopperMode
|
from owrx.modes import Modes, AudioChopperMode
|
||||||
|
from owrx.audio import AudioChopperProfile
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
from owrx.audio import ProfileSourceSubscriber
|
from owrx.audio import ProfileSourceSubscriber
|
||||||
from owrx.audio.wav import AudioWriter
|
from owrx.audio.wav import AudioWriter
|
||||||
from owrx.audio.queue import QueueJob
|
from owrx.audio.queue import QueueJob
|
||||||
from csdr.module import ThreadModule
|
from csdr.module import ThreadModule
|
||||||
from pycsdr.types import Format
|
from pycsdr.types import Format
|
||||||
|
from abc import ABC, abstractmethod
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
@ -13,9 +15,14 @@ logger = logging.getLogger(__name__)
|
|||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
|
|
||||||
|
class AudioChopperParser(ABC):
|
||||||
|
@abstractmethod
|
||||||
|
def parse(self, profile: AudioChopperProfile, frequency: int, line: bytes):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class AudioChopper(ThreadModule, ProfileSourceSubscriber):
|
class AudioChopper(ThreadModule, ProfileSourceSubscriber):
|
||||||
# TODO parser typing
|
def __init__(self, mode_str: str, parser: AudioChopperParser):
|
||||||
def __init__(self, mode_str: str, parser):
|
|
||||||
self.parser = parser
|
self.parser = parser
|
||||||
self.dialFrequency = None
|
self.dialFrequency = None
|
||||||
self.doRun = True
|
self.doRun = True
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from owrx.audio import AudioChopperProfile, ConfigWiredProfileSource
|
from owrx.audio import AudioChopperProfile, ConfigWiredProfileSource
|
||||||
|
from owrx.audio.chopper import AudioChopperParser
|
||||||
import re
|
import re
|
||||||
from js8py import Js8
|
from js8py import Js8
|
||||||
from js8py.frames import Js8FrameHeartbeat, Js8FrameCompound
|
from js8py.frames import Js8FrameHeartbeat, Js8FrameCompound
|
||||||
@ -81,10 +82,10 @@ class Js8TurboProfile(Js8Profile):
|
|||||||
return "C"
|
return "C"
|
||||||
|
|
||||||
|
|
||||||
class Js8Parser:
|
class Js8Parser(AudioChopperParser):
|
||||||
decoderRegex = re.compile(" ?<Decode(Started|Debug|Finished)>")
|
decoderRegex = re.compile(" ?<Decode(Started|Debug|Finished)>")
|
||||||
|
|
||||||
def parse(self, profile, freq, raw_msg):
|
def parse(self, profile: AudioChopperProfile, freq: int, raw_msg: bytes):
|
||||||
try:
|
try:
|
||||||
band = None
|
band = None
|
||||||
if freq is not None:
|
if freq is not None:
|
||||||
|
@ -4,6 +4,7 @@ from owrx.map import Map, LocatorLocation
|
|||||||
from owrx.metrics import Metrics, CounterMetric
|
from owrx.metrics import Metrics, CounterMetric
|
||||||
from owrx.reporting import ReportingEngine
|
from owrx.reporting import ReportingEngine
|
||||||
from owrx.audio import AudioChopperProfile, StaticProfileSource, ConfigWiredProfileSource
|
from owrx.audio import AudioChopperProfile, StaticProfileSource, ConfigWiredProfileSource
|
||||||
|
from owrx.audio.chopper import AudioChopperParser
|
||||||
from abc import ABC, ABCMeta, abstractmethod
|
from abc import ABC, ABCMeta, abstractmethod
|
||||||
from owrx.config import Config
|
from owrx.config import Config
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
@ -244,8 +245,8 @@ class Q65Profile(WsjtProfile):
|
|||||||
return ["jt9", "--q65", "-p", str(self.interval), "-b", self.mode.name, "-d", str(self.decoding_depth()), file]
|
return ["jt9", "--q65", "-p", str(self.interval), "-b", self.mode.name, "-d", str(self.decoding_depth()), file]
|
||||||
|
|
||||||
|
|
||||||
class WsjtParser:
|
class WsjtParser(AudioChopperParser):
|
||||||
def parse(self, profile, freq, raw_msg):
|
def parse(self, profile: WsjtProfile, freq: int, raw_msg: bytes):
|
||||||
try:
|
try:
|
||||||
band = None
|
band = None
|
||||||
if freq is not None:
|
if freq is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user