Browse Source

extend the configuration

Sven Czarnian 3 years ago
parent
commit
276e50daa3
3 changed files with 138 additions and 0 deletions
  1. 89 0
      aman/config/AirportSequencing.py
  2. 41 0
      aman/config/RHC.py
  3. 8 0
      aman/config/RunwaySequencing.py

+ 89 - 0
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

+ 41 - 0
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)

+ 8 - 0
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