Skip to content

Commit 60b0772

Browse files
Remove FormulaType
The formula Type has been used to distinguish between consumption, production or passive sign convention formulas. With the recent changes the sdk only provides passive sign convention formulas. Signed-off-by: Matthias Wende <[email protected]>
1 parent b23f47a commit 60b0772

File tree

10 files changed

+3
-74
lines changed

10 files changed

+3
-74
lines changed

src/frequenz/sdk/timeseries/battery_pool/_battery_pool.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from ..formula_engine._formula_generators import (
2222
BatteryPowerFormula,
2323
FormulaGeneratorConfig,
24-
FormulaType,
2524
)
2625
from ._battery_pool_reference_store import BatteryPoolReferenceStore
2726
from ._methods import SendOnUpdate
@@ -255,7 +254,6 @@ def power(self) -> FormulaEngine[Power]:
255254
BatteryPowerFormula,
256255
FormulaGeneratorConfig(
257256
component_ids=self._battery_pool._batteries,
258-
formula_type=FormulaType.PASSIVE_SIGN_CONVENTION,
259257
),
260258
)
261259
assert isinstance(engine, FormulaEngine)

src/frequenz/sdk/timeseries/ev_charger_pool/_ev_charger_pool.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
EVChargerCurrentFormula,
2727
EVChargerPowerFormula,
2828
FormulaGeneratorConfig,
29-
FormulaType,
3029
)
3130
from ._set_current_bounds import BoundsSetter, ComponentCurrentLimit
3231
from ._state_tracker import EVChargerState, StateTracker
@@ -181,7 +180,6 @@ def power(self) -> FormulaEngine[Power]:
181180
EVChargerPowerFormula,
182181
FormulaGeneratorConfig(
183182
component_ids=self._component_ids,
184-
formula_type=FormulaType.PASSIVE_SIGN_CONVENTION,
185183
),
186184
)
187185
assert isinstance(engine, FormulaEngine)

src/frequenz/sdk/timeseries/formula_engine/_formula_generators/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
FormulaGenerationError,
1414
FormulaGenerator,
1515
FormulaGeneratorConfig,
16-
FormulaType,
1716
)
1817
from ._grid_current_formula import GridCurrentFormula
1918
from ._grid_power_formula import GridPowerFormula
@@ -26,7 +25,6 @@
2625
#
2726
"FormulaGenerator",
2827
"FormulaGeneratorConfig",
29-
"FormulaType",
3028
#
3129
# Power Formula generators
3230
#

src/frequenz/sdk/timeseries/formula_engine/_formula_generators/_battery_power_formula.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
NON_EXISTING_COMPONENT_ID,
1414
ComponentNotFound,
1515
FormulaGenerator,
16-
FormulaType,
1716
)
1817

1918
_logger = logging.getLogger(__name__)
@@ -78,12 +77,5 @@ def generate(
7877
builder.push_oper("+")
7978
builder.push_component_metric(comp.component_id, nones_are_zeros=True)
8079
builder.push_oper(")")
81-
if self._config.formula_type == FormulaType.PRODUCTION:
82-
builder.push_oper("*")
83-
builder.push_constant(-1)
84-
builder.push_oper(")")
85-
86-
if self._config.formula_type != FormulaType.PASSIVE_SIGN_CONVENTION:
87-
builder.push_clipper(0.0, None)
8880

8981
return builder.build()

src/frequenz/sdk/timeseries/formula_engine/_formula_generators/_chp_power_formula.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
NON_EXISTING_COMPONENT_ID,
1616
FormulaGenerationError,
1717
FormulaGenerator,
18-
FormulaType,
1918
)
2019

2120
_logger = logging.getLogger(__name__)
@@ -58,13 +57,6 @@ def generate( # noqa: DOC502 (FormulaGenerationError is raised indirectly by _g
5857
builder.push_oper("+")
5958
builder.push_component_metric(chp_meter_id, nones_are_zeros=False)
6059
builder.push_oper(")")
61-
if self._config.formula_type == FormulaType.PRODUCTION:
62-
builder.push_oper("*")
63-
builder.push_constant(-1)
64-
builder.push_oper(")")
65-
66-
if self._config.formula_type != FormulaType.PASSIVE_SIGN_CONVENTION:
67-
builder.push_clipper(0.0, None)
6860

6961
return builder.build()
7062

src/frequenz/sdk/timeseries/formula_engine/_formula_generators/_ev_charger_power_formula.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ....microgrid.component import ComponentMetricId
99
from ..._quantities import Power
1010
from .._formula_engine import FormulaEngine
11-
from ._formula_generator import NON_EXISTING_COMPONENT_ID, FormulaGenerator, FormulaType
11+
from ._formula_generator import NON_EXISTING_COMPONENT_ID, FormulaGenerator
1212

1313
_logger = logging.getLogger(__name__)
1414

@@ -48,12 +48,5 @@ def generate(self) -> FormulaEngine[Power]:
4848
builder.push_oper("+")
4949
builder.push_component_metric(component_id, nones_are_zeros=True)
5050
builder.push_oper(")")
51-
if self._config.formula_type == FormulaType.PRODUCTION:
52-
builder.push_oper("*")
53-
builder.push_constant(-1)
54-
builder.push_oper(")")
55-
56-
if self._config.formula_type != FormulaType.PASSIVE_SIGN_CONVENTION:
57-
builder.push_clipper(0.0, None)
5851

5952
return builder.build()

src/frequenz/sdk/timeseries/formula_engine/_formula_generators/_formula_generator.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from collections import abc
1010
from collections.abc import Callable
1111
from dataclasses import dataclass
12-
from enum import Enum
1312
from typing import Generic
1413

1514
from frequenz.channels import Sender
@@ -41,35 +40,13 @@ class ComponentNotFound(FormulaGenerationError):
4140
"""
4241

4342

44-
class FormulaType(Enum):
45-
"""Enum representing type of formula outputs."""
46-
47-
PASSIVE_SIGN_CONVENTION = 1
48-
"""Formula output will be signed values, following the passive sign convention, with
49-
consumption from the grid being positive and production to the grid being negative.
50-
"""
51-
52-
PRODUCTION = 2
53-
"""Formula output will be unsigned values representing production to the grid. When
54-
power is being consumed from the grid instead, this formula will output zero.
55-
"""
56-
57-
CONSUMPTION = 3
58-
"""Formula output will be unsigned values representing consumption from the grid.
59-
When power is being produced to the grid instead, this formula will output zero.
60-
"""
61-
62-
6343
@dataclass(frozen=True)
6444
class FormulaGeneratorConfig:
6545
"""Config for formula generators."""
6646

6747
component_ids: abc.Set[int] | None = None
6848
"""The component IDs to use for generating the formula."""
6949

70-
formula_type: FormulaType = FormulaType.PASSIVE_SIGN_CONVENTION
71-
"""The type of formula output."""
72-
7350

7451
class FormulaGenerator(ABC, Generic[QuantityT]):
7552
"""A class for generating formulas from the component graph."""

src/frequenz/sdk/timeseries/formula_engine/_formula_generators/_grid_power_formula.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ....microgrid.component import ComponentCategory, ComponentMetricId
77
from ..._quantities import Power
88
from .._formula_engine import FormulaEngine
9-
from ._formula_generator import FormulaGenerator, FormulaType
9+
from ._formula_generator import FormulaGenerator
1010

1111

1212
class GridPowerFormula(FormulaGenerator[Power]):
@@ -67,12 +67,4 @@ def generate( # noqa: DOC502
6767
)
6868
builder.push_oper(")")
6969

70-
if self._config.formula_type == FormulaType.PRODUCTION:
71-
builder.push_oper("*")
72-
builder.push_constant(-1)
73-
builder.push_oper(")")
74-
75-
if self._config.formula_type != FormulaType.PASSIVE_SIGN_CONVENTION:
76-
builder.push_clipper(0.0, None)
77-
7870
return builder.build()

src/frequenz/sdk/timeseries/formula_engine/_formula_generators/_pv_power_formula.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ....microgrid.component import ComponentCategory, ComponentMetricId
1010
from ..._quantities import Power
1111
from .._formula_engine import FormulaEngine
12-
from ._formula_generator import NON_EXISTING_COMPONENT_ID, FormulaGenerator, FormulaType
12+
from ._formula_generator import NON_EXISTING_COMPONENT_ID, FormulaGenerator
1313

1414
_logger = logging.getLogger(__name__)
1515

@@ -69,12 +69,5 @@ def generate( # noqa: DOC502
6969
nones_are_zeros=component.category != ComponentCategory.METER,
7070
)
7171
builder.push_oper(")")
72-
if self._config.formula_type == FormulaType.PRODUCTION:
73-
builder.push_oper("*")
74-
builder.push_constant(-1)
75-
builder.push_oper(")")
76-
77-
if self._config.formula_type != FormulaType.PASSIVE_SIGN_CONVENTION:
78-
builder.push_clipper(0.0, None)
7972

8073
return builder.build()

src/frequenz/sdk/timeseries/logical_meter/_logical_meter.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
from ..formula_engine._formula_generators import (
1717
CHPPowerFormula,
1818
ConsumerPowerFormula,
19-
FormulaGeneratorConfig,
20-
FormulaType,
2119
GridCurrentFormula,
2220
GridPowerFormula,
2321
ProducerPowerFormula,
@@ -242,7 +240,6 @@ def pv_power(self) -> FormulaEngine[Power]:
242240
engine = self._formula_pool.from_power_formula_generator(
243241
"pv_power",
244242
PVPowerFormula,
245-
FormulaGeneratorConfig(formula_type=FormulaType.PASSIVE_SIGN_CONVENTION),
246243
)
247244
assert isinstance(engine, FormulaEngine)
248245
return engine
@@ -265,7 +262,6 @@ def chp_power(self) -> FormulaEngine[Power]:
265262
engine = self._formula_pool.from_power_formula_generator(
266263
"chp_power",
267264
CHPPowerFormula,
268-
FormulaGeneratorConfig(formula_type=FormulaType.PASSIVE_SIGN_CONVENTION),
269265
)
270266
assert isinstance(engine, FormulaEngine)
271267
return engine

0 commit comments

Comments
 (0)