mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Scheduling calculations no longer calculate from midnight and now handle a single 9-5 day as a duration of 1 day, as per industry standard practice.
This commit is contained in:
@@ -83,6 +83,7 @@ jobs:
|
||||
sudo /usr/bin/python -m pip install pytest
|
||||
sudo /usr/bin/python -m pip install isodate
|
||||
sudo /usr/bin/python -m pip install lark
|
||||
sudo /usr/bin/python -m pip install networkx
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
|
||||
@@ -47,15 +47,32 @@ class Usecase:
|
||||
|
||||
for rel in task.IsSuccessorFrom:
|
||||
predecessor = rel.RelatingProcess
|
||||
predecessor_duration = (
|
||||
ifcopenshell.util.date.ifc2datetime(predecessor.TaskTime.ScheduleDuration)
|
||||
if predecessor.TaskTime.ScheduleDuration
|
||||
else datetime.timedelta()
|
||||
)
|
||||
if rel.SequenceType == "FINISH_START":
|
||||
finish = self.get_task_time_attribute(predecessor, "ScheduleFinish")
|
||||
if not finish:
|
||||
continue
|
||||
days = 0 if predecessor_duration.days == 0 else 1
|
||||
duration_type = "WORKTIME"
|
||||
if rel.TimeLag:
|
||||
days = self.get_lag_time_days(rel.TimeLag)
|
||||
days += self.get_lag_time_days(rel.TimeLag)
|
||||
duration_type = rel.TimeLag.DurationType
|
||||
starts.append(self.offset_date(finish, days, duration_type, self.get_calendar(task)))
|
||||
starts.append(self.offset_date(finish, days, duration_type, self.get_calendar(predecessor)))
|
||||
if days:
|
||||
starts.append(
|
||||
datetime.datetime.combine(
|
||||
self.offset_date(finish, days, duration_type, self.get_calendar(task)), datetime.time(9)
|
||||
)
|
||||
)
|
||||
starts.append(
|
||||
datetime.datetime.combine(
|
||||
self.offset_date(finish, days, duration_type, self.get_calendar(predecessor)),
|
||||
datetime.time(9),
|
||||
)
|
||||
)
|
||||
else:
|
||||
starts.append(finish)
|
||||
elif rel.SequenceType == "START_START":
|
||||
@@ -84,25 +101,31 @@ class Usecase:
|
||||
start = self.get_task_time_attribute(predecessor, "ScheduleStart")
|
||||
if not start:
|
||||
continue
|
||||
days = -1
|
||||
duration_type = "WORKTIME"
|
||||
if rel.TimeLag:
|
||||
days = self.get_lag_time_days(rel.TimeLag)
|
||||
days += self.get_lag_time_days(rel.TimeLag)
|
||||
duration_type = rel.TimeLag.DurationType
|
||||
finishes.append(self.offset_date(start, days, duration_type, self.get_calendar(task)))
|
||||
finishes.append(self.offset_date(start, days, duration_type, self.get_calendar(predecessor)))
|
||||
if days or rel.TimeLag:
|
||||
finishes.append(
|
||||
datetime.datetime.combine(
|
||||
self.offset_date(start, days, duration_type, self.get_calendar(task)), datetime.time(17)
|
||||
)
|
||||
)
|
||||
finishes.append(
|
||||
datetime.datetime.combine(
|
||||
self.offset_date(start, days, duration_type, self.get_calendar(predecessor)),
|
||||
datetime.time(17),
|
||||
)
|
||||
)
|
||||
else:
|
||||
finishes.append(start)
|
||||
|
||||
if starts and finishes:
|
||||
start = max(starts)
|
||||
finish = max(finishes)
|
||||
potential_finish = datetime.datetime.combine(
|
||||
ifcopenshell.util.sequence.get_finish_date(
|
||||
start,
|
||||
duration,
|
||||
task.TaskTime.DurationType,
|
||||
self.get_calendar(task),
|
||||
),
|
||||
datetime.datetime.min.time(),
|
||||
potential_finish = ifcopenshell.util.sequence.get_start_or_finish_date(
|
||||
start, duration, task.TaskTime.DurationType, self.get_calendar(task), date_type="FINISH"
|
||||
)
|
||||
if potential_finish > finish:
|
||||
start_ifc = ifcopenshell.util.date.datetime2ifc(start, "IfcDateTime")
|
||||
@@ -116,11 +139,8 @@ class Usecase:
|
||||
return
|
||||
task.TaskTime.ScheduleFinish = finish_ifc
|
||||
task.TaskTime.ScheduleStart = ifcopenshell.util.date.datetime2ifc(
|
||||
ifcopenshell.util.sequence.get_finish_date(
|
||||
finish,
|
||||
-duration,
|
||||
task.TaskTime.DurationType,
|
||||
self.get_calendar(task),
|
||||
ifcopenshell.util.sequence.get_start_or_finish_date(
|
||||
finish, duration, task.TaskTime.DurationType, self.get_calendar(task), date_type="START"
|
||||
),
|
||||
"IfcDateTime",
|
||||
)
|
||||
@@ -131,11 +151,8 @@ class Usecase:
|
||||
return
|
||||
task.TaskTime.ScheduleFinish = finish_ifc
|
||||
task.TaskTime.ScheduleStart = ifcopenshell.util.date.datetime2ifc(
|
||||
ifcopenshell.util.sequence.get_finish_date(
|
||||
finish,
|
||||
-duration,
|
||||
task.TaskTime.DurationType,
|
||||
self.get_calendar(task),
|
||||
ifcopenshell.util.sequence.get_start_or_finish_date(
|
||||
finish, duration, task.TaskTime.DurationType, self.get_calendar(task), date_type="START"
|
||||
),
|
||||
"IfcDateTime",
|
||||
)
|
||||
@@ -146,11 +163,8 @@ class Usecase:
|
||||
return
|
||||
task.TaskTime.ScheduleStart = start_ifc
|
||||
task.TaskTime.ScheduleFinish = ifcopenshell.util.date.datetime2ifc(
|
||||
ifcopenshell.util.sequence.get_finish_date(
|
||||
start,
|
||||
duration,
|
||||
task.TaskTime.DurationType,
|
||||
self.get_calendar(task),
|
||||
ifcopenshell.util.sequence.get_start_or_finish_date(
|
||||
start, duration, task.TaskTime.DurationType, self.get_calendar(task), date_type="FINISH"
|
||||
),
|
||||
"IfcDateTime",
|
||||
)
|
||||
@@ -167,10 +181,7 @@ class Usecase:
|
||||
return self.calendar_cache[task.id()]
|
||||
|
||||
def offset_date(self, date, days, duration_type, calendar):
|
||||
return datetime.datetime.combine(
|
||||
ifcopenshell.util.sequence.get_finish_date(date, datetime.timedelta(days=days), duration_type, calendar),
|
||||
datetime.datetime.min.time(),
|
||||
)
|
||||
return ifcopenshell.util.sequence.offset_date(date, datetime.timedelta(days=days), duration_type, calendar)
|
||||
|
||||
def get_task_time_attribute(self, task, attribute):
|
||||
if task.TaskTime:
|
||||
|
||||
@@ -40,13 +40,21 @@ class Usecase:
|
||||
del self.settings["attributes"]["ScheduleFinish"]
|
||||
|
||||
duration_type = self.settings["attributes"].get("DurationType", self.settings["task_time"].DurationType)
|
||||
if self.settings["attributes"].get("ScheduleFinish", None):
|
||||
self.settings["attributes"]["ScheduleFinish"] = ifcopenshell.util.sequence.get_soonest_working_day(
|
||||
self.settings["attributes"]["ScheduleFinish"], duration_type, self.calendar
|
||||
finish = self.settings["attributes"].get("ScheduleFinish", None)
|
||||
if finish:
|
||||
if isinstance(finish, str):
|
||||
finish = datetime.datetime.fromisoformat(finish)
|
||||
self.settings["attributes"]["ScheduleFinish"] = datetime.datetime.combine(
|
||||
ifcopenshell.util.sequence.get_soonest_working_day(finish, duration_type, self.calendar),
|
||||
datetime.time(17),
|
||||
)
|
||||
if self.settings["attributes"].get("ScheduleStart", None):
|
||||
self.settings["attributes"]["ScheduleStart"] = ifcopenshell.util.sequence.get_soonest_working_day(
|
||||
self.settings["attributes"]["ScheduleStart"], duration_type, self.calendar
|
||||
start = self.settings["attributes"].get("ScheduleStart", None)
|
||||
if start:
|
||||
if isinstance(start, str):
|
||||
start = datetime.datetime.fromisoformat(start)
|
||||
self.settings["attributes"]["ScheduleStart"] = datetime.datetime.combine(
|
||||
ifcopenshell.util.sequence.get_soonest_working_day(start, duration_type, self.calendar),
|
||||
datetime.time(9),
|
||||
)
|
||||
|
||||
for name, value in self.settings["attributes"].items():
|
||||
@@ -76,20 +84,21 @@ class Usecase:
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=self.task)
|
||||
|
||||
def calculate_finish(self):
|
||||
finish_date = ifcopenshell.util.sequence.get_finish_date(
|
||||
finish = ifcopenshell.util.sequence.get_start_or_finish_date(
|
||||
ifcopenshell.util.date.ifc2datetime(self.settings["task_time"].ScheduleStart),
|
||||
ifcopenshell.util.date.ifc2datetime(self.settings["task_time"].ScheduleDuration),
|
||||
self.settings["task_time"].DurationType,
|
||||
self.calendar,
|
||||
date_type="FINISH",
|
||||
)
|
||||
self.settings["task_time"].ScheduleFinish = ifcopenshell.util.date.datetime2ifc(finish_date, "IfcDateTime")
|
||||
self.settings["task_time"].ScheduleFinish = ifcopenshell.util.date.datetime2ifc(finish, "IfcDateTime")
|
||||
|
||||
def calculate_duration(self):
|
||||
start = ifcopenshell.util.date.ifc2datetime(self.settings["task_time"].ScheduleStart)
|
||||
finish = ifcopenshell.util.date.ifc2datetime(self.settings["task_time"].ScheduleFinish)
|
||||
current_date = datetime.date(start.year, start.month, start.day)
|
||||
finish_date = datetime.date(finish.year, finish.month, finish.day)
|
||||
duration = datetime.timedelta()
|
||||
duration = datetime.timedelta(days=1)
|
||||
while current_date < finish_date:
|
||||
if self.settings["task_time"].DurationType == "ELAPSEDTIME" or not self.calendar:
|
||||
duration += datetime.timedelta(days=1)
|
||||
|
||||
@@ -116,14 +116,12 @@ class Usecase:
|
||||
predecessor_types = [rel.SequenceType for rel in task.IsSuccessorFrom]
|
||||
successor_types = [rel.SequenceType for rel in task.IsPredecessorTo]
|
||||
|
||||
if not predecessor_types or (
|
||||
"FINISH_START" not in predecessor_types and "START_START" not in predecessor_types
|
||||
):
|
||||
if not predecessor_types:
|
||||
self.edges.append(("start", task.id(), {"lag_time": 0, "type": "FS"}))
|
||||
if task.TaskTime and task.TaskTime.ScheduleStart:
|
||||
self.start_dates.append(ifcopenshell.util.date.ifc2datetime(task.TaskTime.ScheduleStart))
|
||||
if not successor_types or ("FINISH_START" not in successor_types and "FINISH_FINISH" not in successor_types):
|
||||
self.edges.append((task.id(), "finish", {"lag_time": 0, "type": "FS"}))
|
||||
if not successor_types:
|
||||
self.edges.append((task.id(), "finish", {"lag_time": 0, "type": "FF"}))
|
||||
|
||||
def update_task_times(self):
|
||||
for ifc_definition_id in self.g.nodes:
|
||||
@@ -149,7 +147,7 @@ class Usecase:
|
||||
)
|
||||
|
||||
def offset_date(self, date, days, node):
|
||||
return ifcopenshell.util.sequence.get_finish_date(
|
||||
return ifcopenshell.util.sequence.offset_date(
|
||||
date, datetime.timedelta(days=days), node["duration_type"], node["calendar"]
|
||||
)
|
||||
|
||||
@@ -170,45 +168,74 @@ class Usecase:
|
||||
finish = predecessor_data.get("early_finish")
|
||||
if finish is None:
|
||||
return
|
||||
if not edge["lag_time"]:
|
||||
starts.append(finish)
|
||||
days = 0 if predecessor_data["duration"] == 0 else 1
|
||||
if edge["lag_time"]:
|
||||
days += edge["lag_time"]
|
||||
if days:
|
||||
starts.append(datetime.datetime.combine(self.offset_date(finish, days, data), datetime.time(9)))
|
||||
starts.append(
|
||||
datetime.datetime.combine(
|
||||
self.offset_date(finish, days, predecessor_data), datetime.time(9)
|
||||
)
|
||||
)
|
||||
else:
|
||||
starts.append(self.offset_date(finish, edge["lag_time"], data))
|
||||
starts.append(self.offset_date(finish, edge["lag_time"], predecessor_data))
|
||||
starts.append(finish)
|
||||
elif edge["type"] == "SS":
|
||||
start = predecessor_data.get("early_start")
|
||||
if start is None:
|
||||
return
|
||||
if not edge["lag_time"]:
|
||||
starts.append(start)
|
||||
else:
|
||||
if edge["lag_time"]:
|
||||
starts.append(self.offset_date(start, edge["lag_time"], data))
|
||||
starts.append(self.offset_date(start, edge["lag_time"], predecessor_data))
|
||||
else:
|
||||
starts.append(start)
|
||||
elif edge["type"] == "FF":
|
||||
finish = predecessor_data.get("early_finish")
|
||||
if finish is None:
|
||||
return
|
||||
if not edge["lag_time"]:
|
||||
finishes.append(finish)
|
||||
else:
|
||||
if edge["lag_time"]:
|
||||
finishes.append(self.offset_date(finish, edge["lag_time"], data))
|
||||
finishes.append(self.offset_date(finish, edge["lag_time"], predecessor_data))
|
||||
else:
|
||||
finishes.append(finish)
|
||||
elif edge["type"] == "SF":
|
||||
start = predecessor_data.get("early_start")
|
||||
if start is None:
|
||||
return
|
||||
if not edge["lag_time"]:
|
||||
finishes.append(start)
|
||||
days = -1
|
||||
if edge["lag_time"]:
|
||||
days += edge["lag_time"]
|
||||
if days or edge["lag_time"]:
|
||||
finishes.append(
|
||||
datetime.datetime.combine(self.offset_date(start, days, data), datetime.time(17))
|
||||
)
|
||||
finishes.append(
|
||||
datetime.datetime.combine(
|
||||
self.offset_date(start, days, predecessor_data), datetime.time(17)
|
||||
)
|
||||
)
|
||||
else:
|
||||
finishes.append(self.offset_date(start, edge["lag_time"], data))
|
||||
finishes.append(self.offset_date(start, edge["lag_time"], predecessor_data))
|
||||
finishes.append(start)
|
||||
if starts and finishes:
|
||||
data["early_start"] = max(starts)
|
||||
data["early_finish"] = max(finishes)
|
||||
if self.offset_date(data["early_start"], data["duration"], data) > data["early_finish"]:
|
||||
data["early_finish"] = self.offset_date(data["early_start"], data["duration"], data)
|
||||
potential_finish = ifcopenshell.util.sequence.get_start_or_finish_date(
|
||||
data["early_start"],
|
||||
datetime.timedelta(days=data["duration"]),
|
||||
data["duration_type"],
|
||||
data["calendar"],
|
||||
date_type="FINISH",
|
||||
)
|
||||
if potential_finish > data["early_finish"]:
|
||||
data["early_finish"] = potential_finish
|
||||
else:
|
||||
data["early_start"] = self.offset_date(data["early_finish"], -data["duration"], data)
|
||||
data["early_start"] = ifcopenshell.util.sequence.get_start_or_finish_date(
|
||||
data["early_finish"],
|
||||
datetime.timedelta(days=data["duration"]),
|
||||
data["duration_type"],
|
||||
data["calendar"],
|
||||
date_type="START",
|
||||
)
|
||||
elif finishes:
|
||||
data["early_finish"] = max(finishes)
|
||||
elif starts:
|
||||
@@ -217,9 +244,21 @@ class Usecase:
|
||||
print("How did this happen?")
|
||||
|
||||
if data.get("early_finish") is None:
|
||||
data["early_finish"] = self.offset_date(data["early_start"], data["duration"], data)
|
||||
data["early_finish"] = ifcopenshell.util.sequence.get_start_or_finish_date(
|
||||
data["early_start"],
|
||||
datetime.timedelta(days=data["duration"]),
|
||||
data["duration_type"],
|
||||
data["calendar"],
|
||||
date_type="FINISH",
|
||||
)
|
||||
elif data.get("early_start") is None:
|
||||
data["early_start"] = self.offset_date(data["early_finish"], -data["duration"], data)
|
||||
data["early_start"] = ifcopenshell.util.sequence.get_start_or_finish_date(
|
||||
data["early_finish"],
|
||||
datetime.timedelta(days=data["duration"]),
|
||||
data["duration_type"],
|
||||
data["calendar"],
|
||||
date_type="START",
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
@@ -241,25 +280,36 @@ class Usecase:
|
||||
start = successor_data.get("late_start")
|
||||
if start is None:
|
||||
return
|
||||
if not edge["lag_time"]:
|
||||
finishes.append(start)
|
||||
days = 1
|
||||
if edge["lag_time"]:
|
||||
days += edge["lag_time"]
|
||||
if days or edge["lag_time"]:
|
||||
finishes.append(
|
||||
datetime.datetime.combine(self.offset_date(start, -days, data), datetime.time(17))
|
||||
)
|
||||
finishes.append(
|
||||
datetime.datetime.combine(self.offset_date(start, -days, successor_data), datetime.time(17))
|
||||
)
|
||||
else:
|
||||
finishes.append(self.offset_date(start, -edge["lag_time"], data))
|
||||
finishes.append(self.offset_date(start, -edge["lag_time"], successor_data))
|
||||
finishes.append(start)
|
||||
free_floats.append(
|
||||
self.calculate_free_float(
|
||||
data["early_finish"], successor_data["early_start"], edge["lag_time"], data, successor_data
|
||||
data["early_finish"].date() + datetime.timedelta(days=1),
|
||||
successor_data["early_start"].date(),
|
||||
edge["lag_time"],
|
||||
data,
|
||||
successor_data,
|
||||
)
|
||||
)
|
||||
elif edge["type"] == "SS":
|
||||
start = successor_data.get("late_start")
|
||||
if start is None:
|
||||
return
|
||||
if not edge["lag_time"]:
|
||||
starts.append(start)
|
||||
else:
|
||||
if edge["lag_time"]:
|
||||
starts.append(self.offset_date(start, -edge["lag_time"], data))
|
||||
starts.append(self.offset_date(start, -edge["lag_time"], successor_data))
|
||||
else:
|
||||
starts.append(start)
|
||||
free_floats.append(
|
||||
self.calculate_free_float(
|
||||
data["early_start"], successor_data["early_start"], edge["lag_time"], data, successor_data
|
||||
@@ -269,11 +319,11 @@ class Usecase:
|
||||
finish = successor_data.get("late_finish")
|
||||
if finish is None:
|
||||
return
|
||||
if not edge["lag_time"]:
|
||||
finishes.append(finish)
|
||||
else:
|
||||
if edge["lag_time"]:
|
||||
finishes.append(self.offset_date(finish, -edge["lag_time"], data))
|
||||
finishes.append(self.offset_date(finish, -edge["lag_time"], successor_data))
|
||||
else:
|
||||
finishes.append(finish)
|
||||
free_floats.append(
|
||||
self.calculate_free_float(
|
||||
data["early_finish"], successor_data["early_finish"], edge["lag_time"], data, successor_data
|
||||
@@ -283,11 +333,18 @@ class Usecase:
|
||||
finish = successor_data.get("late_finish")
|
||||
if finish is None:
|
||||
return
|
||||
if not edge["lag_time"]:
|
||||
starts.append(finish)
|
||||
days = 0 if successor_data["duration"] == 0 else -1
|
||||
if edge["lag_time"]:
|
||||
days += edge["lag_time"]
|
||||
if days:
|
||||
starts.append(
|
||||
datetime.datetime.combine(self.offset_date(finish, -days, data), datetime.time(9))
|
||||
)
|
||||
starts.append(
|
||||
datetime.datetime.combine(self.offset_date(finish, -days, successor_data), datetime.time(9))
|
||||
)
|
||||
else:
|
||||
starts.append(self.offset_date(finish, -edge["lag_time"], data))
|
||||
starts.append(self.offset_date(finish, -edge["lag_time"], successor_data))
|
||||
starts.append(finish)
|
||||
free_floats.append(
|
||||
self.calculate_free_float(
|
||||
data["early_start"], successor_data["early_finish"], edge["lag_time"], data, successor_data
|
||||
@@ -297,9 +354,21 @@ class Usecase:
|
||||
data["late_start"] = min(starts)
|
||||
data["late_finish"] = min(finishes)
|
||||
if self.offset_date(data["late_start"], data["duration"], data) < data["late_finish"]:
|
||||
data["late_finish"] = self.offset_date(data["late_start"], data["duration"], data)
|
||||
data["late_finish"] = ifcopenshell.util.sequence.get_start_or_finish_date(
|
||||
data["late_start"],
|
||||
datetime.timedelta(days=data["duration"]),
|
||||
data["duration_type"],
|
||||
data["calendar"],
|
||||
date_type="FINISH",
|
||||
)
|
||||
else:
|
||||
data["late_start"] = self.offset_date(data["late_finish"], -data["duration"], data)
|
||||
data["late_start"] = ifcopenshell.util.sequence.get_start_or_finish_date(
|
||||
data["late_finish"],
|
||||
datetime.timedelta(days=data["duration"]),
|
||||
data["duration_type"],
|
||||
data["calendar"],
|
||||
date_type="START",
|
||||
)
|
||||
elif finishes:
|
||||
data["late_finish"] = min(finishes)
|
||||
elif starts:
|
||||
@@ -308,9 +377,21 @@ class Usecase:
|
||||
print("How did this happen?")
|
||||
|
||||
if data.get("late_finish") is None:
|
||||
data["late_finish"] = self.offset_date(data["late_start"], data["duration"], data)
|
||||
data["late_finish"] = ifcopenshell.util.sequence.get_start_or_finish_date(
|
||||
data["late_start"],
|
||||
datetime.timedelta(days=data["duration"]),
|
||||
data["duration_type"],
|
||||
data["calendar"],
|
||||
date_type="FINISH",
|
||||
)
|
||||
elif data.get("late_start") is None:
|
||||
data["late_start"] = self.offset_date(data["late_finish"], -data["duration"], data)
|
||||
data["late_start"] = ifcopenshell.util.sequence.get_start_or_finish_date(
|
||||
data["late_finish"],
|
||||
datetime.timedelta(days=data["duration"]),
|
||||
data["duration_type"],
|
||||
data["calendar"],
|
||||
date_type="START",
|
||||
)
|
||||
|
||||
if data["duration_type"] == "WORKTIME":
|
||||
data["total_float"] = datetime.timedelta(
|
||||
@@ -320,8 +401,14 @@ class Usecase:
|
||||
)
|
||||
else:
|
||||
data["total_float"] = data["late_finish"] - data["early_finish"]
|
||||
# If the float is within the span of a single day, it may show as a 8 hours
|
||||
if data["total_float"].seconds == 60 * 60 * 8:
|
||||
data["total_float"] = datetime.timedelta(days=data["total_float"].days + 1)
|
||||
|
||||
data["free_float"] = min(free_floats) if free_floats else None
|
||||
# If the float is within the span of a single day, it may show as a 8 hours
|
||||
if data["free_float"] and data["free_float"].seconds == 60 * 60 * 8:
|
||||
data["free_float"] = datetime.timedelta(days=data["free_float"].days + 1)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -32,10 +32,10 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
|
||||
task2 = self._create_task("P1D")
|
||||
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-02T00:00:00"
|
||||
assert task2.TaskTime.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-02T00:00:00"
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task2.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
|
||||
def test_only_cascading_to_successors_not_predecessors(self):
|
||||
task = self._create_task("P1D")
|
||||
@@ -45,13 +45,13 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
|
||||
self._create_sequence(task, task3, "FINISH_START", lag="P1D")
|
||||
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task2)
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-02T00:00:00"
|
||||
assert task2.TaskTime.ScheduleStart == "2000-01-02T00:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-04T00:00:00"
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task2.TaskTime.ScheduleStart == "2000-01-02T09:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-03T17:00:00"
|
||||
# We assert that these start finish times have not cascaded
|
||||
assert task3.TaskTime.ScheduleStart == "2000-01-02T00:00:00"
|
||||
assert task3.TaskTime.ScheduleFinish == "2000-01-05T00:00:00"
|
||||
assert task3.TaskTime.ScheduleStart == "2000-01-02T09:00:00"
|
||||
assert task3.TaskTime.ScheduleFinish == "2000-01-04T17:00:00"
|
||||
|
||||
def test_cascading_finish_to_start(self):
|
||||
task = self._create_task("P1D")
|
||||
@@ -61,12 +61,27 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
|
||||
self._create_sequence(task, task3, "FINISH_START", lag="P1D")
|
||||
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-02T00:00:00"
|
||||
assert task2.TaskTime.ScheduleStart == "2000-01-02T00:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-04T00:00:00"
|
||||
assert task3.TaskTime.ScheduleStart == "2000-01-03T00:00:00"
|
||||
assert task3.TaskTime.ScheduleFinish == "2000-01-06T00:00:00"
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task2.TaskTime.ScheduleStart == "2000-01-02T09:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-03T17:00:00"
|
||||
assert task3.TaskTime.ScheduleStart == "2000-01-03T09:00:00"
|
||||
assert task3.TaskTime.ScheduleFinish == "2000-01-05T17:00:00"
|
||||
|
||||
def test_cascading_finish_to_start_for_milestones(self):
|
||||
task = self._create_task("P0D")
|
||||
task2 = self._create_task("P2D")
|
||||
task3 = self._create_task("P3D")
|
||||
self._create_sequence(task, task2, "FINISH_START")
|
||||
self._create_sequence(task, task3, "FINISH_START", lag="P1D")
|
||||
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-01T09:00:00"
|
||||
assert task2.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-02T17:00:00"
|
||||
assert task3.TaskTime.ScheduleStart == "2000-01-02T09:00:00"
|
||||
assert task3.TaskTime.ScheduleFinish == "2000-01-04T17:00:00"
|
||||
|
||||
def test_cascading_finish_to_finish(self):
|
||||
task = self._create_task("P1D")
|
||||
@@ -76,12 +91,12 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
|
||||
self._create_sequence(task, task3, "FINISH_FINISH", lag="P1D")
|
||||
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-02T00:00:00"
|
||||
assert task2.TaskTime.ScheduleStart == "1999-12-31T00:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-02T00:00:00"
|
||||
assert task3.TaskTime.ScheduleStart == "1999-12-31T00:00:00"
|
||||
assert task3.TaskTime.ScheduleFinish == "2000-01-03T00:00:00"
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task2.TaskTime.ScheduleStart == "1999-12-31T09:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task3.TaskTime.ScheduleStart == "1999-12-31T09:00:00"
|
||||
assert task3.TaskTime.ScheduleFinish == "2000-01-02T17:00:00"
|
||||
|
||||
def test_cascading_start_to_start(self):
|
||||
task = self._create_task("P1D")
|
||||
@@ -91,12 +106,12 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
|
||||
self._create_sequence(task, task3, "START_START", lag="P1D")
|
||||
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-02T00:00:00"
|
||||
assert task2.TaskTime.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-03T00:00:00"
|
||||
assert task3.TaskTime.ScheduleStart == "2000-01-02T00:00:00"
|
||||
assert task3.TaskTime.ScheduleFinish == "2000-01-05T00:00:00"
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task2.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-02T17:00:00"
|
||||
assert task3.TaskTime.ScheduleStart == "2000-01-02T09:00:00"
|
||||
assert task3.TaskTime.ScheduleFinish == "2000-01-04T17:00:00"
|
||||
|
||||
def test_cascading_start_to_finish(self):
|
||||
task = self._create_task("P1D")
|
||||
@@ -106,15 +121,32 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
|
||||
self._create_sequence(task, task3, "START_FINISH", lag="P1D")
|
||||
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-02T00:00:00"
|
||||
assert task2.TaskTime.ScheduleStart == "1999-12-30T00:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-01T00:00:00"
|
||||
assert task3.TaskTime.ScheduleStart == "1999-12-30T00:00:00"
|
||||
assert task3.TaskTime.ScheduleFinish == "2000-01-02T00:00:00"
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task2.TaskTime.ScheduleStart == "1999-12-30T09:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "1999-12-31T17:00:00"
|
||||
assert task3.TaskTime.ScheduleStart == "1999-12-30T09:00:00"
|
||||
assert task3.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
|
||||
def test_cascading_start_to_finish_for_milestones(self):
|
||||
task = self._create_task("P0D")
|
||||
task2 = self._create_task("P2D")
|
||||
task3 = self._create_task("P3D")
|
||||
self._create_sequence(task, task2, "START_FINISH")
|
||||
self._create_sequence(task, task3, "START_FINISH", lag="P1D")
|
||||
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-01T09:00:00"
|
||||
assert task2.TaskTime.ScheduleStart == "1999-12-30T09:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "1999-12-31T17:00:00"
|
||||
assert task3.TaskTime.ScheduleStart == "1999-12-30T09:00:00"
|
||||
assert task3.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
|
||||
def _create_task(self, duration):
|
||||
task = ifcopenshell.api.run("sequence.add_task", self.file)
|
||||
if duration == "P0D":
|
||||
task.IsMilestone = True
|
||||
task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=task)
|
||||
ifcopenshell.api.run(
|
||||
"sequence.edit_task_time",
|
||||
|
||||
@@ -34,19 +34,19 @@ class TestEditTaskTime(test.bootstrap.IFC4):
|
||||
"UserDefinedDataOrigin": "UserDefinedDataOrigin",
|
||||
"DurationType": "ELAPSEDTIME",
|
||||
"ScheduleDuration": "P1D",
|
||||
"ScheduleStart": "2000-01-01T00:00:00",
|
||||
"ScheduleFinish": "2000-01-02T00:00:00",
|
||||
"ScheduleStart": "2000-01-01T09:00:00",
|
||||
"ScheduleFinish": "2000-01-01T17:00:00",
|
||||
"EarlyStart": "2000-01-01T00:00:00",
|
||||
"EarlyFinish": "2000-01-02T00:00:00",
|
||||
"EarlyFinish": "2000-01-01T00:00:00",
|
||||
"LateStart": "2000-01-01T00:00:00",
|
||||
"LateFinish": "2000-01-02T00:00:00",
|
||||
"LateFinish": "2000-01-01T00:00:00",
|
||||
"FreeFloat": "P0D",
|
||||
"TotalFloat": "P0D",
|
||||
"IsCritical": True,
|
||||
"StatusTime": "2000-01-01T00:00:00",
|
||||
"ActualDuration": "P1D",
|
||||
"ActualStart": "2000-01-01T00:00:00",
|
||||
"ActualFinish": "2000-01-02T00:00:00",
|
||||
"ActualStart": "2000-01-01T09:00:00",
|
||||
"ActualFinish": "2000-01-01T17:00:00",
|
||||
"RemainingTime": "P1D",
|
||||
"Completion": 0.5,
|
||||
},
|
||||
@@ -56,19 +56,19 @@ class TestEditTaskTime(test.bootstrap.IFC4):
|
||||
assert task_time.UserDefinedDataOrigin == "UserDefinedDataOrigin"
|
||||
assert task_time.DurationType == "ELAPSEDTIME"
|
||||
assert task_time.ScheduleDuration == "P1D"
|
||||
assert task_time.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task_time.ScheduleFinish == "2000-01-02T00:00:00"
|
||||
assert task_time.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task_time.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task_time.EarlyStart == "2000-01-01T00:00:00"
|
||||
assert task_time.EarlyFinish == "2000-01-02T00:00:00"
|
||||
assert task_time.EarlyFinish == "2000-01-01T00:00:00"
|
||||
assert task_time.LateStart == "2000-01-01T00:00:00"
|
||||
assert task_time.LateFinish == "2000-01-02T00:00:00"
|
||||
assert task_time.LateFinish == "2000-01-01T00:00:00"
|
||||
assert task_time.FreeFloat == "P0D"
|
||||
assert task_time.TotalFloat == "P0D"
|
||||
assert task_time.IsCritical == True
|
||||
assert task_time.StatusTime == "2000-01-01T00:00:00"
|
||||
assert task_time.ActualDuration == "P1D"
|
||||
assert task_time.ActualStart == "2000-01-01T00:00:00"
|
||||
assert task_time.ActualFinish == "2000-01-02T00:00:00"
|
||||
assert task_time.ActualStart == "2000-01-01T09:00:00"
|
||||
assert task_time.ActualFinish == "2000-01-01T17:00:00"
|
||||
assert task_time.RemainingTime == "P1D"
|
||||
assert task_time.Completion == 0.5
|
||||
|
||||
@@ -80,11 +80,11 @@ class TestEditTaskTime(test.bootstrap.IFC4):
|
||||
task_time=task_time,
|
||||
attributes={
|
||||
"ScheduleDuration": None,
|
||||
"ScheduleStart": "2000-01-01T00:00:00",
|
||||
"ScheduleStart": "2000-01-01T09:00:00",
|
||||
"ScheduleFinish": None,
|
||||
},
|
||||
)
|
||||
assert task_time.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task_time.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task_time.ScheduleFinish is None
|
||||
assert task_time.ScheduleDuration is None
|
||||
|
||||
@@ -104,7 +104,7 @@ class TestEditTaskTime(test.bootstrap.IFC4):
|
||||
"ScheduleFinish": None,
|
||||
},
|
||||
)
|
||||
assert task_time.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task_time.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task_time.ScheduleFinish is None
|
||||
assert task_time.ScheduleDuration is None
|
||||
|
||||
@@ -117,13 +117,13 @@ class TestEditTaskTime(test.bootstrap.IFC4):
|
||||
attributes={
|
||||
"DurationType": "ELAPSEDTIME",
|
||||
"ScheduleDuration": "P1D",
|
||||
"ScheduleStart": "2000-01-01T00:00:00",
|
||||
"ScheduleStart": "2000-01-01T09:00:00",
|
||||
},
|
||||
)
|
||||
assert task_time.DurationType == "ELAPSEDTIME"
|
||||
assert task_time.ScheduleDuration == "P1D"
|
||||
assert task_time.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task_time.ScheduleFinish == "2000-01-02T00:00:00"
|
||||
assert task_time.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task_time.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
|
||||
def test_schedule_durations_are_auto_calculated_if_possible(self):
|
||||
task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.file.createIfcTask())
|
||||
@@ -133,14 +133,14 @@ class TestEditTaskTime(test.bootstrap.IFC4):
|
||||
task_time=task_time,
|
||||
attributes={
|
||||
"DurationType": "ELAPSEDTIME",
|
||||
"ScheduleStart": "2000-01-01T00:00:00",
|
||||
"ScheduleFinish": "2000-01-02T00:00:00",
|
||||
"ScheduleStart": "2000-01-01T09:00:00",
|
||||
"ScheduleFinish": "2000-01-01T17:00:00",
|
||||
},
|
||||
)
|
||||
assert task_time.DurationType == "ELAPSEDTIME"
|
||||
assert task_time.ScheduleDuration == "P1D"
|
||||
assert task_time.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task_time.ScheduleFinish == "2000-01-02T00:00:00"
|
||||
assert task_time.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task_time.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
|
||||
def test_a_duration_takes_priority_over_start_and_finish_dates(self):
|
||||
task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.file.createIfcTask())
|
||||
@@ -151,14 +151,14 @@ class TestEditTaskTime(test.bootstrap.IFC4):
|
||||
attributes={
|
||||
"DurationType": "ELAPSEDTIME",
|
||||
"ScheduleDuration": "P1D",
|
||||
"ScheduleStart": "2000-01-01T00:00:00",
|
||||
"ScheduleFinish": "2000-01-03T00:00:00",
|
||||
"ScheduleStart": "2000-01-01T09:00:00",
|
||||
"ScheduleFinish": "2000-01-03T17:00:00",
|
||||
},
|
||||
)
|
||||
assert task_time.DurationType == "ELAPSEDTIME"
|
||||
assert task_time.ScheduleDuration == "P1D"
|
||||
assert task_time.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task_time.ScheduleFinish == "2000-01-02T00:00:00"
|
||||
assert task_time.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task_time.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
|
||||
def test_durations_can_be_specified_in_datetime_objects(self):
|
||||
task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.file.createIfcTask())
|
||||
@@ -169,13 +169,13 @@ class TestEditTaskTime(test.bootstrap.IFC4):
|
||||
attributes={
|
||||
"DurationType": "ELAPSEDTIME",
|
||||
"ScheduleDuration": datetime.timedelta(days=1),
|
||||
"ScheduleStart": "2000-01-01T00:00:00",
|
||||
"ScheduleStart": "2000-01-01T09:00:00",
|
||||
},
|
||||
)
|
||||
assert task_time.DurationType == "ELAPSEDTIME"
|
||||
assert task_time.ScheduleDuration == "P1D"
|
||||
assert task_time.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task_time.ScheduleFinish == "2000-01-02T00:00:00"
|
||||
assert task_time.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task_time.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
|
||||
def test_zero_durations_are_allowed(self):
|
||||
task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.file.createIfcTask())
|
||||
@@ -186,10 +186,10 @@ class TestEditTaskTime(test.bootstrap.IFC4):
|
||||
attributes={
|
||||
"DurationType": "ELAPSEDTIME",
|
||||
"ScheduleDuration": datetime.timedelta(),
|
||||
"ScheduleStart": "2000-01-01T00:00:00",
|
||||
"ScheduleStart": "2000-01-01T09:00:00",
|
||||
},
|
||||
)
|
||||
assert task_time.DurationType == "ELAPSEDTIME"
|
||||
assert task_time.ScheduleDuration == "P0D"
|
||||
assert task_time.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task_time.ScheduleFinish == "2000-01-01T00:00:00"
|
||||
assert task_time.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task_time.ScheduleFinish == "2000-01-01T09:00:00"
|
||||
|
||||
@@ -0,0 +1,284 @@
|
||||
# IfcOpenShell - IFC toolkit and geometry engine
|
||||
# Copyright (C) 2022 Dion Moult <dion@thinkmoult.com>
|
||||
#
|
||||
# This file is part of IfcOpenShell.
|
||||
#
|
||||
# IfcOpenShell is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# IfcOpenShell is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import datetime
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
# A good way for checking these is to recreate them in ProjectLibre
|
||||
class TestRecalculateSchedule(test.bootstrap.IFC4):
|
||||
def test_doing_nothing_if_the_task_has_no_time(self):
|
||||
self._add_work_schedule()
|
||||
task = ifcopenshell.api.run("sequence.add_task", self.file)
|
||||
ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
|
||||
assert task.TaskTime is None
|
||||
|
||||
def test_recalculating_for_a_single_task(self):
|
||||
self._add_work_schedule()
|
||||
task = self._create_task("P1D")
|
||||
ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.EarlyStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.EarlyFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.LateStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.LateFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.TotalFloat == "P0D"
|
||||
assert task.TaskTime.FreeFloat == "P0D"
|
||||
assert task.TaskTime.IsCritical is True
|
||||
|
||||
def test_recalculating_finish_to_start(self):
|
||||
self._add_work_schedule()
|
||||
task = self._create_task("P1D")
|
||||
task2 = self._create_task("P2D")
|
||||
self._create_sequence(task, task2, "FINISH_START")
|
||||
ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.EarlyStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.EarlyFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.LateStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.LateFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.TotalFloat == "P0D"
|
||||
assert task.TaskTime.FreeFloat == "P0D"
|
||||
assert task.TaskTime.IsCritical is True
|
||||
assert task2.TaskTime.ScheduleStart == "2000-01-02T09:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-03T17:00:00"
|
||||
assert task2.TaskTime.EarlyStart == "2000-01-02T09:00:00"
|
||||
assert task2.TaskTime.EarlyFinish == "2000-01-03T17:00:00"
|
||||
assert task2.TaskTime.LateStart == "2000-01-02T09:00:00"
|
||||
assert task2.TaskTime.LateFinish == "2000-01-03T17:00:00"
|
||||
assert task2.TaskTime.TotalFloat == "P0D"
|
||||
assert task2.TaskTime.FreeFloat == "P0D"
|
||||
assert task2.TaskTime.IsCritical is True
|
||||
|
||||
def test_recalculating_multiple_finish_to_start(self):
|
||||
self._add_work_schedule()
|
||||
task = self._create_task("P1D")
|
||||
task2 = self._create_task("P2D")
|
||||
task3 = self._create_task("P3D")
|
||||
self._create_sequence(task, task2, "FINISH_START")
|
||||
self._create_sequence(task, task3, "FINISH_START", lag="P1D")
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
|
||||
ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.EarlyStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.EarlyFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.LateStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.LateFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.TotalFloat == "P0D"
|
||||
assert task.TaskTime.FreeFloat == "P0D"
|
||||
assert task.TaskTime.IsCritical is True
|
||||
assert task2.TaskTime.ScheduleStart == "2000-01-02T09:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-03T17:00:00"
|
||||
assert task2.TaskTime.EarlyStart == "2000-01-02T09:00:00"
|
||||
assert task2.TaskTime.EarlyFinish == "2000-01-03T17:00:00"
|
||||
assert task2.TaskTime.LateStart == "2000-01-04T09:00:00"
|
||||
assert task2.TaskTime.LateFinish == "2000-01-05T17:00:00"
|
||||
assert task2.TaskTime.TotalFloat == "P2D"
|
||||
assert task2.TaskTime.FreeFloat == "P2D"
|
||||
assert task2.TaskTime.IsCritical is False
|
||||
assert task3.TaskTime.ScheduleStart == "2000-01-03T09:00:00"
|
||||
assert task3.TaskTime.ScheduleFinish == "2000-01-05T17:00:00"
|
||||
assert task3.TaskTime.EarlyStart == "2000-01-03T09:00:00"
|
||||
assert task3.TaskTime.EarlyFinish == "2000-01-05T17:00:00"
|
||||
assert task3.TaskTime.LateStart == "2000-01-03T09:00:00"
|
||||
assert task3.TaskTime.LateFinish == "2000-01-05T17:00:00"
|
||||
assert task3.TaskTime.TotalFloat == "P0D"
|
||||
assert task3.TaskTime.FreeFloat == "P0D"
|
||||
assert task3.TaskTime.IsCritical is True
|
||||
|
||||
def test_recalculating_finish_to_start_with_a_milestone(self):
|
||||
self._add_work_schedule()
|
||||
task = self._create_task("P1D")
|
||||
task2 = self._create_task("P2D")
|
||||
task3 = self._create_task("P0D")
|
||||
self._create_sequence(task, task2, "FINISH_START")
|
||||
self._create_sequence(task, task3, "FINISH_START", lag="P1D")
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
|
||||
ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.EarlyStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.EarlyFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.LateStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.LateFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.TotalFloat == "P0D"
|
||||
assert task.TaskTime.FreeFloat == "P0D"
|
||||
assert task.TaskTime.IsCritical is True
|
||||
assert task2.TaskTime.ScheduleStart == "2000-01-02T09:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-03T17:00:00"
|
||||
assert task2.TaskTime.EarlyStart == "2000-01-02T09:00:00"
|
||||
assert task2.TaskTime.EarlyFinish == "2000-01-03T17:00:00"
|
||||
assert task2.TaskTime.LateStart == "2000-01-02T09:00:00"
|
||||
assert task2.TaskTime.LateFinish == "2000-01-03T17:00:00"
|
||||
assert task2.TaskTime.TotalFloat == "P0D"
|
||||
assert task2.TaskTime.FreeFloat == "P0D"
|
||||
assert task2.TaskTime.IsCritical is True
|
||||
assert task3.TaskTime.ScheduleStart == "2000-01-03T09:00:00"
|
||||
assert task3.TaskTime.ScheduleFinish == "2000-01-03T09:00:00"
|
||||
assert task3.TaskTime.EarlyStart == "2000-01-03T09:00:00"
|
||||
assert task3.TaskTime.EarlyFinish == "2000-01-03T09:00:00"
|
||||
assert task3.TaskTime.LateStart == "2000-01-03T17:00:00"
|
||||
assert task3.TaskTime.LateFinish == "2000-01-03T17:00:00"
|
||||
assert task3.TaskTime.TotalFloat == "P1D"
|
||||
assert task3.TaskTime.FreeFloat == "P1D"
|
||||
assert task3.TaskTime.IsCritical is False
|
||||
|
||||
def test_recalculating_finish_to_start_with_a_milestone_as_the_last_task(self):
|
||||
self._add_work_schedule()
|
||||
task = self._create_task("P1D")
|
||||
task2 = self._create_task("P2D")
|
||||
task3 = self._create_task("P0D")
|
||||
self._create_sequence(task, task2, "FINISH_START")
|
||||
self._create_sequence(task2, task3, "FINISH_START")
|
||||
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
|
||||
ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.EarlyStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.EarlyFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.LateStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.LateFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.TotalFloat == "P0D"
|
||||
assert task.TaskTime.FreeFloat == "P0D"
|
||||
assert task.TaskTime.IsCritical is True
|
||||
assert task2.TaskTime.ScheduleStart == "2000-01-02T09:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-03T17:00:00"
|
||||
assert task2.TaskTime.EarlyStart == "2000-01-02T09:00:00"
|
||||
assert task2.TaskTime.EarlyFinish == "2000-01-03T17:00:00"
|
||||
assert task2.TaskTime.LateStart == "2000-01-02T09:00:00"
|
||||
assert task2.TaskTime.LateFinish == "2000-01-03T17:00:00"
|
||||
assert task2.TaskTime.TotalFloat == "P0D"
|
||||
assert task2.TaskTime.FreeFloat == "P0D"
|
||||
assert task2.TaskTime.IsCritical is True
|
||||
assert task3.TaskTime.ScheduleStart == "2000-01-04T09:00:00"
|
||||
assert task3.TaskTime.ScheduleFinish == "2000-01-04T09:00:00"
|
||||
assert task3.TaskTime.EarlyStart == "2000-01-04T09:00:00"
|
||||
assert task3.TaskTime.EarlyFinish == "2000-01-04T09:00:00"
|
||||
assert task3.TaskTime.LateStart == "2000-01-04T09:00:00"
|
||||
assert task3.TaskTime.LateFinish == "2000-01-04T09:00:00"
|
||||
assert task3.TaskTime.TotalFloat == "P0D"
|
||||
assert task3.TaskTime.FreeFloat == "P0D"
|
||||
assert task3.TaskTime.IsCritical is True
|
||||
|
||||
def test_recalculating_finish_to_finish(self):
|
||||
self._add_work_schedule()
|
||||
task = self._create_task("P1D")
|
||||
task2 = self._create_task("P2D")
|
||||
self._create_sequence(task, task2, "FINISH_FINISH")
|
||||
ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.EarlyStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.EarlyFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.LateStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.LateFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.TotalFloat == "P0D"
|
||||
assert task.TaskTime.FreeFloat == "P0D"
|
||||
assert task.TaskTime.IsCritical is True
|
||||
assert task2.TaskTime.ScheduleStart == "1999-12-31T09:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task2.TaskTime.EarlyStart == "1999-12-31T09:00:00"
|
||||
assert task2.TaskTime.EarlyFinish == "2000-01-01T17:00:00"
|
||||
assert task2.TaskTime.LateStart == "1999-12-31T09:00:00"
|
||||
assert task2.TaskTime.LateFinish == "2000-01-01T17:00:00"
|
||||
assert task2.TaskTime.TotalFloat == "P0D"
|
||||
assert task2.TaskTime.FreeFloat == "P0D"
|
||||
assert task2.TaskTime.IsCritical is True
|
||||
|
||||
def test_recalculating_start_to_start(self):
|
||||
self._add_work_schedule()
|
||||
task = self._create_task("P1D")
|
||||
task2 = self._create_task("P2D")
|
||||
self._create_sequence(task, task2, "START_START")
|
||||
ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.EarlyStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.EarlyFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.LateStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.LateFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.TotalFloat == "P0D"
|
||||
assert task.TaskTime.FreeFloat == "P0D"
|
||||
assert task.TaskTime.IsCritical is True
|
||||
assert task2.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "2000-01-02T17:00:00"
|
||||
assert task2.TaskTime.EarlyStart == "2000-01-01T09:00:00"
|
||||
assert task2.TaskTime.EarlyFinish == "2000-01-02T17:00:00"
|
||||
assert task2.TaskTime.LateStart == "2000-01-01T09:00:00"
|
||||
assert task2.TaskTime.LateFinish == "2000-01-02T17:00:00"
|
||||
assert task2.TaskTime.TotalFloat == "P0D"
|
||||
assert task2.TaskTime.FreeFloat == "P0D"
|
||||
assert task2.TaskTime.IsCritical is True
|
||||
|
||||
def test_recalculating_start_to_finish(self):
|
||||
self._add_work_schedule()
|
||||
task = self._create_task("P1D")
|
||||
task2 = self._create_task("P2D")
|
||||
self._create_sequence(task, task2, "START_FINISH")
|
||||
ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
|
||||
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.EarlyStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.EarlyFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.LateStart == "2000-01-01T09:00:00"
|
||||
assert task.TaskTime.LateFinish == "2000-01-01T17:00:00"
|
||||
assert task.TaskTime.TotalFloat == "P0D"
|
||||
assert task.TaskTime.FreeFloat == "P0D"
|
||||
assert task.TaskTime.IsCritical is True
|
||||
assert task2.TaskTime.ScheduleStart == "1999-12-30T09:00:00"
|
||||
assert task2.TaskTime.ScheduleFinish == "1999-12-31T17:00:00"
|
||||
assert task2.TaskTime.EarlyStart == "1999-12-30T09:00:00"
|
||||
assert task2.TaskTime.EarlyFinish == "1999-12-31T17:00:00"
|
||||
assert task2.TaskTime.LateStart == "1999-12-30T09:00:00"
|
||||
assert task2.TaskTime.LateFinish == "1999-12-31T17:00:00"
|
||||
assert task2.TaskTime.TotalFloat == "P0D"
|
||||
assert task2.TaskTime.FreeFloat == "P0D"
|
||||
assert task2.TaskTime.IsCritical is True
|
||||
|
||||
def _add_work_schedule(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
self.work_schedule = ifcopenshell.api.run("sequence.add_work_schedule", self.file)
|
||||
|
||||
def _create_task(self, duration):
|
||||
task = ifcopenshell.api.run("sequence.add_task", self.file, work_schedule=self.work_schedule)
|
||||
if duration == "P0D":
|
||||
task.IsMilestone = True
|
||||
task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=task)
|
||||
ifcopenshell.api.run(
|
||||
"sequence.edit_task_time",
|
||||
self.file,
|
||||
task_time=task_time,
|
||||
attributes={"ScheduleStart": datetime.date(2000, 1, 1), "ScheduleDuration": duration},
|
||||
)
|
||||
return task
|
||||
|
||||
def _create_sequence(self, predecessor, successor, relationship, lag=None):
|
||||
rel = ifcopenshell.api.run(
|
||||
"sequence.assign_sequence", self.file, relating_process=predecessor, related_process=successor
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"sequence.edit_sequence", self.file, rel_sequence=rel, attributes={"SequenceType": relationship}
|
||||
)
|
||||
if lag:
|
||||
ifcopenshell.api.run(
|
||||
"sequence.assign_lag_time", self.file, rel_sequence=rel, lag_value=lag, duration_type="WORKTIME"
|
||||
)
|
||||
Reference in New Issue
Block a user