Call links show up now.

This commit is contained in:
Marat Fayzullin 2024-09-06 18:12:31 -04:00
parent e25c9c9000
commit cbb86dc7fa
5 changed files with 53 additions and 27 deletions

View File

@ -13,6 +13,7 @@ function LocatorManager(spectral = true) {
this.locators = {};
this.bands = {};
this.modes = {};
this.calls = [];
// The color scale used
this.colorScale = chroma.scale(colors).mode('hsl');
@ -57,9 +58,6 @@ LocatorManager.prototype.update = function(id, data, map) {
// Do not update unless locator present
if (!(id in this.locators)) return false;
// Filter out link messages
if ('callee' in data) return this.updateLink(id, data, map);
// Make sure we have valid band and mode names
if (!data.band) data.band = 'other';
if (!data.mode) data.mode = 'other';
@ -89,9 +87,28 @@ LocatorManager.prototype.update = function(id, data, map) {
return true;
};
LocatorManager.prototype.updateLink = function(id, data, map) {
// @@@ TODO!!!
return false;
LocatorManager.prototype.updateCall = function(data, map) {
// Create an arc
data.arc = new google.maps.Polyline({
path: [
this.id2latlng(data.src.locator),
this.id2latlng(data.dst.locator)
],
geodesic: true,
strokeColor: "#000000",
strokeOpacity: 0.2,
strokeWeight: 1
});
data.arc.setMap(map);
// Push into array, limit array length
this.calls.push(data);
if (this.calls.length > 15) {
var old = this.calls.shift();
old.arc.setMap();
}
return true;
};
LocatorManager.prototype.getSortedKeys = function(colorMap) {
@ -336,3 +353,4 @@ Locator.prototype.getInfoHTML = function(locator, pos, receiverMarker = null) {
+ Utils.makeListTitle('Active Callsigns')
+ '<table align="center" class="openwebrx-map-info">' + list + '</table>';
};

View File

@ -146,9 +146,13 @@ MapManager.prototype.processUpdates = function(updates) {
}
updates.forEach(function(update) {
// TODO: Process caller-callee links here!!!
if (!('location' in update)) return;
// Process caller-callee updates
if ('caller' in update) {
self.lman.updateCall(update, map);
return;
}
// Process position updates
switch (update.location.type) {
case 'latlon':
var marker = self.mman.find(update.callsign);

View File

@ -433,9 +433,13 @@ MapManager.prototype.processUpdates = function(updates) {
}
updates.forEach(function(update) {
// TODO: Process caller-callee links here!!!
if (!('location' in update)) return;
// Process caller-callee updates
if ('caller' in update) {
self.lman.updateCall(update, map);
return;
}
// Process position updates
switch (update.location.type) {
case 'latlon':
var marker = self.mman.find(update.callsign);

View File

@ -36,7 +36,7 @@ class Map(object):
def __init__(self):
self.clients = []
self.positions = {}
self.links = []
self.calls = []
self.positionsLock = threading.Lock()
def removeLoop():
@ -69,7 +69,7 @@ class Map(object):
positions = [
self._makeRecord(key, record) for (key, record) in self.positions.items()
] + [
self._makeLink(link) for link in self.links
self._makeCall(call) for call in self.calls
]
client.write_update(positions)
@ -80,15 +80,15 @@ class Map(object):
except ValueError:
pass
def _makeLink(self, link):
def _makeCall(self, call):
return {
"caller": link["caller"],
"callee": link["callee"],
"src": link["src"].__dict__(),
"dst": link["dst"].__dict__(),
"lastseen": link.timestamp() * 1000,
"mode": link["mode"],
"band": link["band"].getName() if link["band"] is not None else None
"caller": call["caller"],
"callee": call["callee"],
"src": call["src"].__dict__(),
"dst": call["dst"].__dict__(),
"lastseen": call["timestamp"].timestamp() * 1000,
"mode": call["mode"],
"band": call["band"].getName() if call["band"] is not None else None
}
def _makeRecord(self, callsign, record):
@ -101,7 +101,7 @@ class Map(object):
"hops": record["hops"]
}
def updateLink(self, key, callee, mode: str, band: Band = None, timestamp: datetime = None):
def updateCall(self, key, callee, mode: str, band: Band = None, timestamp: datetime = None):
logger.info("{0} call from {1} to {2}".format(mode, key, callee))
# if we get an external timestamp, make sure it's not already expired
@ -117,7 +117,7 @@ class Map(object):
if key in self.positions and callee in self.positions:
src = self.positions[key]["location"]
dst = self.positions[callee]["location"]
link = {
call = {
"caller": key,
"callee": callee,
"timestamp": timestamp,
@ -126,10 +126,10 @@ class Map(object):
"src": src,
"dst": dst
}
broadcast = self._makeLink(link)
self.links.append(link)
if len(self.links) > 15:
self.links.pop(0)
broadcast = self._makeCall(call)
self.calls.append(call)
if len(self.calls) > 15:
self.calls.pop(0)
if broadcast is not None:
self.broadcast([broadcast])

View File

@ -293,7 +293,7 @@ class WsjtParser(AudioChopperParser):
)
ReportingEngine.getSharedInstance().spot(out)
if "callsign" in out and "callee" in out:
Map.getSharedInstance().updateLink(
Map.getSharedInstance().updateCall(
out["callsign"], out["callee"], mode, band
)