|
8 | 8 | import typing |
9 | 9 | import uuid |
10 | 10 | from collections import abc |
| 11 | +from datetime import timedelta |
11 | 12 |
|
12 | 13 | from ..._internal._channels import ReceiverFetcher |
13 | 14 | from ...actor import _power_managing |
| 15 | +from ...timeseries import Bounds |
14 | 16 | from .._base_types import SystemBounds |
15 | 17 | from .._quantities import Current, Power |
16 | 18 | from ..formula_engine import FormulaEngine, FormulaEngine3Phase |
@@ -66,6 +68,66 @@ def __init__( # pylint: disable=too-many-arguments |
66 | 68 | self._source_id = unique_id if name is None else f"{name}-{unique_id}" |
67 | 69 | self._priority = priority |
68 | 70 |
|
| 71 | + async def propose_power( |
| 72 | + self, |
| 73 | + power: Power | None, |
| 74 | + *, |
| 75 | + request_timeout: timedelta = timedelta(seconds=5.0), |
| 76 | + bounds: Bounds[Power | None] = Bounds(None, None), |
| 77 | + ) -> None: |
| 78 | + """Send a proposal to the power manager for the pool's set of EV chargers. |
| 79 | +
|
| 80 | + This proposal is for the maximum power that can be set for the EV chargers in |
| 81 | + the pool. The actual consumption might be lower based on the number of phases |
| 82 | + an EV is drawing power from, and its current state of charge. |
| 83 | +
|
| 84 | + Power values need to follow the Passive Sign Convention (PSC). That is, positive |
| 85 | + values indicate charge power and negative values indicate discharge power. |
| 86 | + Discharging from EV chargers is currently not supported. |
| 87 | +
|
| 88 | + If the same EV chargers are shared by multiple actors, the power manager will |
| 89 | + consider the priority of the actors, the bounds they set, and their preferred |
| 90 | + power, when calculating the target power for the EV chargers |
| 91 | +
|
| 92 | + The preferred power of lower priority actors will take precedence as long as |
| 93 | + they respect the bounds set by higher priority actors. If lower priority actors |
| 94 | + request power values outside of the bounds set by higher priority actors, the |
| 95 | + target power will be the closest value to the preferred power that is within the |
| 96 | + bounds. |
| 97 | +
|
| 98 | + When there are no other actors trying to use the same EV chargers, the actor's |
| 99 | + preferred power would be set as the target power, as long as it falls within the |
| 100 | + system power bounds for the EV chargers. |
| 101 | +
|
| 102 | + The result of the request can be accessed using the receiver returned from the |
| 103 | + [`power_status`][frequenz.sdk.timeseries.ev_charger_pool.EVChargerPool.power_status] |
| 104 | + method, which also streams the bounds that an actor should comply with, based on |
| 105 | + its priority. |
| 106 | +
|
| 107 | + Args: |
| 108 | + power: The power to propose for the EV chargers in the pool. If `None`, |
| 109 | + this proposal will not have any effect on the target power, unless |
| 110 | + bounds are specified. If both are `None`, it is equivalent to not |
| 111 | + having a proposal or withdrawing a previous one. |
| 112 | + request_timeout: The timeout for the request. |
| 113 | + bounds: The power bounds for the proposal. These bounds will apply to |
| 114 | + actors with a lower priority, and can be overridden by bounds from |
| 115 | + actors with a higher priority. If None, the power bounds will be set to |
| 116 | + the maximum power of the batteries in the pool. This is currently and |
| 117 | + experimental feature. |
| 118 | + """ |
| 119 | + await self._ev_charger_pool.power_manager_requests_sender.send( |
| 120 | + _power_managing.Proposal( |
| 121 | + source_id=self._source_id, |
| 122 | + preferred_power=power, |
| 123 | + bounds=bounds, |
| 124 | + component_ids=self._ev_charger_pool.component_ids, |
| 125 | + priority=self._priority, |
| 126 | + creation_time=asyncio.get_running_loop().time(), |
| 127 | + request_timeout=request_timeout, |
| 128 | + ) |
| 129 | + ) |
| 130 | + |
69 | 131 | @property |
70 | 132 | def component_ids(self) -> abc.Set[int]: |
71 | 133 | """Return component IDs of all EV Chargers managed by this EVChargerPool. |
|
0 commit comments