Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 43 additions & 31 deletions data/config/mosquitto/public/default-dynamic-security.json
Original file line number Diff line number Diff line change
Expand Up @@ -1045,49 +1045,55 @@
"acls": [
{
"acltype": "publishClientSend",
"topic": "openWB/set/general/chargemode_config/pv_charging/control_range",
"topic": "openWB/set/general/chargemode_config/surplus/control_range",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/general/chargemode_config/pv_charging/feed_in_yield",
"topic": "openWB/set/general/chargemode_config/surplus/feed_in_limit",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/general/chargemode_config/pv_charging/phase_switch_delay",
"topic": "openWB/set/general/chargemode_config/surplus/feed_in_yield",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/general/chargemode_config/pv_charging/switch_on_threshold",
"topic": "openWB/set/general/chargemode_config/surplus/vehicle/phase_switch_delay",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/general/chargemode_config/pv_charging/retry_failed_phase_switches",
"topic": "openWB/set/general/chargemode_config/surplus/vehicle/switch_on_threshold",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/general/chargemode_config/pv_charging/switch_on_delay",
"topic": "openWB/set/general/chargemode_config/surplus/vehicle/retry_failed_phase_switches",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/general/chargemode_config/pv_charging/switch_off_threshold",
"topic": "openWB/set/general/chargemode_config/surplus/vehicle/switch_on_delay",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/general/chargemode_config/pv_charging/switch_off_delay",
"topic": "openWB/set/general/chargemode_config/surplus/vehicle/switch_off_threshold",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/general/chargemode_config/surplus/vehicle/switch_off_delay",
"priority": 0,
"allow": true
},
Expand All @@ -1099,49 +1105,55 @@
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/pv_charging/control_range",
"topic": "openWB/general/chargemode_config/surplus/control_range",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/surplus/feed_in_limit",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/pv_charging/feed_in_yield",
"topic": "openWB/general/chargemode_config/surplus/feed_in_yield",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/pv_charging/phase_switch_delay",
"topic": "openWB/general/chargemode_config/surplus/vehicle/phase_switch_delay",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/pv_charging/switch_on_threshold",
"topic": "openWB/general/chargemode_config/surplus/vehicle/switch_on_threshold",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/pv_charging/retry_failed_phase_switches",
"topic": "openWB/general/chargemode_config/surplus/vehicle/retry_failed_phase_switches",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/pv_charging/switch_on_delay",
"topic": "openWB/general/chargemode_config/surplus/vehicle/switch_on_delay",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/pv_charging/switch_off_threshold",
"topic": "openWB/general/chargemode_config/surplus/vehicle/switch_off_threshold",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/pv_charging/switch_off_delay",
"topic": "openWB/general/chargemode_config/surplus/vehicle/switch_off_delay",
"priority": 0,
"allow": true
}
Expand Down Expand Up @@ -1226,43 +1238,43 @@
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/general/chargemode_config/pv_charging/bat_mode",
"topic": "openWB/set/general/chargemode_config/bat/mode",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/general/chargemode_config/pv_charging/bat_power_discharge",
"topic": "openWB/set/general/chargemode_config/bat/power_discharge",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/general/chargemode_config/pv_charging/bat_power_discharge_active",
"topic": "openWB/set/general/chargemode_config/bat/power_discharge_active",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/general/chargemode_config/pv_charging/bat_power_reserve",
"topic": "openWB/set/general/chargemode_config/bat/power_reserve",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/general/chargemode_config/pv_charging/bat_power_reserve_active",
"topic": "openWB/set/general/chargemode_config/bat/power_reserve_active",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/general/chargemode_config/pv_charging/max_bat_soc",
"topic": "openWB/set/general/chargemode_config/bat/max_soc",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/general/chargemode_config/pv_charging/min_bat_soc",
"topic": "openWB/set/general/chargemode_config/bat/min_soc",
"priority": 0,
"allow": true
},
Expand Down Expand Up @@ -1358,43 +1370,43 @@
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/pv_charging/bat_mode",
"topic": "openWB/general/chargemode_config/bat/mode",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/pv_charging/bat_power_discharge",
"topic": "openWB/general/chargemode_config/bat/power_discharge",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/pv_charging/bat_power_discharge_active",
"topic": "openWB/general/chargemode_config/bat/power_discharge_active",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/pv_charging/bat_power_reserve",
"topic": "openWB/general/chargemode_config/bat/power_reserve",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/pv_charging/bat_power_reserve_active",
"topic": "openWB/general/chargemode_config/bat/power_reserve_active",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/pv_charging/max_bat_soc",
"topic": "openWB/general/chargemode_config/bat/max_soc",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/pv_charging/min_bat_soc",
"topic": "openWB/general/chargemode_config/bat/min_soc",
"priority": 0,
"allow": true
},
Expand Down Expand Up @@ -2794,7 +2806,7 @@
},
{
"acltype": "publishClientReceive",
"topic": "openWB/general/chargemode_config/pv_charging/bat_mode",
"topic": "openWB/general/chargemode_config/bat/mode",
"priority": 0,
"allow": true
}
Expand Down
1 change: 0 additions & 1 deletion packages/control/algorithm/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def _check_auto_phase_switch_delay(self) -> None:
# wurden, wieder zurückgegeben.
log.debug(f"Ladepunkt {cp.num}: Prüfen, ob Phasenumschaltung durchgeführt werden soll.")
phases, current, message = charging_ev.auto_phase_switch(
cp.data.set.charge_template,
cp.data.control_parameter,
cp.num,
cp.data.get.evse_current,
Expand Down
2 changes: 1 addition & 1 deletion packages/control/algorithm/integration_test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def data_() -> None:
data.data.counter_all_data.data.get.hierarchy = NESTED_HIERARCHY
data.data.counter_all_data.data.config.consider_less_charging = True
data.data.io_actions = IoActions()
data.data.general_data.data.chargemode_config.pv_charging.retry_failed_phase_switches = True
data.data.general_data.data.chargemode_config.surplus.vehicle.retry_failed_phase_switches = True


@dataclass
Expand Down
25 changes: 5 additions & 20 deletions packages/control/algorithm/surplus_controlled.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ def set_surplus_current(self) -> None:
for mode_tuple, counter in common.mode_and_counter_generator(CONSIDERED_CHARGE_MODES_SURPLUS):
preferenced_chargepoints, preferenced_cps_without_set_current = get_preferenced_chargepoint_charging(
get_chargepoints_by_mode_and_counter(mode_tuple, f"counter{counter.num}"))
cp_with_feed_in, cp_without_feed_in = self.filter_by_feed_in_limit(preferenced_chargepoints)
if cp_without_feed_in:
self._set(cp_without_feed_in, 0, mode_tuple, counter)
feed_in_yield = data.data.general_data.data.chargemode_config.pv_charging.feed_in_yield
if cp_with_feed_in:
self._set(cp_with_feed_in, feed_in_yield, mode_tuple, counter)
self._set(preferenced_chargepoints, mode_tuple, counter)
Comment on lines 33 to +36
if preferenced_cps_without_set_current:
for cp in preferenced_cps_without_set_current:
cp.data.set.current = cp.data.set.target_current
Expand All @@ -48,7 +43,6 @@ def set_surplus_current(self) -> None:

def _set(self,
chargepoints: List[Chargepoint],
feed_in_yield: Optional[int],
mode_tuple: Tuple[Optional[str], str, bool],
counter: Counter) -> None:
log.info(f"Mode-Tuple {mode_tuple[0]} - {mode_tuple[1]} - {mode_tuple[2]}, Zähler {counter.num}")
Expand All @@ -60,20 +54,19 @@ def _set(self,
missing_currents,
voltages_mean(cp.data.get.voltages),
counter,
cp,
feed_in=feed_in_yield
cp
)
# im PV-Laden wird der Strom immer durch die Leistung begrenzt
if limit.limiting_value is not None and limit.limiting_value != LimitingValue.POWER:
cp.data.control_parameter.limit = limit
available_for_cp = common.available_current_for_cp(cp, counts, available_currents, missing_currents)
if counter.get_control_range_state(feed_in_yield) == ControlRangeState.MIDDLE:
pv_charging = data.data.general_data.data.chargemode_config.pv_charging
if counter.get_control_range_state() == ControlRangeState.MIDDLE:
surplus = data.data.general_data.data.chargemode_config.surplus
dif_to_old_current = available_for_cp + cp.data.set.target_current - cp.data.set.current_prev
# Wenn die Differenz zwischen altem und neuem Soll-Strom größer als der Regelbereich ist, trotzdem
# nachregeln, auch wenn der Regelbereich eingehalten wird. Sonst würde zB nicht berücksichtigt werden,
# wenn noch ein Fahrzeug dazu kommt.
if ((pv_charging.control_range[1] - pv_charging.control_range[0]) /
if ((surplus.control_range[1] - surplus.control_range[0]) /
(sum(counter.data.get.voltages) / len(counter.data.get.voltages)) < abs(dif_to_old_current)):
current = available_for_cp
else:
Expand Down Expand Up @@ -105,14 +98,6 @@ def _set_loadmangement_message(self,
chargepoint.set_state_and_log(f"Es kann nicht mit der vorgegebenen Stromstärke geladen werden"
f"{limit.message}")

# tested
def filter_by_feed_in_limit(self, chargepoints: List[Chargepoint]) -> Tuple[List[Chargepoint], List[Chargepoint]]:
cp_with_feed_in = list(filter(lambda cp: cp.data.set.charge_template.data.chargemode.
pv_charging.feed_in_limit is True, chargepoints))
cp_without_feed_in = list(filter(lambda cp: cp.data.set.charge_template.data.chargemode.
pv_charging.feed_in_limit is False, chargepoints))
return cp_with_feed_in, cp_without_feed_in

def _fix_deviating_evse_current(self, chargepoint: Chargepoint) -> float:
"""Wenn Autos nicht die volle Ladeleistung nutzen, wird unnötig eingespeist. Dann kann um den noch nicht
genutzten Soll-Strom hochgeregelt werden. Wenn Fahrzeuge entgegen der Norm mehr Ladeleistung beziehen, als
Expand Down
42 changes: 14 additions & 28 deletions packages/control/algorithm/surplus_controlled_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
from control.ev.ev import Ev


@pytest.fixture(autouse=True)
def init_data_store():
data.data_init(Mock())


@pytest.fixture(autouse=True)
def mock_cp1() -> Chargepoint:
return Chargepoint(1, None)
Expand All @@ -30,29 +35,6 @@ def mock_cp3() -> Chargepoint:
return Chargepoint(3, None)


@pytest.mark.parametrize("feed_in_limit_1, feed_in_limit_2, feed_in_limit_3, expected_sorted",
[pytest.param(True, True, True, ([mock_cp1, mock_cp2, mock_cp3], [])),
pytest.param(True, False, True, ([mock_cp1, mock_cp3], [mock_cp2])),
pytest.param(False, False, False, ([], [mock_cp1, mock_cp2, mock_cp3]))])
def test_filter_by_feed_in_limit(feed_in_limit_1: bool,
feed_in_limit_2: bool,
feed_in_limit_3: bool,
expected_sorted: int):
# setup
def setup_cp(cp: Chargepoint, feed_in_limit: bool) -> Chargepoint:
cp.data = ChargepointData()
cp.data.set.charge_template.data.chargemode.pv_charging.feed_in_limit = feed_in_limit
return cp

cp1 = setup_cp(mock_cp1, feed_in_limit_1)
cp2 = setup_cp(mock_cp2, feed_in_limit_2)
cp3 = setup_cp(mock_cp3, feed_in_limit_3)
# execution
cp_with_feed_in, cp_without_feed_in = SurplusControlled().filter_by_feed_in_limit([cp1, cp2, cp3])
# evaluation
assert (cp_with_feed_in, cp_without_feed_in) == expected_sorted


@pytest.mark.parametrize("new_current, expected_current",
[
pytest.param(7, 10),
Expand Down Expand Up @@ -134,24 +116,28 @@ def test_add_unused_evse_current(evse_current: float,


@pytest.mark.parametrize(
"submode_1, submode_2, expected_chargepoints",
"submode_1, submode_2, expected_cp_keys",
[
pytest.param(Chargemode.PV_CHARGING, Chargemode.PV_CHARGING, [mock_cp1, mock_cp2]),
pytest.param(Chargemode.INSTANT_CHARGING, Chargemode.PV_CHARGING, [mock_cp2]),
pytest.param(Chargemode.PV_CHARGING, Chargemode.PV_CHARGING, ["cp1", "cp2"]),
pytest.param(Chargemode.INSTANT_CHARGING, Chargemode.PV_CHARGING, ["cp2"]),
pytest.param(Chargemode.INSTANT_CHARGING, Chargemode.INSTANT_CHARGING, []),
])
def test_get_chargepoints_submode_pv_charging(submode_1: Chargemode,
submode_2: Chargemode,
expected_chargepoints: List[Chargepoint]):
expected_cp_keys: List[str],
mock_cp1: Chargepoint,
mock_cp2: Chargepoint):
# setup
def setup_cp(cp: Chargepoint, submode: str) -> Chargepoint:
cp.data = ChargepointData()
cp.data.set.charging_ev_data = Ev(0)
cp.data.control_parameter.chargemode = Chargemode.PV_CHARGING
cp.data.control_parameter.submode = submode
cp.data.control_parameter.required_current = 6
return cp
data.Data.cp_data = {"cp1": setup_cp(mock_cp1, submode_1),
data.data.cp_data = {"cp1": setup_cp(mock_cp1, submode_1),
"cp2": setup_cp(mock_cp2, submode_2)}
expected_chargepoints = [data.data.cp_data[key] for key in expected_cp_keys]

# evaluation
chargepoints = get_chargepoints_with_required_current_by_chargemode(CONSIDERED_CHARGE_MODES_PV_ONLY)
Expand Down
Loading