Spaces:
Sleeping
Sleeping
Upload data_persistence.py
Browse files- app/data_persistence.py +47 -9
app/data_persistence.py
CHANGED
@@ -15,7 +15,7 @@ import pickle
|
|
15 |
from datetime import datetime
|
16 |
|
17 |
# Import data models
|
18 |
-
from data.building_components import Wall, Roof, Floor, Window, Door, Orientation, ComponentType
|
19 |
|
20 |
|
21 |
class DataPersistence:
|
@@ -114,7 +114,8 @@ class DataPersistence:
|
|
114 |
"roofs": [],
|
115 |
"floors": [],
|
116 |
"windows": [],
|
117 |
-
"doors": []
|
|
|
118 |
}
|
119 |
|
120 |
# Serialize walls
|
@@ -179,6 +180,19 @@ class DataPersistence:
|
|
179 |
|
180 |
serialized_components["doors"].append(serialized_door)
|
181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
return serialized_components
|
183 |
|
184 |
@staticmethod
|
@@ -197,7 +211,8 @@ class DataPersistence:
|
|
197 |
"roofs": [],
|
198 |
"floors": [],
|
199 |
"windows": [],
|
200 |
-
"doors": []
|
|
|
201 |
}
|
202 |
|
203 |
# Deserialize walls
|
@@ -210,7 +225,8 @@ class DataPersistence:
|
|
210 |
area=wall_dict.get("area", 0.0),
|
211 |
orientation=Orientation[wall_dict.get("orientation", "NORTH")],
|
212 |
wall_type=wall_dict.get("wall_type", ""),
|
213 |
-
wall_group=wall_dict.get("wall_group", "")
|
|
|
214 |
)
|
215 |
components["walls"].append(wall)
|
216 |
|
@@ -224,7 +240,8 @@ class DataPersistence:
|
|
224 |
area=roof_dict.get("area", 0.0),
|
225 |
orientation=Orientation[roof_dict.get("orientation", "HORIZONTAL")],
|
226 |
roof_type=roof_dict.get("roof_type", ""),
|
227 |
-
roof_group=roof_dict.get("roof_group", "")
|
|
|
228 |
)
|
229 |
components["roofs"].append(roof)
|
230 |
|
@@ -236,7 +253,8 @@ class DataPersistence:
|
|
236 |
component_type=ComponentType[floor_dict.get("component_type", "FLOOR")],
|
237 |
u_value=floor_dict.get("u_value", 0.0),
|
238 |
area=floor_dict.get("area", 0.0),
|
239 |
-
floor_type=floor_dict.get("floor_type", "")
|
|
|
240 |
)
|
241 |
components["floors"].append(floor)
|
242 |
|
@@ -254,7 +272,8 @@ class DataPersistence:
|
|
254 |
window_type=window_dict.get("window_type", ""),
|
255 |
glazing_layers=window_dict.get("glazing_layers", 1),
|
256 |
gas_fill=window_dict.get("gas_fill", ""),
|
257 |
-
low_e_coating=window_dict.get("low_e_coating", False)
|
|
|
258 |
)
|
259 |
components["windows"].append(window)
|
260 |
|
@@ -267,10 +286,29 @@ class DataPersistence:
|
|
267 |
u_value=door_dict.get("u_value", 0.0),
|
268 |
area=door_dict.get("area", 0.0),
|
269 |
orientation=Orientation[door_dict.get("orientation", "NORTH")],
|
270 |
-
door_type=door_dict.get("door_type", "")
|
|
|
271 |
)
|
272 |
components["doors"].append(door)
|
273 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
return components
|
275 |
|
276 |
@staticmethod
|
@@ -537,4 +575,4 @@ if __name__ == "__main__":
|
|
537 |
}
|
538 |
|
539 |
# Display project management interface
|
540 |
-
data_persistence.display_project_management(st.session_state)
|
|
|
15 |
from datetime import datetime
|
16 |
|
17 |
# Import data models
|
18 |
+
from data.building_components import Wall, Roof, Floor, Window, Door, Orientation, ComponentType, Skylight
|
19 |
|
20 |
|
21 |
class DataPersistence:
|
|
|
114 |
"roofs": [],
|
115 |
"floors": [],
|
116 |
"windows": [],
|
117 |
+
"doors": [],
|
118 |
+
"skylights": []
|
119 |
}
|
120 |
|
121 |
# Serialize walls
|
|
|
180 |
|
181 |
serialized_components["doors"].append(serialized_door)
|
182 |
|
183 |
+
# Serialize skylights
|
184 |
+
for skylight in components.get("skylights", []):
|
185 |
+
serialized_skylight = skylight.__dict__.copy()
|
186 |
+
|
187 |
+
# Convert enums to strings
|
188 |
+
if hasattr(serialized_skylight["orientation"], "name"):
|
189 |
+
serialized_skylight["orientation"] = serialized_skylight["orientation"].name
|
190 |
+
|
191 |
+
if hasattr(serialized_skylight["component_type"], "name"):
|
192 |
+
serialized_skylight["component_type"] = serialized_skylight["component_type"].name
|
193 |
+
|
194 |
+
serialized_components["skylights"].append(serialized_skylight)
|
195 |
+
|
196 |
return serialized_components
|
197 |
|
198 |
@staticmethod
|
|
|
211 |
"roofs": [],
|
212 |
"floors": [],
|
213 |
"windows": [],
|
214 |
+
"doors": [],
|
215 |
+
"skylights": []
|
216 |
}
|
217 |
|
218 |
# Deserialize walls
|
|
|
225 |
area=wall_dict.get("area", 0.0),
|
226 |
orientation=Orientation[wall_dict.get("orientation", "NORTH")],
|
227 |
wall_type=wall_dict.get("wall_type", ""),
|
228 |
+
wall_group=wall_dict.get("wall_group", ""),
|
229 |
+
solar_absorptivity=wall_dict.get("solar_absorptivity", 0.6)
|
230 |
)
|
231 |
components["walls"].append(wall)
|
232 |
|
|
|
240 |
area=roof_dict.get("area", 0.0),
|
241 |
orientation=Orientation[roof_dict.get("orientation", "HORIZONTAL")],
|
242 |
roof_type=roof_dict.get("roof_type", ""),
|
243 |
+
roof_group=roof_dict.get("roof_group", ""),
|
244 |
+
solar_absorptivity=roof_dict.get("solar_absorptivity", 0.6)
|
245 |
)
|
246 |
components["roofs"].append(roof)
|
247 |
|
|
|
253 |
component_type=ComponentType[floor_dict.get("component_type", "FLOOR")],
|
254 |
u_value=floor_dict.get("u_value", 0.0),
|
255 |
area=floor_dict.get("area", 0.0),
|
256 |
+
floor_type=floor_dict.get("floor_type", ""),
|
257 |
+
solar_absorptivity=floor_dict.get("solar_absorptivity", 0.6)
|
258 |
)
|
259 |
components["floors"].append(floor)
|
260 |
|
|
|
272 |
window_type=window_dict.get("window_type", ""),
|
273 |
glazing_layers=window_dict.get("glazing_layers", 1),
|
274 |
gas_fill=window_dict.get("gas_fill", ""),
|
275 |
+
low_e_coating=window_dict.get("low_e_coating", False),
|
276 |
+
solar_absorptivity=window_dict.get("solar_absorptivity", 0.6)
|
277 |
)
|
278 |
components["windows"].append(window)
|
279 |
|
|
|
286 |
u_value=door_dict.get("u_value", 0.0),
|
287 |
area=door_dict.get("area", 0.0),
|
288 |
orientation=Orientation[door_dict.get("orientation", "NORTH")],
|
289 |
+
door_type=door_dict.get("door_type", ""),
|
290 |
+
solar_absorptivity=door_dict.get("solar_absorptivity", 0.6)
|
291 |
)
|
292 |
components["doors"].append(door)
|
293 |
|
294 |
+
# Deserialize skylights
|
295 |
+
for skylight_dict in serialized_components.get("skylights", []):
|
296 |
+
skylight = Skylight(
|
297 |
+
id=skylight_dict.get("id", ""),
|
298 |
+
name=skylight_dict.get("name", ""),
|
299 |
+
component_type=ComponentType[skylight_dict.get("component_type", "SKYLIGHT")],
|
300 |
+
u_value=skylight_dict.get("u_value", 0.0),
|
301 |
+
area=skylight_dict.get("area", 0.0),
|
302 |
+
orientation=Orientation[skylight_dict.get("orientation", "HORIZONTAL")],
|
303 |
+
shgc=skylight_dict.get("shgc", 0.0),
|
304 |
+
vt=skylight_dict.get("vt", 0.0),
|
305 |
+
skylight_type=skylight_dict.get("skylight_type", ""),
|
306 |
+
frame_type=skylight_dict.get("frame_type", ""),
|
307 |
+
drapery_openness=skylight_dict.get("drapery_openness", "Open"),
|
308 |
+
solar_absorptivity=skylight_dict.get("solar_absorptivity", 0.6)
|
309 |
+
)
|
310 |
+
components["skylights"].append(skylight)
|
311 |
+
|
312 |
return components
|
313 |
|
314 |
@staticmethod
|
|
|
575 |
}
|
576 |
|
577 |
# Display project management interface
|
578 |
+
data_persistence.display_project_management(st.session_state)
|