count aprs decodes, too
This commit is contained in:
parent
bc5b16b5e3
commit
338a19373c
16
owrx/aprs.py
16
owrx/aprs.py
@ -1,6 +1,7 @@
|
|||||||
from owrx.kiss import KissDeframer
|
from owrx.kiss import KissDeframer
|
||||||
from owrx.map import Map, LatLngLocation
|
from owrx.map import Map, LatLngLocation
|
||||||
from owrx.bands import Bandplan
|
from owrx.bands import Bandplan
|
||||||
|
from owrx.metrics import Metrics, CounterMetric
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
@ -133,10 +134,24 @@ class AprsParser(object):
|
|||||||
self.dial_freq = None
|
self.dial_freq = None
|
||||||
self.band = None
|
self.band = None
|
||||||
self.handler = handler
|
self.handler = handler
|
||||||
|
self.metric = self.getMetric()
|
||||||
|
|
||||||
def setDialFrequency(self, freq):
|
def setDialFrequency(self, freq):
|
||||||
self.dial_freq = freq
|
self.dial_freq = freq
|
||||||
self.band = Bandplan.getSharedInstance().findBand(freq)
|
self.band = Bandplan.getSharedInstance().findBand(freq)
|
||||||
|
self.metric = self.getMetric()
|
||||||
|
|
||||||
|
def getMetric(self):
|
||||||
|
band = "unknown"
|
||||||
|
if self.band is not None:
|
||||||
|
band = self.band.getName()
|
||||||
|
name = "aprs.decodes.{band}.aprs".format(band=band)
|
||||||
|
metrics = Metrics.getSharedInstance()
|
||||||
|
metric = metrics.getMetric(name)
|
||||||
|
if metric is None:
|
||||||
|
metric = CounterMetric()
|
||||||
|
metrics.addMetric(name, metric)
|
||||||
|
return metric
|
||||||
|
|
||||||
def parse(self, raw):
|
def parse(self, raw):
|
||||||
for frame in self.deframer.parse(raw):
|
for frame in self.deframer.parse(raw):
|
||||||
@ -148,6 +163,7 @@ class AprsParser(object):
|
|||||||
|
|
||||||
logger.debug("decoded APRS data: %s", aprsData)
|
logger.debug("decoded APRS data: %s", aprsData)
|
||||||
self.updateMap(aprsData)
|
self.updateMap(aprsData)
|
||||||
|
self.metric.inc()
|
||||||
self.handler.write_aprs_data(aprsData)
|
self.handler.write_aprs_data(aprsData)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("exception while parsing aprs data")
|
logger.exception("exception while parsing aprs data")
|
||||||
|
@ -252,7 +252,9 @@ class WsjtParser(object):
|
|||||||
|
|
||||||
def pushDecode(self, mode):
|
def pushDecode(self, mode):
|
||||||
metrics = Metrics.getSharedInstance()
|
metrics = Metrics.getSharedInstance()
|
||||||
band = self.band.getName()
|
band = "unknown"
|
||||||
|
if self.band is not None:
|
||||||
|
band = self.band.getName()
|
||||||
if band is None:
|
if band is None:
|
||||||
band = "unknown"
|
band = "unknown"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user