sort the received aircraft reports into the corresponding worker thread

This commit is contained in:
Sven Czarnian
2021-09-03 23:35:17 +02:00
parent 1561335e1b
commit 9de9b813ba
3 changed files with 28 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ import glob
import os
import sys
from aman.com import AircraftReport_pb2
from aman.com.Euroscope import Euroscope
from aman.config.AircraftPerformance import AircraftPerformance
from aman.config.Airport import Airport
@@ -29,6 +30,7 @@ class AMAN:
self.aircraftPerformance = None
self.receiver = None
self.workers = []
self.inbounds = {}
configPath = AMAN.findConfigPath()
@@ -59,7 +61,7 @@ class AMAN:
print('Starter worker for ' + icao)
# create the EuroScope receiver
self.receiver = Euroscope(configPath, self.systemConfig.Server)
self.receiver = Euroscope(configPath, self.systemConfig.Server, self)
def __del__(self):
if None != self.receiver:
@@ -68,3 +70,13 @@ class AMAN:
for worker in self.workers:
worker.stop()
def updateAircraftReport(self, report : AircraftReport_pb2.AircraftReport):
# find the correct worker for the inbound
for worker in self.workers:
if worker.icao == report.destination:
print('Updated ' + report.aircraft.callsign + ' for ' + worker.icao)
worker.acquire()
worker.reportQueue[report.aircraft.callsign] = report
worker.release()
break