producer
frequenz.sdk.timeseries.producer ¤
The logical component for calculating high level producer metrics for a microgrid.
Classes¤
frequenz.sdk.timeseries.producer.Producer ¤
Calculate high level producer metrics in a microgrid.
Under normal circumstances this is expected to correspond to the gross production of the sites active parts excluding EV chargers and batteries.
Producer provides methods for fetching power values from different points
in the microgrid. These methods return FormulaReceiver
objects, which can
be used like normal Receiver
s, but can also be composed to form
higher-order formula streams.
Note
Producer
instances are not meant to be created directly by users.
Use the microgrid.producer
method
for creating Producer
instances.
Example
from datetime import timedelta
from frequenz.sdk import microgrid
from frequenz.sdk.timeseries import ResamplerConfig
await microgrid.initialize(
"grpc://127.0.0.1:50051",
ResamplerConfig(resampling_period=timedelta(seconds=1.0))
)
producer = microgrid.producer()
# Get a receiver for a builtin formula
producer_power_recv = producer.power.new_receiver()
async for producer_power_sample in producer_power_recv:
print(producer_power_sample)
Source code in frequenz/sdk/timeseries/producer.py
Attributes¤
power
property
¤
power: FormulaEngine[Power]
Fetch the producer power for the microgrid.
This formula produces values that are in the Passive Sign Convention (PSC).
It will start the formula engine to calculate producer power if it is not already running.
A receiver from the formula engine can be created using the
new_receiver
method.
RETURNS | DESCRIPTION |
---|---|
FormulaEngine[Power]
|
A FormulaEngine that will calculate and stream producer power. |
Functions¤
__init__ ¤
__init__(
channel_registry: ChannelRegistry,
resampler_subscription_sender: Sender[
ComponentMetricRequest
],
) -> None
Initialize the producer formula generator.
PARAMETER | DESCRIPTION |
---|---|
channel_registry
|
The channel registry to use for the producer.
TYPE:
|
resampler_subscription_sender
|
The sender to use for resampler subscriptions.
TYPE:
|