add band information to ysf locations
This commit is contained in:
parent
8df4f9ce52
commit
243e73064a
19
owrx/meta.py
19
owrx/meta.py
@ -5,6 +5,7 @@ from datetime import datetime, timedelta
|
|||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
from owrx.map import Map, LatLngLocation
|
from owrx.map import Map, LatLngLocation
|
||||||
|
from owrx.bands import Bandplan
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -71,19 +72,29 @@ class DmrMetaEnricher(object):
|
|||||||
|
|
||||||
|
|
||||||
class YsfMetaEnricher(object):
|
class YsfMetaEnricher(object):
|
||||||
|
def __init__(self, parser):
|
||||||
|
self.parser = parser
|
||||||
|
|
||||||
def enrich(self, meta):
|
def enrich(self, meta):
|
||||||
if "source" in meta and "lat" in meta and "lon" in meta:
|
if "source" in meta and "lat" in meta and "lon" in meta:
|
||||||
# TODO parsing the float values should probably happen earlier
|
# TODO parsing the float values should probably happen earlier
|
||||||
loc = LatLngLocation(float(meta["lat"]), float(meta["lon"]))
|
loc = LatLngLocation(float(meta["lat"]), float(meta["lon"]))
|
||||||
Map.getSharedInstance().updateLocation(meta["source"], loc, "YSF")
|
Map.getSharedInstance().updateLocation(meta["source"], loc, "YSF", self.parser.getBand())
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class MetaParser(object):
|
class MetaParser(object):
|
||||||
enrichers = {"DMR": DmrMetaEnricher(), "YSF": YsfMetaEnricher()}
|
|
||||||
|
|
||||||
def __init__(self, handler):
|
def __init__(self, handler):
|
||||||
self.handler = handler
|
self.handler = handler
|
||||||
|
self.enrichers = {"DMR": DmrMetaEnricher(), "YSF": YsfMetaEnricher(self)}
|
||||||
|
self.band = None
|
||||||
|
|
||||||
|
def setDialFrequency(self, freq):
|
||||||
|
self.band = Bandplan.getSharedInstance().findBand(freq)
|
||||||
|
|
||||||
|
def getBand(self):
|
||||||
|
return self.band
|
||||||
|
|
||||||
def parse(self, meta):
|
def parse(self, meta):
|
||||||
fields = meta.split(";")
|
fields = meta.split(";")
|
||||||
@ -91,8 +102,8 @@ class MetaParser(object):
|
|||||||
|
|
||||||
if "protocol" in meta:
|
if "protocol" in meta:
|
||||||
protocol = meta["protocol"]
|
protocol = meta["protocol"]
|
||||||
if protocol in MetaParser.enrichers:
|
if protocol in self.enrichers:
|
||||||
additional_data = MetaParser.enrichers[protocol].enrich(meta)
|
additional_data = self.enrichers[protocol].enrich(meta)
|
||||||
if additional_data is not None:
|
if additional_data is not None:
|
||||||
meta["additional"] = additional_data
|
meta["additional"] = additional_data
|
||||||
self.handler.write_metadata(meta)
|
self.handler.write_metadata(meta)
|
||||||
|
@ -537,6 +537,7 @@ class DspManager(csdr.output):
|
|||||||
freq = self.localProps["center_freq"] + self.localProps["offset_freq"]
|
freq = self.localProps["center_freq"] + self.localProps["offset_freq"]
|
||||||
self.wsjtParser.setDialFrequency(freq)
|
self.wsjtParser.setDialFrequency(freq)
|
||||||
self.aprsParser.setDialFrequency(freq)
|
self.aprsParser.setDialFrequency(freq)
|
||||||
|
self.metaParser.setDialFrequency(freq)
|
||||||
|
|
||||||
self.subscriptions = [
|
self.subscriptions = [
|
||||||
self.localProps.getProperty("audio_compression").wire(self.dsp.set_audio_compression),
|
self.localProps.getProperty("audio_compression").wire(self.dsp.set_audio_compression),
|
||||||
|
Loading…
Reference in New Issue
Block a user