From 276e50daa30565d81dba680100f34c74fa17afc1 Mon Sep 17 00:00:00 2001 From: Sven Czarnian Date: Tue, 12 Oct 2021 22:28:35 +0200 Subject: [PATCH] extend the configuration --- aman/config/AirportSequencing.py | 89 ++++++++++++++++++++++++++++++++ aman/config/RHC.py | 41 +++++++++++++++ aman/config/RunwaySequencing.py | 8 +++ 3 files changed, 138 insertions(+) create mode 100644 aman/config/AirportSequencing.py create mode 100644 aman/config/RHC.py create mode 100644 aman/config/RunwaySequencing.py diff --git a/aman/config/AirportSequencing.py b/aman/config/AirportSequencing.py new file mode 100644 index 0000000..3287360 --- /dev/null +++ b/aman/config/AirportSequencing.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python + +from aman.config.RunwaySequencing import RunwaySequencing + +class AirportSequencing: + def __init__(self, icao : str): + self.ActiveArrivalRunways = [] + self.RunwayDependencies = [] + + def clearData(self): + self.ActiveArrivalRunways.clear() + self.RunwayDependencies.clear() + + def activateRunway(self, runway : RunwaySequencing): + for active in self.ActiveArrivalRunways: + if active.Runway.name == runway.Runway.name: + self.ActiveArrivalRunways[runway.Runway.name] = runway + return + self.ActiveArrivalRunways.append(runway) + + def runwayIndex(self, identifier : str): + for i in range(0, len(self.ActiveArrivalRunways)): + if self.ActiveArrivalRunways[i].Runway.name == identifier: + return i + return -1 + + def deactivateRunway(self, identifier : str): + index = self.runwayIndex(identifier) + if 0 <= index: + self.ActiveArrivalRunways.pop(index) + + # remove the dependencies + for i in range(self.RunwayDependencies - 1, -1, -1): + if index == self.RunwayDependencies[i][0] or index == self.RunwayDependencies[i][1]: + self.RunwayDependencies.pop(i) + + def addDependency(self, first : str, second : str): + idxFirst = self.runwayIndex(first) + idxSecond = self.runwayIndex(second) + if 0 > idxFirst or 0 > idxSecond: + return + + foundFirst = False + foundSecond = False + for dependency in self.RunwayDependencies: + if idxFirst == dependency[0] and idxSecond == dependency[1]: + foundFirst = True + elif idxFirst == dependency[1] and idxSecond == dependency[0]: + foundSecond = True + + if False == foundFirst: + self.RunwayDependencies.append([ idxFirst, idxSecond ]) + if False == foundSecond: + self.RunwayDependencies.append([ idxSecond, idxFirst ]) + + def removeDependency(self, first : str, second : str): + idxFirst = self.runwayIndex(first) + idxSecond = self.runwayIndex(second) + if 0 > idxFirst or 0 > idxSecond: + return + + for i in range(self.RunwayDependencies - 1, -1, -1): + dependency = self.RunwayDependencies[i] + + # check for all the pairs + if idxFirst == dependency[0] and idxSecond == dependency[1]: + self.RunwayDependencies.pop(i) + elif idxSecond == dependency[0] and idxSecond == dependency[0]: + self.RunwayDependencies.pop(i) + + def findRunway(self, identifier : str): + for runway in self.ActiveArrivalRunways: + if runway.Runway.name == identifier: + return runway + return None + + def findDependentRunway(self, identifier : str): + # runway is unknown + index = self.runwayIndex(identifier) + if 0 > index: + return None + + # search the dependency pair + for dependency in self.RunwayDependencies: + if index == dependency[0]: + return self.ActiveArrivalRunways[dependency[1]] + + # no dependencies found + return None diff --git a/aman/config/RHC.py b/aman/config/RHC.py new file mode 100644 index 0000000..50a7f45 --- /dev/null +++ b/aman/config/RHC.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +from datetime import timedelta + +import configparser; +import sys + +class RHC(): + def __init__(self, config : configparser.ConfigParser): + # latest scheduling fix in minutes + self.FixedBeforeArrival = None + # number of seconds per window + self.WindowSize = None + # number of horizon windows for optimization iteration + self.WindowOverlap = None + # distance until IAF to add an aircraft to the optimization + self.MaximumIafDistance = None + + # search the required sections + for key in config: + if 'windowsize' == key: + self.WindowSize = int(config['windowsize']) + elif 'windowoverlap' == key: + self.WindowOverlap = int(config['windowoverlap']) + elif 'fixedbeforearrival' == key: + self.FixedBeforeArrival = timedelta(minutes = int(config['fixedbeforearrival'])) + elif 'maximumiafdistance' == key: + self.MaximumIafDistance = int(config['maximumiafdistance']) + + if self.WindowSize is None: + sys.stderr.write('No window size configuration found!') + sys.exit(-1) + if self.WindowOverlap is None: + sys.stderr.write('No window overlap configuration found!') + sys.exit(-1) + if self.FixedBeforeArrival is None: + sys.stderr.write('No fixed before IAF configuration found!') + sys.exit(-1) + if self.MaximumIafDistance is None: + sys.stderr.write('No maximum IAF distance found!') + sys.exit(-1) diff --git a/aman/config/RunwaySequencing.py b/aman/config/RunwaySequencing.py new file mode 100644 index 0000000..c85be16 --- /dev/null +++ b/aman/config/RunwaySequencing.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +from aman.types.Runway import Runway + +class RunwaySequencing: + def __init__(self, runway : Runway): + self.Runway = runway + self.Spacing = 3 \ No newline at end of file