From 7b957af9e11031fcdb47d0745de36fdb1fff3523 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Tue, 20 Apr 2021 12:55:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- runtime.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/runtime.py b/runtime.py index 85df7ee..4c5d379 100644 --- a/runtime.py +++ b/runtime.py @@ -124,10 +124,9 @@ class RuntimeResource: return False for resource_need in self.schedules: - if resource_need.end > schedule.start: + if resource_need.end > schedule.start > resource_need.start: pre_need = resource_need - if back_need is not None \ - and resource_need.start < resource_need.end: + if resource_need.start < schedule.end < resource_need.end: back_need = resource_need if pre_need is not None or back_need is not None: @@ -148,7 +147,7 @@ class RuntimeResource: if len(self.schedules) == 1: target_schedule = self.schedules[0] if self.start_time < target_schedule.start: - if target_schedule.start - self.start_time > duration + timedelta(minutes=1): + if target_schedule.start - self.start_time > duration: return target_schedule.start - duration else: @@ -158,11 +157,11 @@ class RuntimeResource: pre_schedule = self.schedules[i] back_schedule = self.schedules[i + 1] - if self.start_time < pre_schedule.start: - if pre_schedule.start - self.start_time > duration + timedelta(minutes=1): - return pre_schedule.start - duration - timedelta(minutes=1) + if self.start_time < pre_schedule.start and i == 0: + if pre_schedule.start - self.start_time > duration: + return pre_schedule.start - duration - elif back_schedule.start - pre_schedule.end > duration + timedelta(minutes=1): + elif back_schedule.start - pre_schedule.end > duration: return pre_schedule.end return self.schedules[-1].end