Skip to content

Commit 8203984

Browse files
committed
Update data pipeline to work with new PowerDistributingActor interface
This commit also removes the `power_distributing_handle` method. This will be replaced by methods in the battery_pool that will be added in a subsequent commit. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 0cd8d9a commit 8203984

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

src/frequenz/sdk/microgrid/_data_pipeline.py

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from collections import abc
1616
from dataclasses import dataclass
1717

18-
from frequenz.channels import Bidirectional, Broadcast, Sender
18+
from frequenz.channels import Broadcast, Sender
1919

2020
from . import connection_manager
2121
from .component import ComponentCategory
@@ -37,7 +37,6 @@
3737
BatteryStatus,
3838
PowerDistributingActor,
3939
Request,
40-
Result,
4140
)
4241
from ..timeseries.battery_pool import BatteryPool
4342
from ..timeseries.ev_charger_pool import EVChargerPool
@@ -89,8 +88,8 @@ def __init__(
8988
self._battery_status_channel = Broadcast["BatteryStatus"](
9089
"battery-status", resend_latest=True
9190
)
92-
self._power_distribution_channel = Bidirectional["Request", "Result"](
93-
"Default", "Power Distributing Actor"
91+
self._power_distribution_channel = Broadcast["Request"](
92+
"Power Distributing Actor, Broadcast Channel"
9493
)
9594

9695
self._power_distributing_actor: "PowerDistributingActor" | None = None
@@ -180,23 +179,13 @@ def battery_pool(
180179
batteries_status_receiver=self._battery_status_channel.new_receiver(
181180
maxsize=1
182181
),
182+
power_distributing_sender=self._power_distribution_channel.new_sender(),
183183
min_update_interval=self._resampler_config.resampling_period,
184184
batteries_id=battery_ids,
185185
)
186186

187187
return self._battery_pools[key]
188188

189-
def power_distributing_handle(self) -> Bidirectional.Handle[Request, Result]:
190-
"""Return the handle to the power distributing actor.
191-
192-
Returns:
193-
A Bidirectional handle to communicate with the power distributing actor.
194-
"""
195-
if not self._power_distributing_actor:
196-
self._start_power_distributing_actor()
197-
198-
return self._power_distribution_channel.client_handle
199-
200189
def _start_power_distributing_actor(self) -> None:
201190
"""Start the power distributing actor if it is not already running."""
202191
if self._power_distributing_actor:
@@ -218,7 +207,8 @@ def _start_power_distributing_actor(self) -> None:
218207
# Until the PowerManager is implemented, support for multiple use-case actors
219208
# will not be available in the high level interface.
220209
self._power_distributing_actor = PowerDistributingActor(
221-
users_channels={"default": self._power_distribution_channel.service_handle},
210+
requests_receiver=self._power_distribution_channel.new_receiver(),
211+
channel_registry=self._channel_registry,
222212
battery_status_sender=self._battery_status_channel.new_sender(),
223213
)
224214

@@ -344,15 +334,6 @@ def battery_pool(battery_ids: abc.Set[int] | None = None) -> BatteryPool:
344334
return _get().battery_pool(battery_ids)
345335

346336

347-
def power_distributing_handle() -> Bidirectional.Handle[Request, Result]:
348-
"""Return the handle to the power distributing actor.
349-
350-
Returns:
351-
A Bidirectional handle to communicate with the power distributing actor.
352-
"""
353-
return _get().power_distributing_handle()
354-
355-
356337
def _get() -> _DataPipeline:
357338
if _DATA_PIPELINE is None:
358339
raise RuntimeError(

0 commit comments

Comments
 (0)