Skip to content
Merged
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
5 changes: 3 additions & 2 deletions packages/control/algorithm/surplus_controlled.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ def _set_loadmangement_message(self,
limit: LoadmanagementLimit,
load: Load) -> None:
# Strom muss an diesem Zähler geändert werden
if (current != load.data.set.current and
if ((load.data.set.current is None or round(current, 2) != round(load.data.set.current, 2)) and
# Strom erreicht nicht die vorgegebene Stromstärke
current != max(load.data.control_parameter.required_currents) and
round(current, 2) != round(max(load.data.control_parameter.required_currents), 2) and
limit.message is not None and
# im PV-Laden wird der Strom immer durch die Leistung begrenzt
limit.limiting_value != LimitingValue.POWER):
load.set_state_and_log(f"Es kann nicht mit der vorgegebenen Stromstärke geladen werden"
Expand Down
37 changes: 37 additions & 0 deletions packages/control/algorithm/surplus_controlled_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from control.chargepoint.control_parameter import ControlParameter
from control.counter_all.counter_all import CounterAll
from control.ev.ev import Ev
from control.consumer.consumer import Consumer
from control.limiting_value import LimitingValue, LoadmanagementLimit


@pytest.fixture(autouse=True)
Expand Down Expand Up @@ -42,6 +44,41 @@ def mock_data() -> None:
data.data.counter_all_data = CounterAll()


@pytest.mark.parametrize(
"current, set_current, required_current, limit, expected_message",
[
pytest.param(13.04, 6, 13.043478260869565,
LoadmanagementLimit(None, None), None, id="reported-consumer-rounding"),
pytest.param(12, 6, 13.04, LoadmanagementLimit(None, None), None,
id="no-limit-reason"),
pytest.param(13.04, 6, 13.043478260869565,
LoadmanagementLimit(" current limit", LimitingValue.CURRENT), None,
id="rounded-required-current"),
pytest.param(13.04, 13.043478260869565, 16,
LoadmanagementLimit(" current limit", LimitingValue.CURRENT), None,
id="rounded-unchanged-current"),
pytest.param(12, 6, 13.04,
LoadmanagementLimit(" power limit", LimitingValue.POWER), None,
id="normal-pv-power-limit"),
pytest.param(12, 6, 13.04,
LoadmanagementLimit(" current limit", LimitingValue.CURRENT),
"Es kann nicht mit der vorgegebenen Stromstärke geladen werden current limit",
id="actual-current-limit"),
pytest.param(12, None, 13.04,
LoadmanagementLimit(" current limit", LimitingValue.CURRENT),
"Es kann nicht mit der vorgegebenen Stromstärke geladen werden current limit",
id="no-previous-set-current"),
])
def test_set_loadmanagement_message(current, set_current, required_current, limit, expected_message):
consumer = Consumer(27)
consumer.data.set.current = set_current
consumer.data.control_parameter.required_currents = [required_current, 0, 0]

SurplusControlled()._set_loadmangement_message(current, limit, consumer)

assert consumer.data.get.state_str == expected_message


@pytest.mark.parametrize("new_current, expected_current",
[
pytest.param(7, 10),
Expand Down
Loading