adapt the code to split up predictions form the inbounds

This commit is contained in:
Sven Czarnian
2021-11-13 22:55:04 +01:00
parent eba9e2deab
commit 8b34f622a3
9 changed files with 280 additions and 267 deletions

View File

@@ -4,7 +4,7 @@ from datetime import datetime, timedelta
from aman.sys.aco.Configuration import Configuration
from aman.sys.aco.Constraints import SpacingConstraints
from aman.types.Inbound import Inbound
from aman.sys.aco.Node import Node
class RunwayManager:
def __init__(self, configuration : Configuration):
@@ -20,33 +20,33 @@ class RunwayManager:
if not runway.Runway.Name in self.RunwayInbounds:
self.RunwayInbounds[runway.Runway.Name] = None
def calculateEarliestArrivalTime(self, runway : str, inbound : Inbound, useETA : bool, earliestArrivalTime : datetime):
def calculateEarliestArrivalTime(self, runway : str, node : Node, useETA : bool, earliestArrivalTime : datetime):
constrainedETA = None
if None != self.RunwayInbounds[runway]:
# get the WTC based ETA
if None == self.RunwayInbounds[runway].WTC or None == inbound.WTC:
if None == self.RunwayInbounds[runway].Inbound.WTC or None == node.Inbound.WTC:
spacingWTC = 3
else:
spacingWTC = self.Spacings[self.RunwayInbounds[runway].WTC][inbound.WTC]
spacingWTC = self.Spacings[self.RunwayInbounds[runway].Inbound.WTC][node.Inbound.WTC]
# get the runway time spacing
spacingRunway = self.Configuration.RunwayConstraints.findRunway(runway).Spacing
constrainedETA = self.RunwayInbounds[runway].PlannedArrivalTime + timedelta(minutes = max(spacingWTC, spacingRunway) / (inbound.PerformanceData.SpeedApproach / 60))
constrainedETA = self.RunwayInbounds[runway].Inbound.PlannedArrivalTime + timedelta(minutes = max(spacingWTC, spacingRunway) / (node.Inbound.PerformanceData.SpeedApproach / 60))
# calculate the arrival times for the dependent inbounds
for dependentRunway in self.Configuration.RunwayConstraints.findDependentRunways(runway):
if None != self.RunwayInbounds[dependentRunway.Runway.Name]:
# TODO staggered spacing variabel
candidate = self.RunwayInbounds[dependentRunway.Runway.Name].PlannedArrivalTime + timedelta(minutes = 3 / (inbound.PerformanceData.SpeedApproach / 60))
candidate = self.RunwayInbounds[dependentRunway.Runway.Name].Inbound.PlannedArrivalTime + timedelta(minutes = 3 / (node.Inbound.PerformanceData.SpeedApproach / 60))
if None == constrainedETA or candidate > constrainedETA:
constrainedETA = candidate
# get the arrival time on the runway of the inbound
if True == useETA:
arrivalTime = inbound.ArrivalCandidates[runway].EarliestArrivalTime
arrivalTime = node.ArrivalCandidates[runway].EarliestArrivalTime
else:
arrivalTime = inbound.ArrivalCandidates[runway].InitialArrivalTime
arrivalTime = node.ArrivalCandidates[runway].InitialArrivalTime
if None == constrainedETA:
return max(arrivalTime, earliestArrivalTime), timedelta(seconds = 0)
@@ -57,7 +57,7 @@ class RunwayManager:
else:
return eta, timedelta(seconds = 0)
def selectArrivalRunway(self, inbound : Inbound, useETA : bool, earliestArrivalTime : datetime):
def selectArrivalRunway(self, node : Node, useETA : bool, earliestArrivalTime : datetime):
availableRunways = self.Configuration.RunwayConstraints.ActiveArrivalRunways
#if 1 < len(availableRunways):
@@ -68,7 +68,7 @@ class RunwayManager:
# fallback to check if we have available runways
if 0 == len(availableRunways):
runway = self.Configuration.RunwayConstraints.ActiveArrivalRunways[0]
return runway, self.calculateEarliestArrivalTime(runway.Runway.Name, inbound, useETA, earliestArrivalTime)
return runway, self.calculateEarliestArrivalTime(runway.Runway.Name, node, useETA, earliestArrivalTime)
# start with the beginning
selectedRunway = None
@@ -77,7 +77,7 @@ class RunwayManager:
# get the runway with the earliest ETA
for runway in availableRunways:
candidate, delta = self.calculateEarliestArrivalTime(runway.Runway.Name, inbound, useETA, earliestArrivalTime)
candidate, delta = self.calculateEarliestArrivalTime(runway.Runway.Name, node, useETA, earliestArrivalTime)
if None == eta or eta > candidate:
selectedRunway = runway.Runway
lostTime = delta