|
@@ -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
|