largely working dashboard

This commit is contained in:
Lucas Tan 2025-07-20 17:05:13 +01:00
parent 6d1199e37a
commit d3dbd9c9f3
4 changed files with 20 additions and 4 deletions

View File

@ -31,7 +31,7 @@ def discharge_bess(bess, site_name, dt, discharge_power):
continue
if unit["site"] == site_name:
new_soc = unit["SoC"] - (dt * discharge_energy) / unit["capacity_kWh"]
new_soc = unit["SoC"] - discharge_energy / unit["capacity_kWh"]
new_soc = 0 if new_soc < 0 else new_soc
else:
continue

View File

@ -26,6 +26,11 @@ def format_dataframe(
current_load = bess_data["units"][index]["current_load_kW"]
unit_name = bess_data["units"][index]["name"]
predicted_swap_time = swap_time.get(unit_name, "N/A")
# convert predicted_swap_time to a readable format
if isinstance(predicted_swap_time, float):
predicted_swap_time = pd.to_datetime(
predicted_swap_time, unit="s"
).strftime("%Y-%m-%d %H:%M:%S")
status_df = pd.concat(
[

View File

@ -63,7 +63,7 @@ def show_table():
"SoC (%)": st.column_config.ProgressColumn(
"State of Charge",
help="State of Charge of the BESS unit",
format="%d%%",
format="%.1f%%",
min_value=0,
max_value=100,
),
@ -84,9 +84,20 @@ def show_table():
if st.session_state.running:
# display simulation start time
st.metric(
"Simulation Start Time",
value=pd.to_datetime(main.c["sim_start_time"], unit="s").strftime(
"%Y-%m-%d %H:%M:%S"
),
)
st.metric(
"Time Elapsed in DD:HH:MM:SS",
value=str(pd.to_timedelta(main.sim_i * main.dt, unit="s")),
)
# display BESS data, SoC, Load Consumption
show_table()
time.sleep(1)
time.sleep(3)
st.rerun()
else:
show_table()

View File

@ -126,7 +126,7 @@ def simulation_loop():
)
# small sleep to allow dashboard to refresh / release GIL
time.sleep(1)
time.sleep(0.1)
### <<< CONTROL ADDED >>> Control functions