@@ -57,52 +57,65 @@ def __init__(self, battery_pool: BatteryPool, source_id: str | None, priority: i
5757 self ._source_id = unique_id if source_id is None else f"{ source_id } -{ unique_id } "
5858 self ._priority = priority
5959
60- async def set_power (
60+ async def propose_power (
6161 self ,
62- preferred_power : Power | None ,
62+ power : Power | None ,
6363 * ,
6464 request_timeout : timedelta = timedelta (seconds = 5.0 ),
6565 include_broken_batteries : bool = False ,
66- _bounds : timeseries .Bounds [Power | None ] = timeseries .Bounds (None , None ),
66+ bounds : timeseries .Bounds [Power | None ] = timeseries .Bounds (None , None ),
6767 ) -> None :
68- """Set the given power for the batteries in the pool .
68+ """Send a proposal to the power manager for the pool's set of batteries .
6969
7070 Power values need to follow the Passive Sign Convention (PSC). That is, positive
7171 values indicate charge power and negative values indicate discharge power.
7272
73- When not using the Passive Sign Convention, the `charge` and `discharge` methods
74- might be more convenient.
73+ If the same batteries are shared by multiple actors, the power manager will
74+ consider the priority of the actors, the bounds they set, and their preferred
75+ power, when calculating the target power for the batteries.
76+
77+ The preferred power of lower priority actors will take precedence as long as
78+ they respect the bounds set by higher priority actors. If lower priority actors
79+ request power values outside of the bounds set by higher priority actors, the
80+ target power will be closest value to the preferred power that is within the
81+ bounds.
82+
83+ When there are no other actors trying to use the same batteries, the actor's
84+ preferred power would be set as the target power, as long as it falls within the
85+ system power bounds for the batteries.
7586
7687 The result of the request can be accessed using the receiver returned from the
7788 `power_distribution_results` method.
7889
7990 Args:
80- preferred_power: The power to set for the batteries in the pool.
91+ power: The power to propose for the batteries in the pool. If None, the
92+ proposed power of higher priority actors will take precedence as the
93+ target power.
8194 request_timeout: The timeout for the request.
8295 include_broken_batteries: if True, the power will be set for all batteries
8396 in the pool, including the broken ones. If False, then the power will be
8497 set only for the working batteries. This is not a guarantee that the
8598 power will be set for all working batteries, as the microgrid API may
8699 still reject the request.
87- _bounds : The power bounds for the request . These bounds will apply to actors
88- with a lower priority, and can be overridden by bounds from actors with
89- a higher priority. If None, the power bounds will be set to the maximum
90- power of the batteries in the pool. This is currently and experimental
91- feature.
100+ bounds : The power bounds for the proposal . These bounds will apply to
101+ actors with a lower priority, and can be overridden by bounds from
102+ actors with a higher priority. If None, the power bounds will be set
103+ to the maximum power of the batteries in the pool. This is currently
104+ and experimental feature.
92105 """
93106 await self ._battery_pool ._power_manager_requests_sender .send (
94107 _power_managing .Proposal (
95108 source_id = self ._source_id ,
96- preferred_power = preferred_power ,
97- bounds = _bounds ,
109+ preferred_power = power ,
110+ bounds = bounds ,
98111 battery_ids = self ._battery_pool ._batteries ,
99112 priority = self ._priority ,
100113 request_timeout = request_timeout ,
101114 include_broken_batteries = include_broken_batteries ,
102115 )
103116 )
104117
105- async def charge (
118+ async def propose_charge (
106119 self ,
107120 power : Power | None ,
108121 * ,
@@ -113,14 +126,21 @@ async def charge(
113126
114127 Power values need to be positive values, indicating charge power.
115128
116- When using the Passive Sign Convention, the `set_power ` method might be more
129+ When using the Passive Sign Convention, the `propose_power ` method might be more
117130 convenient.
118131
132+ If the same batteries are shared by multiple actors, the behaviour is the same
133+ as that of the `propose_power` method. The bounds for lower priority actors
134+ can't be specified with this method. If that's required, use the
135+ `propose_power` method instead.
136+
119137 The result of the request can be accessed using the receiver returned from
120- the `power_distribution_results ` method.
138+ the `power_status ` method.
121139
122140 Args:
123- power: Unsigned charge power to set for the batteries in the pool.
141+ power: The unsigned charge power to propose for the batteries in the pool.
142+ If None, the proposed power of higher priority actors will take
143+ precedence as the target power.
124144 request_timeout: The timeout for the request.
125145 include_broken_batteries: if True, the power will be set for all batteries
126146 in the pool, including the broken ones. If False, then the power will be
@@ -145,7 +165,7 @@ async def charge(
145165 )
146166 )
147167
148- async def discharge (
168+ async def propose_discharge (
149169 self ,
150170 power : Power | None ,
151171 * ,
@@ -156,14 +176,21 @@ async def discharge(
156176
157177 Power values need to be positive values, indicating discharge power.
158178
159- When using the Passive Sign Convention, the `set_power ` method might be more
179+ When using the Passive Sign Convention, the `propose_power ` method might be more
160180 convenient.
161181
182+ If the same batteries are shared by multiple actors, the behaviour is the same
183+ as that of the `propose_power` method. The bounds for lower priority actors
184+ can't be specified with this method. If that's required, use the
185+ `propose_power` method instead.
186+
162187 The result of the request can be accessed using the receiver returned from
163- the `power_distribution_results ` method.
188+ the `power_status ` method.
164189
165190 Args:
166- power: Unsigned discharge power to set for the batteries in the pool.
191+ power: The unsigned discharge power to propose for the batteries in the
192+ pool. If None, the proposed power of higher priority actors will take
193+ precedence as the target power.
167194 request_timeout: The timeout for the request.
168195 include_broken_batteries: if True, the power will be set for all batteries
169196 in the pool, including the broken ones. If False, then the power will be
0 commit comments