Skip to content

Commit eef25ec

Browse files
Add 3-phase current formulas (#164)
This PR introduces some new types for streaming 3-phase data: - `Sample3Phase` :: for holding a 3-phase measurement. - `FormulaChannel3Phase/FormulaReceiver3Phase` :: composable channel/receiver types for streaming `Sample3Phase` objects. - `FormulaEngine3Phase` :: for combining `Sample` objects from `FormulaEngine` into `Sample3Phase` objects. - `HigherOrderFormulaBuilder3Phase` :: For composing `FormulaReceiver3Phase` and generating new `FormulaEngine3Phase` from them. It also adds formula generators for 3-phase `grid_current` and `ev_charger_current`, and exposes them through the `LogicalMeter`.
2 parents f409033 + 933e4ae commit eef25ec

File tree

11 files changed

+638
-94
lines changed

11 files changed

+638
-94
lines changed

src/frequenz/sdk/timeseries/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
[`Sample`][frequenz.sdk.timeseries.Sample]s.
99
"""
1010

11-
from ._base_types import Sample
11+
from ._base_types import Sample, Sample3Phase
1212

13-
__all__ = [
14-
"Sample",
15-
]
13+
__all__ = ["Sample", "Sample3Phase"]

src/frequenz/sdk/timeseries/_base_types.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,25 @@ class Sample:
2626

2727
value: Optional[float] = field(compare=False, default=None)
2828
"""The value of this sample."""
29+
30+
31+
@dataclass(frozen=True)
32+
class Sample3Phase:
33+
"""A 3-phase measurement made at a particular point in time.
34+
35+
Each of the `value` fields could be `None` if a component is malfunctioning
36+
or data is lacking for another reason, but a sample still needs to be sent
37+
to have a coherent view on a group of component metrics for a particular
38+
timestamp.
39+
"""
40+
41+
timestamp: datetime
42+
"""The time when this sample was generated."""
43+
value_p1: Optional[float]
44+
"""The value of the 1st phase in this sample."""
45+
46+
value_p2: Optional[float]
47+
"""The value of the 2nd phase in this sample."""
48+
49+
value_p3: Optional[float]
50+
"""The value of the 3rd phase in this sample."""

0 commit comments

Comments
 (0)