Skip to content

Commit

Permalink
Expose the 3-phase active power through microgrid
Browse files Browse the repository at this point in the history
The 3-phase active power is needed to calculate the power factor
of the microgrid. The power factor is not available through
the microgrid API in the current version used in the SDK.

So the 3-phase active power is temporary exposed through the
microgrid API until the migration to the latest version is
completed. Then the 3-phase power factor can be fetched
and streamed through the microgrid API.

Signed-off-by: Daniel Zullo <daniel.zullo@frequenz.com>
  • Loading branch information
daniel-zullo-frequenz committed Feb 1, 2024
1 parent a39f4f0 commit 4681446
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/frequenz/sdk/microgrid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
from ..actor import ResamplerConfig
from . import _data_pipeline, client, component, connection_manager, metadata
from ._data_pipeline import (
_active_power,
battery_pool,
consumer,
ev_charger_pool,
Expand All @@ -149,6 +150,7 @@ async def initialize(host: str, port: int, resampler_config: ResamplerConfig) ->

__all__ = [
"initialize",
"_active_power",
"client",
"component",
"consumer",
Expand Down
17 changes: 17 additions & 0 deletions src/frequenz/sdk/microgrid/_data_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from ..actor._actor import Actor
from ..timeseries._base_types import PoolType
from ..timeseries._grid_frequency import GridFrequency
from ..timeseries._power_streamer import ActivePowerStreamer
from ..timeseries._voltage_streamer import VoltageStreamer
from ..timeseries.grid import Grid
from ..timeseries.grid import get as get_grid
Expand Down Expand Up @@ -127,6 +128,7 @@ def __init__(
self._battery_pools: dict[frozenset[int], BatteryPoolReferenceStore] = {}
self._frequency_instance: GridFrequency | None = None
self._voltage_instance: VoltageStreamer | None = None
self._active_power_instance: ActivePowerStreamer | None = None

def frequency(self) -> GridFrequency:
"""Return the grid frequency measuring point."""
Expand All @@ -148,6 +150,16 @@ def voltage(self) -> VoltageStreamer:

return self._voltage_instance

def active_power(self) -> ActivePowerStreamer:
"""Return the 3-phase active power measuring point."""
if not self._active_power_instance:
self._active_power_instance = ActivePowerStreamer(
self._resampling_request_sender(),
self._channel_registry,
)

return self._active_power_instance

def logical_meter(self) -> LogicalMeter:
"""Return the logical meter of the microgrid."""
from ..timeseries.logical_meter import LogicalMeter
Expand Down Expand Up @@ -434,6 +446,11 @@ def voltage() -> VoltageStreamer:
return _get().voltage()


def _active_power() -> ActivePowerStreamer:
"""Return the 3-phase active power measuring point."""
return _get().active_power()


def logical_meter() -> LogicalMeter:
"""Return the logical meter of the microgrid."""
return _get().logical_meter()
Expand Down

0 comments on commit 4681446

Please sign in to comment.