mabuseif commited on
Commit
fc68faa
·
verified ·
1 Parent(s): b6cc8f1

Update app/components.py

Browse files
Files changed (1) hide show
  1. app/components.py +15 -6
app/components.py CHANGED
@@ -18,6 +18,7 @@ import logging
18
  import uuid
19
  from typing import Dict, List, Any, Optional, Tuple, Union
20
  from app.m_c_data import DEFAULT_WINDOW_PROPERTIES # Import DEFAULT_WINDOW_PROPERTIES
 
21
 
22
  # Configure logging
23
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
@@ -152,7 +153,6 @@ def display_component_tab(comp_type: str):
152
  name = st.text_input(
153
  "Name",
154
  value=editor_state.get("name", ""),
155
-
156
  help="Enter a unique name for this component."
157
  )
158
 
@@ -347,14 +347,21 @@ def display_component_tab(comp_type: str):
347
  component_data["parent_component"] = parent_component
348
  component_data["function_type"] = function_type
349
  component_data["shading_coefficient"] = shading_coefficient
350
- # Get fenestration properties (SHGC, U-Value, h_o) if available
351
  if fenestration in available_items:
352
  fenestration_data = available_items[fenestration]
353
- component_data["shgc"] = fenestration_data.get("shgc", 0.7)
354
- component_data["u_value"] = fenestration_data.get("u_value", 5.0)
355
- component_data["h_o"] = fenestration_data.get("h_o", DEFAULT_WINDOW_PROPERTIES["h_o"])
356
- component_data["visible_transmittance"] = fenestration_data.get("visible_transmittance", 0.7)
 
 
 
 
 
 
357
  else:
 
358
  component_data["shgc"] = 0.7
359
  component_data["u_value"] = 5.0
360
  component_data["h_o"] = DEFAULT_WINDOW_PROPERTIES["h_o"]
@@ -429,6 +436,7 @@ def display_wall_window_table(comp_type: str, components: List[Dict[str, Any]]):
429
  editor_data["fenestration"] = comp.get("fenestration", "")
430
  editor_data["parent_component"] = comp.get("parent_component", "")
431
  editor_data["shading_coefficient"] = comp.get("shading_coefficient", 1.0)
 
432
 
433
  st.session_state[f"{comp_type}_editor"] = editor_data
434
  st.session_state[f"{comp_type}_action"] = {"action": "edit", "id": str(uuid.uuid4())}
@@ -493,6 +501,7 @@ def display_roof_skylight_table(comp_type: str, components: List[Dict[str, Any]]
493
  editor_data["fenestration"] = comp.get("fenestration", "")
494
  editor_data["parent_component"] = comp.get("parent_component", "")
495
  editor_data["shading_coefficient"] = comp.get("shading_coefficient", 1.0)
 
496
 
497
  st.session_state[f"{comp_type}_editor"] = editor_data
498
  st.session_state[f"{comp_type}_action"] = {"action": "edit", "id": str(uuid.uuid4())}
 
18
  import uuid
19
  from typing import Dict, List, Any, Optional, Tuple, Union
20
  from app.m_c_data import DEFAULT_WINDOW_PROPERTIES # Import DEFAULT_WINDOW_PROPERTIES
21
+ from app.materials_library import GlazingMaterial # Added import for GlazingMaterial
22
 
23
  # Configure logging
24
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
 
153
  name = st.text_input(
154
  "Name",
155
  value=editor_state.get("name", ""),
 
156
  help="Enter a unique name for this component."
157
  )
158
 
 
347
  component_data["parent_component"] = parent_component
348
  component_data["function_type"] = function_type
349
  component_data["shading_coefficient"] = shading_coefficient
350
+ # Fix: Handle both GlazingMaterial and dictionary for fenestration_data
351
  if fenestration in available_items:
352
  fenestration_data = available_items[fenestration]
353
+ if isinstance(fenestration_data, GlazingMaterial):
354
+ component_data["shgc"] = fenestration_data.shgc
355
+ component_data["u_value"] = fenestration_data.u_value
356
+ component_data["h_o"] = fenestration_data.h_o or DEFAULT_WINDOW_PROPERTIES["h_o"]
357
+ component_data["visible_transmittance"] = fenestration_data.visible_transmittance
358
+ else:
359
+ component_data["shgc"] = fenestration_data.get("shgc", 0.7)
360
+ component_data["u_value"] = fenestration_data.get("u_value", 5.0)
361
+ component_data["h_o"] = fenestration_data.get("h_o", DEFAULT_WINDOW_PROPERTIES["h_o"])
362
+ component_data["visible_transmittance"] = fenestration_data.get("visible_transmittance", 0.7)
363
  else:
364
+ logger.warning(f"Fenestration '{fenestration}' not found for {name}. Using defaults.")
365
  component_data["shgc"] = 0.7
366
  component_data["u_value"] = 5.0
367
  component_data["h_o"] = DEFAULT_WINDOW_PROPERTIES["h_o"]
 
436
  editor_data["fenestration"] = comp.get("fenestration", "")
437
  editor_data["parent_component"] = comp.get("parent_component", "")
438
  editor_data["shading_coefficient"] = comp.get("shading_coefficient", 1.0)
439
+ editor_data["function_type"] = comp.get("function_type", "Fixed")
440
 
441
  st.session_state[f"{comp_type}_editor"] = editor_data
442
  st.session_state[f"{comp_type}_action"] = {"action": "edit", "id": str(uuid.uuid4())}
 
501
  editor_data["fenestration"] = comp.get("fenestration", "")
502
  editor_data["parent_component"] = comp.get("parent_component", "")
503
  editor_data["shading_coefficient"] = comp.get("shading_coefficient", 1.0)
504
+ editor_data["function_type"] = comp.get("function_type", "Fixed")
505
 
506
  st.session_state[f"{comp_type}_editor"] = editor_data
507
  st.session_state[f"{comp_type}_action"] = {"action": "edit", "id": str(uuid.uuid4())}