define member variables with capital letters

This commit is contained in:
Sven Czarnian
2021-10-13 12:52:29 +02:00
parent 9d69a60396
commit 1e043e2765
15 changed files with 229 additions and 223 deletions

View File

@@ -7,13 +7,13 @@ import scipy.interpolate
class WeatherModel:
def __init__(self, gaforId, weather : Weather):
self.gafor = gaforId
self.weather = weather
self.windDirectionModel = None
self.windSpeedModel = None
self.lastWeatherUpdate = None
self.minimumAltitude = 1000000
self.maximumAltitude = -1
self.Gafor = gaforId
self.Weather = weather
self.WindDirectionModel = None
self.WindSpeedModel = None
self.LastWeatherUpdate = None
self.MinimumAltitude = 1000000
self.MaximumAltitude = -1
# create the density interpolation model
# the density model is based on https://aerotoolbox.com/atmcalc/
@@ -95,51 +95,51 @@ class WeatherModel:
return ias * math.sqrt(1.225 / self.densityModel(altitude).item())
def updateWindModel(self):
if None == self.lastWeatherUpdate or self.lastWeatherUpdate != self.weather.provider.updateTime:
self.lastWeatherUpdate = self.weather.provider.updateTime
if None == self.LastWeatherUpdate or self.LastWeatherUpdate != self.Weather.Provider.UpdateTime:
self.LastWeatherUpdate = self.Weather.Provider.UpdateTime
self.minimumAltitude = 1000000
self.maximumAltitude = -1
self.windDirectionModel = None
self.windSpeedModel = None
self.MinimumAltitude = 1000000
self.MaximumAltitude = -1
self.WindDirectionModel = None
self.WindSpeedModel = None
if None != self.weather.provider.windData and self.gafor in self.weather.provider.windData:
if None != self.Weather.Provider.WindData and self.Gafor in self.Weather.Provider.WindData:
altitudes = []
directions = []
speeds = []
# collect the data for the wind model
for level in self.weather.provider.windData[self.gafor]:
for level in self.Weather.Provider.WindData[self.Gafor]:
altitudes.append(level[0])
directions.append(level[1])
speeds.append(level[2])
# define the thresholds for later boundary checks
if self.minimumAltitude > level[0]:
self.minimumAltitude = level[0]
if self.maximumAltitude < level[0]:
self.maximumAltitude = level[0]
if self.MinimumAltitude > level[0]:
self.MinimumAltitude = level[0]
if self.MaximumAltitude < level[0]:
self.MaximumAltitude = level[0]
# calculate the models
if 1 < len(altitudes):
self.windDirectionModel = scipy.interpolate.interp1d(altitudes, directions)
self.windSpeedModel = scipy.interpolate.interp1d(altitudes, speeds)
self.WindDirectionModel = scipy.interpolate.interp1d(altitudes, directions)
self.WindSpeedModel = scipy.interpolate.interp1d(altitudes, speeds)
def calculateGS(self, altitude : int, ias : int, heading : int):
self.updateWindModel()
tas = self.calculateTAS(altitude, ias)
# initialize the wind data
if None != self.windDirectionModel and None != self.windSpeedModel:
if None != self.WindDirectionModel and None != self.WindSpeedModel:
direction = 0.0
speed = 0.0
if None != self.windSpeedModel and None != self.windDirectionModel:
if self.maximumAltitude <= altitude:
altitude = self.maximumAltitude - 1
if self.minimumAltitude >= altitude:
altitude = self.minimumAltitude + 1
direction = self.windDirectionModel(altitude).item()
speed = self.windSpeedModel(altitude).item()
if None != self.WindSpeedModel and None != self.WindDirectionModel:
if self.MaximumAltitude <= altitude:
altitude = self.MaximumAltitude - 1
if self.MinimumAltitude >= altitude:
altitude = self.MinimumAltitude + 1
direction = self.WindDirectionModel(altitude).item()
speed = self.WindSpeedModel(altitude).item()
else:
speed = 0
direction = 0

View File

@@ -14,48 +14,46 @@ from aman.types.PerformanceData import PerformanceData
class Worker(Thread):
def __init__(self):
Thread.__init__(self)
self.stopThread = None
self.icao = None
self.configuration = None
self.arrivalRoutes = None
self.performanceData = None
self.updateLock = None
self.reportQueue = {}
self.weatherModel = None
self.StopThread = None
self.Icao = None
self.Configuration = None
self.PerformanceData = None
self.UpdateLock = None
self.ReportQueue = {}
self.WeatherModel = None
self.RecedingHorizonControl = None
def __del__(self):
self.release()
def acquire(self, icao : str, configuration : Airport, weather : Weather, performance : PerformanceData):
self.stopThread = None
self.icao = icao
self.configuration = configuration
self.sequencingConfiguration = self.configuration.DefaultSequencing
self.performanceData = performance
self.arrivalRoutes = configuration.GngData.arrivalRoutes
self.updateLock = Lock()
self.reportQueue = {}
self.weatherModel = WeatherModel(self.configuration.GaforId, weather)
self.RecedingHorizonControl = RecedingHorizonControl(self.configuration.RecedingHorizonControl)
self.StopThread = None
self.Icao = icao
self.Configuration = configuration
self.sequencingConfiguration = configuration.DefaultSequencing
self.PerformanceData = performance
self.UpdateLock = Lock()
self.ReportQueue = {}
self.WeatherModel = WeatherModel(configuration.GaforId, weather)
self.RecedingHorizonControl = RecedingHorizonControl(configuration.RecedingHorizonControl)
self.start()
def acquireLock(self):
if None != self.updateLock:
self.updateLock.acquire()
if None != self.UpdateLock:
self.UpdateLock.acquire()
def release(self):
self.stopThread = True
self.StopThread = True
self.join()
def releaseLock(self):
if None != self.updateLock:
self.updateLock.release()
if None != self.UpdateLock:
self.UpdateLock.release()
def run(self):
counter = 0
while None == self.stopThread:
while None == self.StopThread:
time.sleep(1)
counter += 1
if 0 != (counter % 10):
@@ -67,17 +65,17 @@ class Worker(Thread):
self.RecedingHorizonControl.cleanupWindows()
# update the aircraft information in RHC
for callsign in self.reportQueue:
report = self.reportQueue[callsign]
for callsign in self.ReportQueue:
report = self.ReportQueue[callsign]
if 0 != report.distanceToIAF and '' != report.initialApproachFix:
inbound = Inbound(report, self.sequencingConfiguration, self.configuration.GngData, self.performanceData, self.weatherModel)
inbound = Inbound(report, self.sequencingConfiguration, self.Configuration.GngData, self.PerformanceData, self.WeatherModel)
if None != inbound.PlannedRunway and None != inbound.PlannedStar:
self.RecedingHorizonControl.update(inbound)
else:
print('Unable to find all data of ' + report.aircraft.callsign)
self.reportQueue.clear()
self.ReportQueue.clear()
if 0 != len(self.RecedingHorizonControl.Windows):
print('FCFS run:')
@@ -89,9 +87,9 @@ class Worker(Thread):
# this is required to handle the overlap between windows
preceedingInbounds = {}
for runway in self.sequencingConfiguration.ActiveArrivalRunways:
inbound = self.RecedingHorizonControl.lastFixedInboundOnRunway(runway.Runway.name)
inbound = self.RecedingHorizonControl.lastFixedInboundOnRunway(runway.Runway.Name)
if None != inbound:
preceedingInbounds[runway.Runway.name] = inbound
preceedingInbounds[runway.Runway.Name] = inbound
# search the ACO relevant aircrafts
relevantInbounds = self.RecedingHorizonControl.optimizationRelevantInbounds()
@@ -106,6 +104,6 @@ class Worker(Thread):
# TODO perform the ACO run
# TODO update the RHC stages based on the ACO run result
else:
print('No relevant inbounds found for the optimization in ' + self.icao)
print('No relevant inbounds found for the optimization in ' + self.Icao)
self.releaseLock()