pass through the mode on the map

This commit is contained in:
Jakob Ketterl
2019-07-11 23:40:09 +02:00
parent acbf2939c9
commit 2470c2bfa6
4 changed files with 24 additions and 11 deletions

View File

@ -44,7 +44,8 @@ class Map(object):
{
"callsign": callsign,
"location": record["location"].__dict__(),
"lastseen": record["updated"].timestamp() * 1000
"lastseen": record["updated"].timestamp() * 1000,
"mode" : record["mode"]
}
for (callsign, record) in self.positions.items()
])
@ -55,14 +56,15 @@ class Map(object):
except ValueError:
pass
def updateLocation(self, callsign, loc: Location):
def updateLocation(self, callsign, loc: Location, mode: str):
ts = datetime.now()
self.positions[callsign] = {"location": loc, "updated": ts}
self.positions[callsign] = {"location": loc, "updated": ts, "mode": mode}
self.broadcast([
{
"callsign": callsign,
"location": loc.__dict__(),
"lastseen": ts.timestamp() * 1000
"lastseen": ts.timestamp() * 1000,
"mode" : mode
}
])

View File

@ -71,7 +71,8 @@ class YsfMetaEnricher(object):
def enrich(self, meta):
if "source" in meta and "lat" in meta and "lon" in meta:
# TODO parsing the float values should probably happen earlier
Map.getSharedInstance().updateLocation(meta["source"], LatLngLocation(float(meta["lat"]), float(meta["lon"])))
loc = LatLngLocation(float(meta["lat"]), float(meta["lon"]))
Map.getSharedInstance().updateLocation(meta["source"], loc, "YSF")
return None

View File

@ -118,9 +118,15 @@ class WsjtParser(object):
self.handler = handler
self.locator_pattern = re.compile(".*\s([A-Z0-9]+)\s([A-R]{2}[0-9]{2})$")
modes = {
"~": "FT8"
}
def parse(self, data):
try:
msg = data.decode().rstrip()
# sample
# '222100 -15 -0.0 508 ~ CQ EA7MJ IM66'
# known debug messages we know to skip
if msg.startswith("<DecodeFinished>"):
return
@ -133,15 +139,17 @@ class WsjtParser(object):
out["db"] = float(msg[7:10])
out["dt"] = float(msg[11:15])
out["freq"] = int(msg[16:20])
modeChar = msg[21:22]
out["mode"] = mode = WsjtParser.modes[modeChar] if modeChar in WsjtParser.modes else "unknown"
wsjt_msg = msg[24:60].strip()
self.getLocator(wsjt_msg)
self.parseLocator(wsjt_msg, mode)
out["msg"] = wsjt_msg
self.handler.write_wsjt_message(out)
except ValueError:
logger.exception("error while parsing wsjt message")
def getLocator(self, msg):
def parseLocator(self, msg, mode):
m = self.locator_pattern.match(msg)
if m is None:
return
@ -149,4 +157,4 @@ class WsjtParser(object):
# likely this just means roger roger goodbye.
if m.group(2) == "RR73":
return
Map.getSharedInstance().updateLocation(m.group(1), LocatorLocation(m.group(2)))
Map.getSharedInstance().updateLocation(m.group(1), LocatorLocation(m.group(2)), mode)