2021-03-31 11:35:40 +11:00
|
|
|
import ifcopenshell.util.date
|
|
|
|
|
|
2021-02-17 22:54:11 +11:00
|
|
|
class Data:
|
|
|
|
|
is_loaded = False
|
2021-03-31 11:35:40 +11:00
|
|
|
work_plans = {}
|
2021-04-07 00:51:20 +01:00
|
|
|
work_schedules = {}
|
2021-02-17 22:54:11 +11:00
|
|
|
tasks = {}
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def purge(cls):
|
|
|
|
|
cls.is_loaded = False
|
2021-03-31 11:35:40 +11:00
|
|
|
cls.work_plans = {}
|
2021-04-07 00:51:20 +01:00
|
|
|
cls.work_schedules = {}
|
|
|
|
|
cls.work_calendars = {}
|
2021-02-17 22:54:11 +11:00
|
|
|
cls.tasks = {}
|
|
|
|
|
|
|
|
|
|
@classmethod
|
2021-03-25 10:48:31 +11:00
|
|
|
def load(cls, file):
|
2021-04-07 00:04:57 +01:00
|
|
|
cls._file = file
|
|
|
|
|
if not cls._file:
|
|
|
|
|
return
|
|
|
|
|
cls.load_work_plans()
|
|
|
|
|
cls.load_work_schedules()
|
2021-04-07 00:51:20 +01:00
|
|
|
cls.load_work_calendars()
|
2021-04-07 00:04:57 +01:00
|
|
|
cls.load_tasks()
|
|
|
|
|
cls.is_loaded=True
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def load_work_plans(cls):
|
2021-03-31 11:35:40 +11:00
|
|
|
cls.work_plans = {}
|
2021-04-07 00:04:57 +01:00
|
|
|
for work_plan in cls._file.by_type("IfcWorkPlan"):
|
2021-03-31 11:35:40 +11:00
|
|
|
data = work_plan.get_info()
|
|
|
|
|
del data["OwnerHistory"]
|
|
|
|
|
if data["Creators"]:
|
|
|
|
|
data["Creators"] = [p.id() for p in data["Creators"]]
|
2021-04-07 00:04:57 +01:00
|
|
|
data["CreationDate"] = ifcopenshell.util.date.ifc2datetime(data["CreationDate"]).isoformat()
|
|
|
|
|
data["StartTime"] = ifcopenshell.util.date.ifc2datetime(data["StartTime"]).isoformat()
|
2021-03-31 11:35:40 +11:00
|
|
|
if data["FinishTime"]:
|
2021-04-07 00:04:57 +01:00
|
|
|
data["FinishTime"] = ifcopenshell.util.date.ifc2datetime(data["FinishTime"]).isoformat()
|
2021-03-31 11:35:40 +11:00
|
|
|
cls.work_plans[work_plan.id()] = data
|
2021-04-07 00:04:57 +01:00
|
|
|
|
2021-04-07 00:51:20 +01:00
|
|
|
@classmethod
|
|
|
|
|
def load_work_schedules(cls):
|
|
|
|
|
cls.work_schedules = {}
|
|
|
|
|
for work_schedule in cls._file.by_type("IfcWorkSchedule"):
|
|
|
|
|
data = work_schedule.get_info()
|
|
|
|
|
del data["OwnerHistory"]
|
|
|
|
|
if data["Creators"]:
|
|
|
|
|
data["Creators"] = [p.id() for p in data["Creators"]]
|
|
|
|
|
data["CreationDate"] = ifcopenshell.util.date.ifc2datetime(data["CreationDate"]).isoformat()
|
|
|
|
|
data["StartTime"] = ifcopenshell.util.date.ifc2datetime(data["StartTime"]).isoformat()
|
|
|
|
|
if data["FinishTime"]:
|
|
|
|
|
data["FinishTime"] = ifcopenshell.util.date.ifc2datetime(data["FinishTime"]).isoformat()
|
|
|
|
|
cls.work_schedules[work_schedule.id()] = data
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def load_work_calendars(cls):
|
|
|
|
|
for work_calendar in cls._file.by_type("IfcWorkCalendar"):
|
|
|
|
|
data = work_calendar.get_info()
|
|
|
|
|
del data["OwnerHistory"]
|
|
|
|
|
##### HOW DO WE NEST ENTITIES SUCH AS WORKTIME? ####
|
|
|
|
|
##### HOW TO ALLOW DISPLAY OF TIME? AND DATES? ####
|
|
|
|
|
del data["WorkingTimes"]
|
|
|
|
|
del data["ExceptionTimes"]
|
|
|
|
|
# if data["WorkingTimes"]:
|
|
|
|
|
# for worktime in data["WorkingTimes"]:
|
|
|
|
|
# worktime_data = {}
|
|
|
|
|
# if worktime.Start:
|
|
|
|
|
# worktime_data["start"] = ifcopenshell.util.date.ifc2datetime(worktime.Start).isoformat()
|
|
|
|
|
# if worktime.Start:
|
|
|
|
|
# worktime_data["finish"] = ifcopenshell.util.date.ifc2datetime(worktime.Start).isoformat()
|
|
|
|
|
# worktime = worktime_data
|
|
|
|
|
# if data["ExceptionTimes"]:
|
|
|
|
|
# for exceptiontime in data["ExceptionTimes"]:
|
|
|
|
|
# exceptiontime_data = {}
|
|
|
|
|
# exceptiontime_data["start"] = ifcopenshell.util.date.ifc2datetime(exceptiontime.Finish).isoformat()
|
|
|
|
|
# exceptiontime_data["finish"] = ifcopenshell.util.date.ifc2datetime(exceptiontime.Finish).isoformat()
|
|
|
|
|
# exceptiontime = exceptiontime_data
|
|
|
|
|
cls.work_calendars[work_calendar.id()] = data
|
|
|
|
|
|
2021-04-07 00:04:57 +01:00
|
|
|
@classmethod
|
|
|
|
|
def load_tasks(cls):
|
|
|
|
|
cls.tasks = {}
|
|
|
|
|
for task in cls._file.by_type("IfcTask"):
|
2021-02-17 22:54:11 +11:00
|
|
|
cls.tasks[task.id()] = {"Name": task.Name, "Identification": task.Identification or ""}
|