Spaces:
Sleeping
Sleeping
Update app/internal_loads.py
Browse files- app/internal_loads.py +28 -72
app/internal_loads.py
CHANGED
@@ -188,13 +188,6 @@ def display_people_tab():
|
|
188 |
help="Select the occupancy schedule for this group."
|
189 |
)
|
190 |
|
191 |
-
# Zone assignment
|
192 |
-
zone = st.text_input(
|
193 |
-
"Zone",
|
194 |
-
value=editor_state.get("zone", "Whole Building"),
|
195 |
-
help="Zone or area where this people group is located."
|
196 |
-
)
|
197 |
-
|
198 |
# Submit buttons
|
199 |
col1, col2 = st.columns(2)
|
200 |
with col1:
|
@@ -229,9 +222,8 @@ def display_people_tab():
|
|
229 |
"clo_summer": clo_summer,
|
230 |
"clo_winter": clo_winter,
|
231 |
"schedule": schedule,
|
232 |
-
"zone": zone,
|
233 |
"sensible_heat_per_person": (activity_data["sensible_min_w"] + activity_data["sensible_max_w"]) / 2,
|
234 |
-
"latent_heat_per_person": (activity_data["
|
235 |
"total_sensible_heat": num_people * (activity_data["sensible_min_w"] + activity_data["sensible_max_w"]) / 2,
|
236 |
"total_latent_heat": num_people * (activity_data["latent_min_w"] + activity_data["latent_max_w"]) / 2
|
237 |
}
|
@@ -349,13 +341,6 @@ def display_lighting_tab():
|
|
349 |
help="Select the lighting schedule for this system."
|
350 |
)
|
351 |
|
352 |
-
# Zone assignment
|
353 |
-
zone = st.text_input(
|
354 |
-
"Zone",
|
355 |
-
value=editor_state.get("zone", "Whole Building"),
|
356 |
-
help="Zone or area where this lighting system is located."
|
357 |
-
)
|
358 |
-
|
359 |
# Submit buttons
|
360 |
col1, col2 = st.columns(2)
|
361 |
with col1:
|
@@ -389,8 +374,7 @@ def display_lighting_tab():
|
|
389 |
"total_power": area * lpd,
|
390 |
"radiative_fraction": radiative_fraction,
|
391 |
"convective_fraction": convective_fraction,
|
392 |
-
"schedule": schedule
|
393 |
-
"zone": zone
|
394 |
}
|
395 |
|
396 |
# Handle edit mode
|
@@ -520,13 +504,6 @@ def display_equipment_tab():
|
|
520 |
help="Select the equipment schedule."
|
521 |
)
|
522 |
|
523 |
-
# Zone assignment
|
524 |
-
zone = st.text_input(
|
525 |
-
"Zone",
|
526 |
-
value=editor_state.get("zone", "Whole Building"),
|
527 |
-
help="Zone or area where this equipment is located."
|
528 |
-
)
|
529 |
-
|
530 |
# Submit buttons
|
531 |
col1, col2 = st.columns(2)
|
532 |
with col1:
|
@@ -562,8 +539,7 @@ def display_equipment_tab():
|
|
562 |
"total_latent_power": area * latent_gain,
|
563 |
"radiative_fraction": radiative_fraction,
|
564 |
"convective_fraction": convective_fraction,
|
565 |
-
"schedule": schedule
|
566 |
-
"zone": zone
|
567 |
}
|
568 |
|
569 |
# Handle edit mode
|
@@ -676,13 +652,6 @@ def display_ventilation_infiltration_tab():
|
|
676 |
help="Select the operation schedule for this system."
|
677 |
)
|
678 |
|
679 |
-
# Zone assignment
|
680 |
-
zone = st.text_input(
|
681 |
-
"Zone",
|
682 |
-
value=editor_state.get("zone", "Whole Building"),
|
683 |
-
help="Zone or area where this system operates."
|
684 |
-
)
|
685 |
-
|
686 |
# Submit buttons
|
687 |
col1, col2 = st.columns(2)
|
688 |
with col1:
|
@@ -712,8 +681,7 @@ def display_ventilation_infiltration_tab():
|
|
712 |
"area": area,
|
713 |
"ventilation_rate": ventilation_rate,
|
714 |
"air_change_rate": air_change_rate,
|
715 |
-
"schedule": schedule
|
716 |
-
"zone": zone
|
717 |
}
|
718 |
|
719 |
# Handle edit mode
|
@@ -978,27 +946,25 @@ def is_schedule_in_use(schedule_name: str) -> bool:
|
|
978 |
def display_people_table(people_groups: List[Dict[str, Any]]):
|
979 |
"""Display people groups in a table format with edit/delete buttons."""
|
980 |
# Create column headers
|
981 |
-
cols = st.columns([2, 1, 1, 1, 1, 1
|
982 |
cols[0].write("**Name**")
|
983 |
cols[1].write("**Number**")
|
984 |
cols[2].write("**Sensible (W)**")
|
985 |
cols[3].write("**Latent (W)**")
|
986 |
-
cols[4].write("**
|
987 |
-
cols[5].write("**
|
988 |
-
cols[6].write("**Delete**")
|
989 |
|
990 |
# Display each group
|
991 |
for idx, group in enumerate(people_groups):
|
992 |
-
cols = st.columns([2, 1, 1, 1, 1, 1
|
993 |
cols[0].write(group["name"])
|
994 |
cols[1].write(str(group.get("num_people", 0)))
|
995 |
cols[2].write(f"{group.get('total_sensible_heat', 0):.1f}")
|
996 |
cols[3].write(f"{group.get('total_latent_heat', 0):.1f}")
|
997 |
-
cols[4].write(group.get("zone", "Unknown"))
|
998 |
|
999 |
# Edit button
|
1000 |
edit_key = f"edit_people_{group['name']}_{idx}"
|
1001 |
-
with cols[
|
1002 |
if st.button("Edit", key=edit_key):
|
1003 |
st.session_state.people_editor = {
|
1004 |
"index": idx,
|
@@ -1008,7 +974,6 @@ def display_people_table(people_groups: List[Dict[str, Any]]):
|
|
1008 |
"clo_summer": group.get("clo_summer", 0.5),
|
1009 |
"clo_winter": group.get("clo_winter", 1.0),
|
1010 |
"schedule": group.get("schedule", "Continuous"),
|
1011 |
-
"zone": group.get("zone", "Whole Building"),
|
1012 |
"is_edit": True
|
1013 |
}
|
1014 |
st.session_state.people_action = {"action": "edit", "id": str(uuid.uuid4())}
|
@@ -1016,7 +981,7 @@ def display_people_table(people_groups: List[Dict[str, Any]]):
|
|
1016 |
|
1017 |
# Delete button
|
1018 |
delete_key = f"delete_people_{group['name']}_{idx}"
|
1019 |
-
with cols[
|
1020 |
if st.button("Delete", key=delete_key):
|
1021 |
st.session_state.project_data["internal_loads"]["people"].pop(idx)
|
1022 |
st.success(f"People Group '{group['name']}' deleted!")
|
@@ -1026,27 +991,25 @@ def display_people_table(people_groups: List[Dict[str, Any]]):
|
|
1026 |
def display_lighting_table(lighting_systems: List[Dict[str, Any]]):
|
1027 |
"""Display lighting systems in a table format with edit/delete buttons."""
|
1028 |
# Create column headers
|
1029 |
-
cols = st.columns([2, 1, 1, 1, 1, 1
|
1030 |
cols[0].write("**Name**")
|
1031 |
cols[1].write("**Area (m虏)**")
|
1032 |
cols[2].write("**LPD (W/m虏)**")
|
1033 |
cols[3].write("**Total Power (W)**")
|
1034 |
-
cols[4].write("**
|
1035 |
-
cols[5].write("**
|
1036 |
-
cols[6].write("**Delete**")
|
1037 |
|
1038 |
# Display each system
|
1039 |
for idx, system in enumerate(lighting_systems):
|
1040 |
-
cols = st.columns([2, 1, 1, 1, 1, 1
|
1041 |
cols[0].write(system["name"])
|
1042 |
cols[1].write(f"{system.get('area', 0):.1f}")
|
1043 |
cols[2].write(f"{system.get('lpd', 0):.2f}")
|
1044 |
cols[3].write(f"{system.get('total_power', 0):.1f}")
|
1045 |
-
cols[4].write(system.get("zone", "Unknown"))
|
1046 |
|
1047 |
# Edit button
|
1048 |
edit_key = f"edit_lighting_{system['name']}_{idx}"
|
1049 |
-
with cols[
|
1050 |
if st.button("Edit", key=edit_key):
|
1051 |
st.session_state.lighting_editor = {
|
1052 |
"index": idx,
|
@@ -1056,7 +1019,6 @@ def display_lighting_table(lighting_systems: List[Dict[str, Any]]):
|
|
1056 |
"radiative_fraction": system.get("radiative_fraction", 0.4),
|
1057 |
"convective_fraction": system.get("convective_fraction", 0.6),
|
1058 |
"schedule": system.get("schedule", "Continuous"),
|
1059 |
-
"zone": system.get("zone", "Whole Building"),
|
1060 |
"is_edit": True
|
1061 |
}
|
1062 |
st.session_state.lighting_action = {"action": "edit", "id": str(uuid.uuid4())}
|
@@ -1064,7 +1026,7 @@ def display_lighting_table(lighting_systems: List[Dict[str, Any]]):
|
|
1064 |
|
1065 |
# Delete button
|
1066 |
delete_key = f"delete_lighting_{system['name']}_{idx}"
|
1067 |
-
with cols[
|
1068 |
if st.button("Delete", key=delete_key):
|
1069 |
st.session_state.project_data["internal_loads"]["lighting"].pop(idx)
|
1070 |
st.success(f"Lighting System '{system['name']}' deleted!")
|
@@ -1074,27 +1036,25 @@ def display_lighting_table(lighting_systems: List[Dict[str, Any]]):
|
|
1074 |
def display_equipment_table(equipment_systems: List[Dict[str, Any]]):
|
1075 |
"""Display equipment systems in a table format with edit/delete buttons."""
|
1076 |
# Create column headers
|
1077 |
-
cols = st.columns([2, 1, 1, 1, 1, 1
|
1078 |
cols[0].write("**Name**")
|
1079 |
cols[1].write("**Area (m虏)**")
|
1080 |
cols[2].write("**Sensible (W)**")
|
1081 |
cols[3].write("**Latent (W)**")
|
1082 |
-
cols[4].write("**
|
1083 |
-
cols[5].write("**
|
1084 |
-
cols[6].write("**Delete**")
|
1085 |
|
1086 |
# Display each system
|
1087 |
for idx, system in enumerate(equipment_systems):
|
1088 |
-
cols = st.columns([2, 1, 1, 1, 1, 1
|
1089 |
cols[0].write(system["name"])
|
1090 |
cols[1].write(f"{system.get('area', 0):.1f}")
|
1091 |
cols[2].write(f"{system.get('total_sensible_power', 0):.1f}")
|
1092 |
cols[3].write(f"{system.get('total_latent_power', 0):.1f}")
|
1093 |
-
cols[4].write(system.get("zone", "Unknown"))
|
1094 |
|
1095 |
# Edit button
|
1096 |
edit_key = f"edit_equipment_{system['name']}_{idx}"
|
1097 |
-
with cols[
|
1098 |
if st.button("Edit", key=edit_key):
|
1099 |
st.session_state.equipment_editor = {
|
1100 |
"index": idx,
|
@@ -1105,7 +1065,6 @@ def display_equipment_table(equipment_systems: List[Dict[str, Any]]):
|
|
1105 |
"radiative_fraction": system.get("radiative_fraction", 0.5),
|
1106 |
"convective_fraction": system.get("convective_fraction", 0.5),
|
1107 |
"schedule": system.get("schedule", "Continuous"),
|
1108 |
-
"zone": system.get("zone", "Whole Building"),
|
1109 |
"is_edit": True
|
1110 |
}
|
1111 |
st.session_state.equipment_action = {"action": "edit", "id": str(uuid.uuid4())}
|
@@ -1113,7 +1072,7 @@ def display_equipment_table(equipment_systems: List[Dict[str, Any]]):
|
|
1113 |
|
1114 |
# Delete button
|
1115 |
delete_key = f"delete_equipment_{system['name']}_{idx}"
|
1116 |
-
with cols[
|
1117 |
if st.button("Delete", key=delete_key):
|
1118 |
st.session_state.project_data["internal_loads"]["equipment"].pop(idx)
|
1119 |
st.success(f"Equipment '{system['name']}' deleted!")
|
@@ -1123,28 +1082,26 @@ def display_equipment_table(equipment_systems: List[Dict[str, Any]]):
|
|
1123 |
def display_ventilation_infiltration_table(vent_inf_systems: List[Dict[str, Any]]):
|
1124 |
"""Display ventilation/infiltration systems in a table format with edit/delete buttons."""
|
1125 |
# Create column headers
|
1126 |
-
cols = st.columns([2, 1, 1, 1, 1, 1
|
1127 |
cols[0].write("**Name**")
|
1128 |
cols[1].write("**Type**")
|
1129 |
cols[2].write("**Area (m虏)**")
|
1130 |
cols[3].write("**Rate**")
|
1131 |
-
cols[4].write("**
|
1132 |
-
cols[5].write("**
|
1133 |
-
cols[6].write("**Delete**")
|
1134 |
|
1135 |
# Display each system
|
1136 |
for idx, system in enumerate(vent_inf_systems):
|
1137 |
-
cols = st.columns([2, 1, 1, 1, 1, 1
|
1138 |
cols[0].write(system["name"])
|
1139 |
cols[1].write(system.get("system_type", "Unknown"))
|
1140 |
cols[2].write(f"{system.get('area', 0):.1f}")
|
1141 |
rate_info = f"{system.get('ventilation_rate', 0):.2f} L/s路m虏" if system.get("system_type") == "Ventilation" else f"{system.get('air_change_rate', 0):.2f} ACH"
|
1142 |
cols[3].write(rate_info)
|
1143 |
-
cols[4].write(system.get("zone", "Unknown"))
|
1144 |
|
1145 |
# Edit button
|
1146 |
edit_key = f"edit_vent_inf_{system['name']}_{idx}"
|
1147 |
-
with cols[
|
1148 |
if st.button("Edit", key=edit_key):
|
1149 |
st.session_state.vent_inf_editor = {
|
1150 |
"index": idx,
|
@@ -1154,7 +1111,6 @@ def display_ventilation_infiltration_table(vent_inf_systems: List[Dict[str, Any]
|
|
1154 |
"ventilation_rate": system.get("ventilation_rate", 10.0),
|
1155 |
"air_change_rate": system.get("air_change_rate", 1.0),
|
1156 |
"schedule": system.get("schedule", "Continuous"),
|
1157 |
-
"zone": system.get("zone", "Whole Building"),
|
1158 |
"is_edit": True
|
1159 |
}
|
1160 |
st.session_state.vent_inf_action = {"action": "edit", "id": str(uuid.uuid4())}
|
@@ -1162,7 +1118,7 @@ def display_ventilation_infiltration_table(vent_inf_systems: List[Dict[str, Any]
|
|
1162 |
|
1163 |
# Delete button
|
1164 |
delete_key = f"delete_vent_inf_{system['name']}_{idx}"
|
1165 |
-
with cols[
|
1166 |
if st.button("Delete", key=delete_key):
|
1167 |
st.session_state.project_data["internal_loads"]["ventilation_infiltration"].pop(idx)
|
1168 |
st.success(f"{system.get('system_type', 'System')} '{system['name']}' deleted!")
|
|
|
188 |
help="Select the occupancy schedule for this group."
|
189 |
)
|
190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
# Submit buttons
|
192 |
col1, col2 = st.columns(2)
|
193 |
with col1:
|
|
|
222 |
"clo_summer": clo_summer,
|
223 |
"clo_winter": clo_winter,
|
224 |
"schedule": schedule,
|
|
|
225 |
"sensible_heat_per_person": (activity_data["sensible_min_w"] + activity_data["sensible_max_w"]) / 2,
|
226 |
+
"latent_heat_per_person": (activity_data["latent_so_w"] + activity_data["latent_max_w"]) / 2,
|
227 |
"total_sensible_heat": num_people * (activity_data["sensible_min_w"] + activity_data["sensible_max_w"]) / 2,
|
228 |
"total_latent_heat": num_people * (activity_data["latent_min_w"] + activity_data["latent_max_w"]) / 2
|
229 |
}
|
|
|
341 |
help="Select the lighting schedule for this system."
|
342 |
)
|
343 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
# Submit buttons
|
345 |
col1, col2 = st.columns(2)
|
346 |
with col1:
|
|
|
374 |
"total_power": area * lpd,
|
375 |
"radiative_fraction": radiative_fraction,
|
376 |
"convective_fraction": convective_fraction,
|
377 |
+
"schedule": schedule
|
|
|
378 |
}
|
379 |
|
380 |
# Handle edit mode
|
|
|
504 |
help="Select the equipment schedule."
|
505 |
)
|
506 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
507 |
# Submit buttons
|
508 |
col1, col2 = st.columns(2)
|
509 |
with col1:
|
|
|
539 |
"total_latent_power": area * latent_gain,
|
540 |
"radiative_fraction": radiative_fraction,
|
541 |
"convective_fraction": convective_fraction,
|
542 |
+
"schedule": schedule
|
|
|
543 |
}
|
544 |
|
545 |
# Handle edit mode
|
|
|
652 |
help="Select the operation schedule for this system."
|
653 |
)
|
654 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
655 |
# Submit buttons
|
656 |
col1, col2 = st.columns(2)
|
657 |
with col1:
|
|
|
681 |
"area": area,
|
682 |
"ventilation_rate": ventilation_rate,
|
683 |
"air_change_rate": air_change_rate,
|
684 |
+
"schedule": schedule
|
|
|
685 |
}
|
686 |
|
687 |
# Handle edit mode
|
|
|
946 |
def display_people_table(people_groups: List[Dict[str, Any]]):
|
947 |
"""Display people groups in a table format with edit/delete buttons."""
|
948 |
# Create column headers
|
949 |
+
cols = st.columns([2, 1, 1, 1, 1, 1])
|
950 |
cols[0].write("**Name**")
|
951 |
cols[1].write("**Number**")
|
952 |
cols[2].write("**Sensible (W)**")
|
953 |
cols[3].write("**Latent (W)**")
|
954 |
+
cols[4].write("**Edit**")
|
955 |
+
cols[5].write("**Delete**")
|
|
|
956 |
|
957 |
# Display each group
|
958 |
for idx, group in enumerate(people_groups):
|
959 |
+
cols = st.columns([2, 1, 1, 1, 1, 1])
|
960 |
cols[0].write(group["name"])
|
961 |
cols[1].write(str(group.get("num_people", 0)))
|
962 |
cols[2].write(f"{group.get('total_sensible_heat', 0):.1f}")
|
963 |
cols[3].write(f"{group.get('total_latent_heat', 0):.1f}")
|
|
|
964 |
|
965 |
# Edit button
|
966 |
edit_key = f"edit_people_{group['name']}_{idx}"
|
967 |
+
with cols[4].container():
|
968 |
if st.button("Edit", key=edit_key):
|
969 |
st.session_state.people_editor = {
|
970 |
"index": idx,
|
|
|
974 |
"clo_summer": group.get("clo_summer", 0.5),
|
975 |
"clo_winter": group.get("clo_winter", 1.0),
|
976 |
"schedule": group.get("schedule", "Continuous"),
|
|
|
977 |
"is_edit": True
|
978 |
}
|
979 |
st.session_state.people_action = {"action": "edit", "id": str(uuid.uuid4())}
|
|
|
981 |
|
982 |
# Delete button
|
983 |
delete_key = f"delete_people_{group['name']}_{idx}"
|
984 |
+
with cols[5].container():
|
985 |
if st.button("Delete", key=delete_key):
|
986 |
st.session_state.project_data["internal_loads"]["people"].pop(idx)
|
987 |
st.success(f"People Group '{group['name']}' deleted!")
|
|
|
991 |
def display_lighting_table(lighting_systems: List[Dict[str, Any]]):
|
992 |
"""Display lighting systems in a table format with edit/delete buttons."""
|
993 |
# Create column headers
|
994 |
+
cols = st.columns([2, 1, 1, 1, 1, 1])
|
995 |
cols[0].write("**Name**")
|
996 |
cols[1].write("**Area (m虏)**")
|
997 |
cols[2].write("**LPD (W/m虏)**")
|
998 |
cols[3].write("**Total Power (W)**")
|
999 |
+
cols[4].write("**Edit**")
|
1000 |
+
cols[5].write("**Delete**")
|
|
|
1001 |
|
1002 |
# Display each system
|
1003 |
for idx, system in enumerate(lighting_systems):
|
1004 |
+
cols = st.columns([2, 1, 1, 1, 1, 1])
|
1005 |
cols[0].write(system["name"])
|
1006 |
cols[1].write(f"{system.get('area', 0):.1f}")
|
1007 |
cols[2].write(f"{system.get('lpd', 0):.2f}")
|
1008 |
cols[3].write(f"{system.get('total_power', 0):.1f}")
|
|
|
1009 |
|
1010 |
# Edit button
|
1011 |
edit_key = f"edit_lighting_{system['name']}_{idx}"
|
1012 |
+
with cols[4].container():
|
1013 |
if st.button("Edit", key=edit_key):
|
1014 |
st.session_state.lighting_editor = {
|
1015 |
"index": idx,
|
|
|
1019 |
"radiative_fraction": system.get("radiative_fraction", 0.4),
|
1020 |
"convective_fraction": system.get("convective_fraction", 0.6),
|
1021 |
"schedule": system.get("schedule", "Continuous"),
|
|
|
1022 |
"is_edit": True
|
1023 |
}
|
1024 |
st.session_state.lighting_action = {"action": "edit", "id": str(uuid.uuid4())}
|
|
|
1026 |
|
1027 |
# Delete button
|
1028 |
delete_key = f"delete_lighting_{system['name']}_{idx}"
|
1029 |
+
with cols[5].container():
|
1030 |
if st.button("Delete", key=delete_key):
|
1031 |
st.session_state.project_data["internal_loads"]["lighting"].pop(idx)
|
1032 |
st.success(f"Lighting System '{system['name']}' deleted!")
|
|
|
1036 |
def display_equipment_table(equipment_systems: List[Dict[str, Any]]):
|
1037 |
"""Display equipment systems in a table format with edit/delete buttons."""
|
1038 |
# Create column headers
|
1039 |
+
cols = st.columns([2, 1, 1, 1, 1, 1])
|
1040 |
cols[0].write("**Name**")
|
1041 |
cols[1].write("**Area (m虏)**")
|
1042 |
cols[2].write("**Sensible (W)**")
|
1043 |
cols[3].write("**Latent (W)**")
|
1044 |
+
cols[4].write("**Edit**")
|
1045 |
+
cols[5].write("**Delete**")
|
|
|
1046 |
|
1047 |
# Display each system
|
1048 |
for idx, system in enumerate(equipment_systems):
|
1049 |
+
cols = st.columns([2, 1, 1, 1, 1, 1])
|
1050 |
cols[0].write(system["name"])
|
1051 |
cols[1].write(f"{system.get('area', 0):.1f}")
|
1052 |
cols[2].write(f"{system.get('total_sensible_power', 0):.1f}")
|
1053 |
cols[3].write(f"{system.get('total_latent_power', 0):.1f}")
|
|
|
1054 |
|
1055 |
# Edit button
|
1056 |
edit_key = f"edit_equipment_{system['name']}_{idx}"
|
1057 |
+
with cols[4].container():
|
1058 |
if st.button("Edit", key=edit_key):
|
1059 |
st.session_state.equipment_editor = {
|
1060 |
"index": idx,
|
|
|
1065 |
"radiative_fraction": system.get("radiative_fraction", 0.5),
|
1066 |
"convective_fraction": system.get("convective_fraction", 0.5),
|
1067 |
"schedule": system.get("schedule", "Continuous"),
|
|
|
1068 |
"is_edit": True
|
1069 |
}
|
1070 |
st.session_state.equipment_action = {"action": "edit", "id": str(uuid.uuid4())}
|
|
|
1072 |
|
1073 |
# Delete button
|
1074 |
delete_key = f"delete_equipment_{system['name']}_{idx}"
|
1075 |
+
with cols[5].container():
|
1076 |
if st.button("Delete", key=delete_key):
|
1077 |
st.session_state.project_data["internal_loads"]["equipment"].pop(idx)
|
1078 |
st.success(f"Equipment '{system['name']}' deleted!")
|
|
|
1082 |
def display_ventilation_infiltration_table(vent_inf_systems: List[Dict[str, Any]]):
|
1083 |
"""Display ventilation/infiltration systems in a table format with edit/delete buttons."""
|
1084 |
# Create column headers
|
1085 |
+
cols = st.columns([2, 1, 1, 1, 1, 1])
|
1086 |
cols[0].write("**Name**")
|
1087 |
cols[1].write("**Type**")
|
1088 |
cols[2].write("**Area (m虏)**")
|
1089 |
cols[3].write("**Rate**")
|
1090 |
+
cols[4].write("**Edit**")
|
1091 |
+
cols[5].write("**Delete**")
|
|
|
1092 |
|
1093 |
# Display each system
|
1094 |
for idx, system in enumerate(vent_inf_systems):
|
1095 |
+
cols = st.columns([2, 1, 1, 1, 1, 1])
|
1096 |
cols[0].write(system["name"])
|
1097 |
cols[1].write(system.get("system_type", "Unknown"))
|
1098 |
cols[2].write(f"{system.get('area', 0):.1f}")
|
1099 |
rate_info = f"{system.get('ventilation_rate', 0):.2f} L/s路m虏" if system.get("system_type") == "Ventilation" else f"{system.get('air_change_rate', 0):.2f} ACH"
|
1100 |
cols[3].write(rate_info)
|
|
|
1101 |
|
1102 |
# Edit button
|
1103 |
edit_key = f"edit_vent_inf_{system['name']}_{idx}"
|
1104 |
+
with cols[4].container():
|
1105 |
if st.button("Edit", key=edit_key):
|
1106 |
st.session_state.vent_inf_editor = {
|
1107 |
"index": idx,
|
|
|
1111 |
"ventilation_rate": system.get("ventilation_rate", 10.0),
|
1112 |
"air_change_rate": system.get("air_change_rate", 1.0),
|
1113 |
"schedule": system.get("schedule", "Continuous"),
|
|
|
1114 |
"is_edit": True
|
1115 |
}
|
1116 |
st.session_state.vent_inf_action = {"action": "edit", "id": str(uuid.uuid4())}
|
|
|
1118 |
|
1119 |
# Delete button
|
1120 |
delete_key = f"delete_vent_inf_{system['name']}_{idx}"
|
1121 |
+
with cols[5].container():
|
1122 |
if st.button("Delete", key=delete_key):
|
1123 |
st.session_state.project_data["internal_loads"]["ventilation_infiltration"].pop(idx)
|
1124 |
st.success(f"{system.get('system_type', 'System')} '{system['name']}' deleted!")
|