doladeni odpoledniho dobiti
Some checks failed
CI and deploy / migration-check (push) Failing after 22s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-05-21 16:18:30 +02:00
parent c9149babd3
commit e295e55770
4 changed files with 91 additions and 15 deletions

View File

@@ -265,8 +265,13 @@ begin
v_per_slot_discharge_wh := v_max_discharge_w * v_discharge_eff * 0.25;
v_energy_to_fill := v_soc_max_wh - p_current_soc_wh;
v_exportable := v_soc_max_wh - v_min_soc_wh;
-- Rozpočet masek: buffer neinfluje počet slotů nad skutečný deficit; nad reserve jen deficit.
if p_current_soc_wh >= v_reserve_wh then
-- Rozpočet masek: charge_slot_buffer zvětší Wh cíl (do soc_max) i cap počtu grid slotů.
if v_charge_buf > 0 then
v_grid_target_wh := least(
greatest(v_energy_to_fill, 0) * v_charge_buf,
greatest(v_soc_max_wh - p_current_soc_wh, 0)
);
elsif p_current_soc_wh >= v_reserve_wh then
v_grid_target_wh := greatest(v_energy_to_fill, 0);
else
v_grid_target_wh := least(
@@ -366,14 +371,25 @@ begin
end if;
if v_per_slot_charge_wh > 0 then
v_grid_charge_cap_am := greatest(
1,
least(24, ceil(v_chg_am_wh / v_per_slot_charge_wh)::int)
);
v_grid_charge_cap_pm := greatest(
1,
least(24, ceil(v_chg_pm_wh / v_per_slot_charge_wh)::int)
);
if v_charge_buf > 0 then
v_grid_charge_cap_am := greatest(
1,
least(24, ceil((v_chg_am_wh / v_per_slot_charge_wh) * v_charge_buf)::int)
);
v_grid_charge_cap_pm := greatest(
1,
least(24, ceil((v_chg_pm_wh / v_per_slot_charge_wh) * v_charge_buf)::int)
);
else
v_grid_charge_cap_am := greatest(
1,
least(24, ceil(v_chg_am_wh / v_per_slot_charge_wh)::int)
);
v_grid_charge_cap_pm := greatest(
1,
least(24, ceil(v_chg_pm_wh / v_per_slot_charge_wh)::int)
);
end if;
else
v_grid_charge_cap_am := 6;
v_grid_charge_cap_pm := 6;
@@ -427,6 +443,20 @@ begin
end loop;
v_grid_filled_wh := v_grid_filled_wh + v_cum;
-- PM dostane i nevyčerpaný AM rozpočet (levné NT dopoledne ≠ vyčerpání celého grid_target).
v_chg_pm_wh := greatest(v_chg_pm_wh, v_grid_target_wh - v_grid_filled_wh);
if v_per_slot_charge_wh > 0 and v_charge_buf > 0 then
v_grid_charge_cap_pm := greatest(
v_grid_charge_cap_pm,
least(24, ceil((v_chg_pm_wh / v_per_slot_charge_wh) * v_charge_buf)::int)
);
elsif v_per_slot_charge_wh > 0 then
v_grid_charge_cap_pm := greatest(
v_grid_charge_cap_pm,
least(24, ceil(v_chg_pm_wh / v_per_slot_charge_wh)::int)
);
end if;
-- B) Grid PM
v_cum := 0;
v_grid_slots_pm := 0;