allow unset weather provider

This commit is contained in:
Sven Czarnian
2021-11-22 16:19:46 +01:00
parent 18577ebe9a
commit f021baf4cc
4 changed files with 13 additions and 6 deletions

View File

@@ -28,15 +28,16 @@ class ComThread(Thread):
report.ParseFromString(msg) report.ParseFromString(msg)
# try to associate the received aircrafts to airports # try to associate the received aircrafts to airports
icao = [] icao = None
for inbound in report.reports: for inbound in report.reports:
self.AMAN.updateAircraftReport(inbound) self.AMAN.updateAircraftReport(inbound)
icao = inbound.destination icao = inbound.destination
# get the sequence of the airport # get the sequence of the airport
airport = self.AMAN.findAirport(icao) if None != icao:
if None != airport: airport = self.AMAN.findAirport(icao)
self.Com.sendSequence('', airport.inboundSequence(), airport.WeatherModel) if None != airport:
self.Com.sendSequence(icao, airport.inboundSequence(), airport.WeatherModel)
except zmq.ZMQError as error: except zmq.ZMQError as error:
if zmq.EAGAIN == error.errno: if zmq.EAGAIN == error.errno:

View File

@@ -21,7 +21,7 @@ class Weather(Thread):
if 'DWD' == config.Provider.upper(): if 'DWD' == config.Provider.upper():
self.Provider = DwdCrawler() self.Provider = DwdCrawler()
else: elif 'NONE' != config.Provider.upper():
sys.stderr.write('Invalid or unknown weather-provider defined') sys.stderr.write('Invalid or unknown weather-provider defined')
sys.exit(-1) sys.exit(-1)

View File

@@ -98,6 +98,9 @@ class WeatherModel:
return ias * math.sqrt(1.225 / self.densityModel(altitude).item()) return ias * math.sqrt(1.225 / self.densityModel(altitude).item())
def updateWindModel(self): def updateWindModel(self):
if None == self.Weather or None == self.Weather.Provider:
return
if None == self.LastWeatherUpdate or self.LastWeatherUpdate != self.Weather.Provider.UpdateTime: if None == self.LastWeatherUpdate or self.LastWeatherUpdate != self.Weather.Provider.UpdateTime:
self.MinimumAltitude = 1000000 self.MinimumAltitude = 1000000
self.MaximumAltitude = -1 self.MaximumAltitude = -1

View File

@@ -27,7 +27,10 @@ class Worker(Thread):
self.PerformanceData = performance self.PerformanceData = performance
self.UpdateLock = Lock() self.UpdateLock = Lock()
self.ReportQueue = {} self.ReportQueue = {}
self.WeatherModel = WeatherModel(configuration.GaforId, weather) if None != weather:
self.WeatherModel = WeatherModel(configuration.GaforId, weather)
else:
self.WeatherModel = WeatherModel(0, None)
self.RecedingHorizonControl = RecedingHorizonControl(configuration.RecedingHorizonControl) self.RecedingHorizonControl = RecedingHorizonControl(configuration.RecedingHorizonControl)
self.Euroscope = euroscope self.Euroscope = euroscope