Skip to content

Commit 5e10562

Browse files
committed
Add frequency metric to Inverter and EVCharger data
Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent a8f3d62 commit 5e10562

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/frequenz/sdk/microgrid/component/_component_data.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ class InverterData(ComponentData):
278278
"""
279279
# pylint: enable=line-too-long
280280

281+
frequency: float
282+
"""AC frequency, in Hertz (Hz)."""
283+
281284
_component_state: inverter_pb.ComponentState.ValueType
282285
"""State of the inverter."""
283286

@@ -303,6 +306,7 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> InverterData:
303306
active_power_exclusion_lower_bound=raw_power.system_exclusion_bounds.lower,
304307
active_power_inclusion_upper_bound=raw_power.system_inclusion_bounds.upper,
305308
active_power_exclusion_upper_bound=raw_power.system_exclusion_bounds.upper,
309+
frequency=raw.inverter.data.ac.frequency.value,
306310
_component_state=raw.inverter.state.component_state,
307311
_errors=list(raw.inverter.errors),
308312
)
@@ -332,6 +336,9 @@ class EVChargerData(ComponentData):
332336
wire for phase/line 1,2 and 3 respectively.
333337
"""
334338

339+
frequency: float
340+
"""AC frequency, in Hertz (Hz)."""
341+
335342
cable_state: EVChargerCableState
336343
"""The state of the ev charger's cable."""
337344

@@ -366,6 +373,7 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> EVChargerData:
366373
component_state=EVChargerComponentState.from_pb(
367374
raw.ev_charger.state.component_state
368375
),
376+
frequency=raw.ev_charger.data.ac.frequency.value,
369377
)
370378
ev_charger_data._set_raw(raw=raw)
371379
return ev_charger_data

tests/utils/component_data_wrapper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def __init__( # pylint: disable=too-many-arguments
106106
active_power_exclusion_lower_bound: float = math.nan,
107107
active_power_inclusion_upper_bound: float = math.nan,
108108
active_power_exclusion_upper_bound: float = math.nan,
109+
frequency: float = 50.0,
109110
_component_state: inverter_pb.ComponentState.ValueType = (
110111
inverter_pb.ComponentState.COMPONENT_STATE_UNSPECIFIED
111112
),
@@ -125,6 +126,7 @@ def __init__( # pylint: disable=too-many-arguments
125126
active_power_inclusion_upper_bound=active_power_inclusion_upper_bound,
126127
active_power_exclusion_upper_bound=active_power_exclusion_upper_bound,
127128
_component_state=_component_state,
129+
frequency=frequency,
128130
_errors=_errors if _errors else [],
129131
)
130132

@@ -154,6 +156,7 @@ def __init__( # pylint: disable=too-many-arguments
154156
active_power: float = math.nan,
155157
current_per_phase: Tuple[float, float, float] | None = None,
156158
voltage_per_phase: Tuple[float, float, float] | None = None,
159+
frequency: float = 50.0,
157160
cable_state: EVChargerCableState = EVChargerCableState.UNSPECIFIED,
158161
component_state: EVChargerComponentState = EVChargerComponentState.UNSPECIFIED,
159162
) -> None:
@@ -176,6 +179,7 @@ def __init__( # pylint: disable=too-many-arguments
176179
if voltage_per_phase
177180
else (math.nan, math.nan, math.nan)
178181
),
182+
frequency=frequency,
179183
cable_state=cable_state,
180184
component_state=component_state,
181185
)

0 commit comments

Comments
 (0)