refix planneru
This commit is contained in:
@@ -221,43 +221,43 @@ begin
|
|||||||
v_grid_target_wh := v_energy_to_fill * v_charge_buf;
|
v_grid_target_wh := v_energy_to_fill * v_charge_buf;
|
||||||
v_discharge_target_wh := v_exportable * v_discharge_buf;
|
v_discharge_target_wh := v_exportable * v_discharge_buf;
|
||||||
|
|
||||||
-- charge mask
|
-- charge mask (sloupce temp tabulky kvalifikujeme: RETURNS TABLE dělá PL proměnné stejných jmen)
|
||||||
if v_charge_buf <= 0 then
|
if v_charge_buf <= 0 then
|
||||||
update _ems_plan_slot_wk set allow_charge = true;
|
update _ems_plan_slot_wk wk set allow_charge = true;
|
||||||
elsif v_energy_to_fill <= 0 then
|
elsif v_energy_to_fill <= 0 then
|
||||||
update _ems_plan_slot_wk set allow_charge = false;
|
update _ems_plan_slot_wk wk set allow_charge = false;
|
||||||
else
|
else
|
||||||
update _ems_plan_slot_wk set allow_charge = (pv_surplus_w > 0);
|
update _ems_plan_slot_wk wk set allow_charge = (wk.pv_surplus_w > 0);
|
||||||
v_cum := 0;
|
v_cum := 0;
|
||||||
for r_slot in
|
for r_slot in
|
||||||
select slot_ord
|
select wk.slot_ord
|
||||||
from _ems_plan_slot_wk
|
from _ems_plan_slot_wk wk
|
||||||
where pv_surplus_w <= 0
|
where wk.pv_surplus_w <= 0
|
||||||
order by buy_price, slot_ord
|
order by wk.buy_price, wk.slot_ord
|
||||||
loop
|
loop
|
||||||
exit when v_cum >= v_grid_target_wh;
|
exit when v_cum >= v_grid_target_wh;
|
||||||
exit when v_per_slot_charge_wh <= 0;
|
exit when v_per_slot_charge_wh <= 0;
|
||||||
update _ems_plan_slot_wk set allow_charge = true where slot_ord = r_slot.slot_ord;
|
update _ems_plan_slot_wk wk set allow_charge = true where wk.slot_ord = r_slot.slot_ord;
|
||||||
v_cum := v_cum + v_per_slot_charge_wh;
|
v_cum := v_cum + v_per_slot_charge_wh;
|
||||||
end loop;
|
end loop;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
-- discharge-export mask
|
-- discharge-export mask
|
||||||
if v_discharge_buf <= 0 then
|
if v_discharge_buf <= 0 then
|
||||||
update _ems_plan_slot_wk set allow_discharge_export = true;
|
update _ems_plan_slot_wk wk set allow_discharge_export = true;
|
||||||
elsif v_exportable <= 0 then
|
elsif v_exportable <= 0 then
|
||||||
update _ems_plan_slot_wk set allow_discharge_export = false;
|
update _ems_plan_slot_wk wk set allow_discharge_export = false;
|
||||||
else
|
else
|
||||||
update _ems_plan_slot_wk set allow_discharge_export = false;
|
update _ems_plan_slot_wk wk set allow_discharge_export = false;
|
||||||
v_cum := 0;
|
v_cum := 0;
|
||||||
for r_slot in
|
for r_slot in
|
||||||
select slot_ord
|
select wk.slot_ord
|
||||||
from _ems_plan_slot_wk
|
from _ems_plan_slot_wk wk
|
||||||
order by sell_price desc, slot_ord desc
|
order by wk.sell_price desc, wk.slot_ord desc
|
||||||
loop
|
loop
|
||||||
exit when v_cum >= v_discharge_target_wh;
|
exit when v_cum >= v_discharge_target_wh;
|
||||||
exit when v_per_slot_discharge_wh <= 0;
|
exit when v_per_slot_discharge_wh <= 0;
|
||||||
update _ems_plan_slot_wk set allow_discharge_export = true where slot_ord = r_slot.slot_ord;
|
update _ems_plan_slot_wk wk set allow_discharge_export = true where wk.slot_ord = r_slot.slot_ord;
|
||||||
v_cum := v_cum + v_per_slot_discharge_wh;
|
v_cum := v_cum + v_per_slot_discharge_wh;
|
||||||
end loop;
|
end loop;
|
||||||
end if;
|
end if;
|
||||||
|
|||||||
Reference in New Issue
Block a user