Pārlūkot izejas kodu

fix sporadic system crashes

Sven Czarnian 2 gadi atpakaļ
vecāks
revīzija
c9937d39c2
1 mainītis faili ar 9 papildinājumiem un 2 dzēšanām
  1. 9 2
      aman/sys/RecedingHorizonControl.py

+ 9 - 2
aman/sys/RecedingHorizonControl.py

@@ -175,11 +175,18 @@ class RecedingHorizonControl:
         return runwayInbounds, iafInbounds
 
     def optimizationRelevantInbounds(self):
+        if 0 == len(self.Windows):
+            return None, None
+
         inbounds = []
-        earliestArrivalTime = self.Windows[self.FreezedIndex + 1].StartTime
+        if self.FreezedIndex + 1 >= len(self.Windows):
+            earliestArrivalTime = dt.utcfromtimestamp(int(time.time())).replace(tzinfo = pytz.UTC)
+            earliestArrivalTime += self.Configuration.FixedBeforeArrival
+        else:
+            earliestArrivalTime = self.Windows[self.FreezedIndex + 1].StartTime
 
         # check if we have a reconnect in the freezed blocks (VATSIM specific behavior)
-        for i in range(0, self.FreezedIndex + 1):
+        for i in range(0, min(len(self.Windows), self.FreezedIndex + 1)):
             for inbound in self.Windows[i].Inbounds:
                 if False == inbound.HasValidSequence:
                     inbounds.sort(key = lambda x: x.PlannedArrivalTime if None != x.PlannedArrivalTime else x.EnrouteArrivalTime)