Commit 4cdecb1
authored
Make FormulaEngine instances composable, instead of FormulaReceivers (#327)
This PR changes how formulas are composed -
- receivers from formulas are no longer composable.
- formula composition is now done by composing FormulaEngine instances.
- Automatic formulas from the logical meter and *pools, are now
properties, and return `FormulaEngine` instances, which can be composed
further, or can provide a receiver to fetch values.
``` python
grid_power_receiver =
microgrid.logical_meter().grid_power.new_receiver()
self._inverter_power = (
microgrid.logical_meter().pv_power
+ microgrid.logical_meter().battery_power
).build("inverter_power")
inverter_power_receiver = self._inverter_power.new_receiver()
```
The type hint issues in the formula engine are also resolved.File tree
21 files changed
+478
-525
lines changed- examples
- src/frequenz/sdk/timeseries
- _formula_engine
- _formula_generators
- ev_charger_pool
- logical_meter
- tests/timeseries
- _formula_engine
21 files changed
+478
-525
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
9 | 27 | | |
10 | 28 | | |
11 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | 137 | | |
144 | 138 | | |
145 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
| 5 | + | |
13 | 6 | | |
14 | 7 | | |
15 | 8 | | |
16 | 9 | | |
17 | 10 | | |
18 | 11 | | |
19 | | - | |
20 | | - | |
21 | 12 | | |
22 | | - | |
23 | | - | |
24 | 13 | | |
25 | 14 | | |
0 commit comments