diff --git a/aman/sys/RecedingHorizonControl.py b/aman/sys/RecedingHorizonControl.py index ecc50cb..d254abe 100644 --- a/aman/sys/RecedingHorizonControl.py +++ b/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)