2021-09-10 13:38:36 +00:00
|
|
|
from csdr.module import PickleModule
|
2021-09-30 22:52:32 +00:00
|
|
|
from owrx.bands import Bandplan
|
|
|
|
from owrx.metrics import Metrics, CounterMetric
|
2021-01-22 18:48:31 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2020-01-09 14:11:53 +00:00
|
|
|
|
2021-09-10 13:38:36 +00:00
|
|
|
class PocsagParser(PickleModule):
|
2021-09-30 22:52:32 +00:00
|
|
|
def __init__(self):
|
|
|
|
self.band = None
|
|
|
|
super().__init__()
|
|
|
|
|
2021-09-10 13:38:36 +00:00
|
|
|
def process(self, meta):
|
|
|
|
try:
|
|
|
|
if "address" in meta:
|
|
|
|
meta["address"] = int(meta["address"])
|
|
|
|
meta["mode"] = "Pocsag"
|
2021-09-30 22:52:32 +00:00
|
|
|
self.pushDecode()
|
2021-09-10 13:38:36 +00:00
|
|
|
return meta
|
|
|
|
except Exception:
|
|
|
|
logger.exception("Exception while parsing Pocsag message")
|
2021-09-30 22:52:32 +00:00
|
|
|
|
|
|
|
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()
|