increase performance

This commit is contained in:
Sven Czarnian
2021-10-18 12:42:18 +02:00
parent 33b32befbc
commit 12d77d0e71

View File

@@ -20,37 +20,26 @@ class RunwayManager:
if not runway.Runway.Name in self.RunwayInbounds: if not runway.Runway.Name in self.RunwayInbounds:
self.RunwayInbounds[runway.Runway.Name] = None self.RunwayInbounds[runway.Runway.Name] = None
def validateWtc(inbound : Inbound):
wtc = inbound.Report.aircraft.wtc.upper()
if 'L' == wtc or 'M' == wtc or 'H' == wtc or 'J' == wtc:
return wtc
else:
return None
def calculateEarliestArrivalTime(self, runway : str, inbound : Inbound, useITA : bool, earliestArrivalTime : datetime): def calculateEarliestArrivalTime(self, runway : str, inbound : Inbound, useITA : bool, earliestArrivalTime : datetime):
earliestArrivalTimes = [] constrainedETA = None
if None != self.RunwayInbounds[runway]: if None != self.RunwayInbounds[runway]:
# get the WTC based ETA # get the WTC based ETA
wtcPre = RunwayManager.validateWtc(self.RunwayInbounds[runway]) if None == self.RunwayInbounds[runway].WTC or None == inbound.WTC:
wtcThis = RunwayManager.validateWtc(inbound) spacingWTC = 3
if None == wtcPre or None == wtcThis:
spacing = 3
else: else:
spacing = self.Spacings[wtcPre][wtcThis] spacingWTC = self.Spacings[self.RunwayInbounds[runway].WTC][inbound.WTC]
delay = timedelta(minutes = spacing / (inbound.PerformanceData.SpeedApproach / 60))
earliestArrivalTimes.append(self.RunwayInbounds[runway].PlannedArrivalTime + delay)
# get the runway time spacing # get the runway time spacing
spacing = self.Configuration.RunwayConstraints.findRunway(runway).Spacing spacingRunway = self.Configuration.RunwayConstraints.findRunway(runway).Spacing
delay = timedelta(minutes = spacing / (inbound.PerformanceData.SpeedApproach / 60)) constrainedETA = self.RunwayInbounds[runway].PlannedArrivalTime + timedelta(minutes = max(spacingWTC, spacingRunway) / (inbound.PerformanceData.SpeedApproach / 60))
earliestArrivalTimes.append(self.RunwayInbounds[runway].PlannedArrivalTime + delay)
# calculate the arrival times for the dependent inbounds # calculate the arrival times for the dependent inbounds
for dependentRunway in self.Configuration.RunwayConstraints.findDependentRunways(runway): for dependentRunway in self.Configuration.RunwayConstraints.findDependentRunways(runway):
if None != self.RunwayInbounds[dependentRunway.Runway.Name]: if None != self.RunwayInbounds[dependentRunway.Runway.Name]:
delay = timedelta(minutes = 3 / (inbound.PerformanceData.SpeedApproach / 60)) candidate = self.RunwayInbounds[dependentRunway.Runway.Name].PlannedArrivalTime + timedelta(minutes = 3 / (inbound.PerformanceData.SpeedApproach / 60))
earliestArrivalTimes.append(self.RunwayInbounds[dependentRunway.Runway.Name].PlannedArrivalTime + delay) if None == constrainedETA or candidate > constrainedETA:
constrainedETA = candidate
# get the arrival time on the runway of the inbound # get the arrival time on the runway of the inbound
if True == useITA: if True == useITA:
@@ -58,19 +47,17 @@ class RunwayManager:
else: else:
arrivalTime = inbound.ArrivalCandidates[runway].InitialArrivalTime arrivalTime = inbound.ArrivalCandidates[runway].InitialArrivalTime
if 0 == len(earliestArrivalTimes): if None == constrainedETA:
return arrivalTime, timedelta(seconds = 0) return max(arrivalTime, earliestArrivalTime), timedelta(seconds = 0)
else: else:
eta = max(earliestArrivalTimes) eta = max(constrainedETA, earliestArrivalTime)
if eta < arrivalTime: if eta < arrivalTime:
return arrivalTime, arrivalTime - eta return arrivalTime, arrivalTime - eta
else: else:
return eta, timedelta(seconds = 0) return eta, timedelta(seconds = 0)
def selectArrivalRunway(self, inbound : Inbound, useITA : bool, earliestArrivalTime : datetime): def selectArrivalRunway(self, inbound : Inbound, useITA : bool, earliestArrivalTime : datetime):
availableRunways = [] availableRunways = self.Configuration.RunwayConstraints.ActiveArrivalRunways
for runway in self.Configuration.RunwayConstraints.ActiveArrivalRunways:
availableRunways.append(runway)
#if 1 < len(availableRunways): #if 1 < len(availableRunways):
# TODO filter based on type # TODO filter based on type