add metrics for pocsag
This commit is contained in:
parent
66dd4b4581
commit
8cce5bd889
@ -45,13 +45,14 @@ class PacketDemodulator(ServiceDemodulator, DialFrequencyReceiver):
|
|||||||
self.parser.setDialFrequency(frequency)
|
self.parser.setDialFrequency(frequency)
|
||||||
|
|
||||||
|
|
||||||
class PocsagDemodulator(ServiceDemodulator):
|
class PocsagDemodulator(ServiceDemodulator, DialFrequencyReceiver):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.parser = PocsagParser()
|
||||||
workers = [
|
workers = [
|
||||||
FmDemod(),
|
FmDemod(),
|
||||||
FskDemodulator(samplesPerSymbol=40, invert=True),
|
FskDemodulator(samplesPerSymbol=40, invert=True),
|
||||||
PocsagDecoder(),
|
PocsagDecoder(),
|
||||||
PocsagParser(),
|
self.parser,
|
||||||
]
|
]
|
||||||
super().__init__(workers)
|
super().__init__(workers)
|
||||||
|
|
||||||
@ -61,6 +62,9 @@ class PocsagDemodulator(ServiceDemodulator):
|
|||||||
def getFixedAudioRate(self) -> int:
|
def getFixedAudioRate(self) -> int:
|
||||||
return 48000
|
return 48000
|
||||||
|
|
||||||
|
def setDialFrequency(self, frequency: int) -> None:
|
||||||
|
self.parser.setDialFrequency(frequency)
|
||||||
|
|
||||||
|
|
||||||
class PskDemodulator(SecondaryDemodulator, SecondarySelectorChain):
|
class PskDemodulator(SecondaryDemodulator, SecondarySelectorChain):
|
||||||
def __init__(self, baudRate: float):
|
def __init__(self, baudRate: float):
|
||||||
|
@ -1,15 +1,37 @@
|
|||||||
from csdr.module import PickleModule
|
from csdr.module import PickleModule
|
||||||
|
from owrx.bands import Bandplan
|
||||||
|
from owrx.metrics import Metrics, CounterMetric
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class PocsagParser(PickleModule):
|
class PocsagParser(PickleModule):
|
||||||
|
def __init__(self):
|
||||||
|
self.band = None
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
def process(self, meta):
|
def process(self, meta):
|
||||||
try:
|
try:
|
||||||
if "address" in meta:
|
if "address" in meta:
|
||||||
meta["address"] = int(meta["address"])
|
meta["address"] = int(meta["address"])
|
||||||
meta["mode"] = "Pocsag"
|
meta["mode"] = "Pocsag"
|
||||||
|
self.pushDecode()
|
||||||
return meta
|
return meta
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("Exception while parsing Pocsag message")
|
logger.exception("Exception while parsing Pocsag message")
|
||||||
|
|
||||||
|
def setDialFrequency(self, freq: int) -> None:
|
||||||
|
self.band = Bandplan.getSharedInstance().findBand(freq)
|
||||||
|
|
||||||
|
def pushDecode(self):
|
||||||
|
band = "unknown"
|
||||||
|
if self.band is not None:
|
||||||
|
band = self.band.getName()
|
||||||
|
name = "digiham.decodes.{band}.pocsag".format(band=band)
|
||||||
|
metrics = Metrics.getSharedInstance()
|
||||||
|
metric = metrics.getMetric(name)
|
||||||
|
if metric is None:
|
||||||
|
metric = CounterMetric()
|
||||||
|
metrics.addMetric(name, metric)
|
||||||
|
metric.inc()
|
||||||
|
Loading…
Reference in New Issue
Block a user