1414from frequenz .channels import Receiver , Sender
1515
1616from ..._internal ._asyncio import cancel_and_await
17- from ..._internal ._constants import RECEIVER_MAX_SIZE
1817from ...actor import ChannelRegistry , ComponentMetricRequest
1918from ...actor .power_distributing ._battery_pool_status import BatteryStatus
2019from ...microgrid import connection_manager
@@ -184,19 +183,19 @@ def consumption_power(self) -> FormulaEngine:
184183 assert isinstance (engine , FormulaEngine )
185184 return engine
186185
187- async def soc (
188- self , maxsize : int | None = RECEIVER_MAX_SIZE
189- ) -> Receiver [SoCMetrics | None ]:
186+ @property
187+ def soc (self ) -> MetricAggregator [SoCMetrics ]:
190188 """Get receiver to receive new soc metrics when they change.
191189
192- Soc formulas are described in the receiver return type.
193- None will be send if there is no component to calculate metric.
190+ Soc formulas are described in the receiver return type. None will be send if
191+ there is no component to calculate metric.
194192
195- Args:
196- maxsize: Maxsize of the receiver channel .
193+ A receiver from the MetricAggregator can be obtained by calling the
194+ `new_receiver` method .
197195
198196 Returns:
199- Receiver for this metric.
197+ A MetricAggregator that will calculate and stream the aggregate soc of
198+ all batteries in the pool.
200199 """
201200 method_name = SendOnUpdate .name () + "_" + SoCCalculator .name ()
202201
@@ -208,22 +207,21 @@ async def soc(
208207 min_update_interval = self ._min_update_interval ,
209208 )
210209
211- running_method = self ._active_methods [method_name ]
212- return running_method .new_receiver (maxsize )
210+ return self ._active_methods [method_name ]
213211
214- async def capacity (
215- self , maxsize : int | None = RECEIVER_MAX_SIZE
216- ) -> Receiver [CapacityMetrics | None ]:
212+ @property
213+ def capacity (self ) -> MetricAggregator [CapacityMetrics ]:
217214 """Get receiver to receive new capacity metrics when they change.
218215
219- Capacity formulas are described in the receiver return type.
220- None will be send if there is no component to calculate metrics.
216+ Capacity formulas are described in the receiver return type. None will be send
217+ if there is no component to calculate metrics.
221218
222- Args:
223- maxsize: Maxsize of the receiver channel .
219+ A receiver from the MetricAggregator can be obtained by calling the
220+ `new_receiver` method .
224221
225222 Returns:
226- Receiver for this metric.
223+ A MetricAggregator that will calculate and stream the capacity of all
224+ batteries in the pool.
227225 """
228226 method_name = SendOnUpdate .name () + "_" + CapacityCalculator .name ()
229227
@@ -235,22 +233,21 @@ async def capacity(
235233 min_update_interval = self ._min_update_interval ,
236234 )
237235
238- running_method = self ._active_methods [method_name ]
239- return running_method .new_receiver (maxsize )
236+ return self ._active_methods [method_name ]
240237
241- async def power_bounds (
242- self , maxsize : int | None = RECEIVER_MAX_SIZE
243- ) -> Receiver [PowerMetrics | None ]:
238+ @property
239+ def power_bounds (self ) -> MetricAggregator [PowerMetrics ]:
244240 """Get receiver to receive new power bounds when they change.
245241
246242 Power bounds formulas are described in the receiver return type.
247243 None will be send if there is no component to calculate metrics.
248244
249- Args:
250- maxsize: Maxsize of the receivers channel .
245+ A receiver from the MetricAggregator can be obtained by calling the
246+ `new_receiver` method .
251247
252248 Returns:
253- Receiver for this metric.
249+ A MetricAggregator that will calculate and stream the power bounds
250+ of all batteries in the pool.
254251 """
255252 method_name = SendOnUpdate .name () + "_" + PowerBoundsCalculator .name ()
256253
@@ -262,8 +259,7 @@ async def power_bounds(
262259 min_update_interval = self ._min_update_interval ,
263260 )
264261
265- running_method = self ._active_methods [method_name ]
266- return running_method .new_receiver (maxsize )
262+ return self ._active_methods [method_name ]
267263
268264 async def stop (self ) -> None :
269265 """Stop all pending async tasks."""
0 commit comments