Skip to content

Commit 0e19bf4

Browse files
authored
Modularize status tracking for pools of components in the power distributing actor (#779)
The new design works as follows: - reusable `ComponentPoolStatusTracker` that takes individual `ComponentStatus` and generates `ComponentPoolStatus` objects. - the individual `ComponentStatus` need to be generated by code specific to the component category, because status is calculated differently for different component categories. This code specific for a component category has to be a class that implements the abstract `ComponentStatusTracker` class. - The `ComponentPoolStatusTracker` accepts implementations of `ComponentStatusTracker`, like the `BatteryStatusTracker` (which looks at the status of corresponding inverters also), and but is otherwise generic. This PR takes us part of the way towards getting the PowerDistributingActor easily usable for other component types. It also simplifies some implementations and replaces the use of `MergeNamed` with `Merge` from the channels repo.
2 parents ad298cd + 00c48d9 commit 0e19bf4

File tree

14 files changed

+576
-484
lines changed

14 files changed

+576
-484
lines changed

benchmarks/power_distribution/power_distributor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from frequenz.sdk import microgrid
1717
from frequenz.sdk.actor import ResamplerConfig
1818
from frequenz.sdk.actor.power_distributing import (
19-
BatteryStatus,
19+
ComponentPoolStatus,
2020
Error,
2121
OutOfBounds,
2222
PartialFailure,
@@ -112,7 +112,7 @@ async def run_test( # pylint: disable=too-many-locals
112112
start = timeit.default_timer()
113113

114114
power_request_channel = Broadcast[Request]("power-request")
115-
battery_status_channel = Broadcast[BatteryStatus]("battery-status")
115+
battery_status_channel = Broadcast[ComponentPoolStatus]("battery-status")
116116
power_result_channel = Broadcast[Result]("power-result")
117117
async with PowerDistributingActor(
118118
requests_receiver=power_request_channel.new_receiver(),

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

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

13-
from ._battery_pool_status import BatteryStatus
13+
from ._component_status import ComponentPoolStatus
1414
from .power_distributing import PowerDistributingActor
1515
from .request import Request
1616
from .result import Error, OutOfBounds, PartialFailure, Result, Success
@@ -23,5 +23,5 @@
2323
"Success",
2424
"OutOfBounds",
2525
"PartialFailure",
26-
"BatteryStatus",
26+
"ComponentPoolStatus",
2727
]

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

Lines changed: 0 additions & 214 deletions
This file was deleted.

0 commit comments

Comments
 (0)