Skip to content

Commit 5a850f5

Browse files
Move power distributing request to the separate module
Signed-off-by: ela-kotulska-frequenz <[email protected]>
1 parent 4900b81 commit 5a850f5

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

src/frequenz/sdk/actor/power_distributing/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
PowerDistributingActor and send requests for charging or discharging power.
1111
"""
1212

13-
from .power_distributing import PowerDistributingActor, Request, Result
13+
from .power_distributing import PowerDistributingActor, Result
14+
from .request import Request
1415

1516
__all__ = ["PowerDistributingActor", "Request", "Result"]

src/frequenz/sdk/actor/power_distributing/power_distributing.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
InverterData,
4545
)
4646
from ...power import DistributionAlgorithm, InvBatPair
47+
from .request import Request
4748

4849
_logger = logging.getLogger(__name__)
4950

@@ -139,25 +140,6 @@ def is_broken(self, component_id: int) -> bool:
139140
return False
140141

141142

142-
@dataclass
143-
class Request:
144-
"""Request from the user."""
145-
146-
# How much power to set
147-
power: int
148-
# In which batteries the power should be set
149-
batteries: Set[int]
150-
# Timeout for the server to respond on the request.
151-
request_timeout_sec: float = 5.0
152-
# If True and requested power value is out of bound, then
153-
# PowerDistributor will decrease the power to match the bounds and
154-
# distribute only decreased power.
155-
# If False and the requested power is out of bound, then
156-
# PowerDistributor will not process this request and send result with status
157-
# Result.Status.OUT_OF_BOUND.
158-
adjust_power: bool = True
159-
160-
161143
@dataclass
162144
class Result:
163145
"""Result on distribution request."""
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# License: MIT
2+
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
3+
"""Definition of the user request."""
4+
5+
from dataclasses import dataclass
6+
from typing import Set
7+
8+
9+
@dataclass
10+
class Request:
11+
"""Request from the user."""
12+
13+
# How much power to set
14+
power: int
15+
# In which batteries the power should be set
16+
batteries: Set[int]
17+
# Timeout for the server to respond on the requests.
18+
request_timeout_sec: float = 5.0
19+
# If True and requested power value is above upper bound, then the power will be
20+
# decreased to match the bounds. Only the decreased power will be set.
21+
# If False and the requested power is above upper bound, then request won't
22+
# be processed. result.OutOfBound message will be send back to the user.
23+
adjust_power: bool = True

0 commit comments

Comments
 (0)