|
49 | 49 | from ..timeseries.consumer import Consumer |
50 | 50 | from ..timeseries.ev_charger_pool import EVChargerPool |
51 | 51 | from ..timeseries.logical_meter import LogicalMeter |
| 52 | + from ..timeseries.producer import Producer |
52 | 53 |
|
53 | 54 |
|
54 | 55 | _REQUEST_RECV_BUFFER_SIZE = 500 |
@@ -120,6 +121,7 @@ def __init__( |
120 | 121 |
|
121 | 122 | self._logical_meter: LogicalMeter | None = None |
122 | 123 | self._consumer: Consumer | None = None |
| 124 | + self._producer: Producer | None = None |
123 | 125 | self._grid: Grid | None = None |
124 | 126 | self._ev_charger_pools: dict[frozenset[int], EVChargerPool] = {} |
125 | 127 | self._battery_pools: dict[frozenset[int], BatteryPoolReferenceStore] = {} |
@@ -188,6 +190,23 @@ def consumer(self) -> Consumer: |
188 | 190 | ) |
189 | 191 | return self._consumer |
190 | 192 |
|
| 193 | + def producer(self) -> Producer: |
| 194 | + """Return the producer instance. |
| 195 | +
|
| 196 | + If a Producer instance doesn't exist, a new one is created and returned. |
| 197 | +
|
| 198 | + Returns: |
| 199 | + A Producer instance. |
| 200 | + """ |
| 201 | + from ..timeseries.producer import Producer |
| 202 | + |
| 203 | + if self._producer is None: |
| 204 | + self._producer = Producer( |
| 205 | + channel_registry=self._channel_registry, |
| 206 | + resampler_subscription_sender=self._resampling_request_sender(), |
| 207 | + ) |
| 208 | + return self._producer |
| 209 | + |
191 | 210 | def ev_charger_pool( |
192 | 211 | self, |
193 | 212 | ev_charger_ids: set[int] | None = None, |
@@ -471,6 +490,11 @@ def consumer() -> Consumer: |
471 | 490 | return _get().consumer() |
472 | 491 |
|
473 | 492 |
|
| 493 | +def producer() -> Producer: |
| 494 | + """Return the [`Production`][frequenz.sdk.timeseries.producer.Producer] measuring point.""" |
| 495 | + return _get().producer() |
| 496 | + |
| 497 | + |
474 | 498 | def ev_charger_pool(ev_charger_ids: set[int] | None = None) -> EVChargerPool: |
475 | 499 | """Return the corresponding EVChargerPool instance for the given ids. |
476 | 500 |
|
|
0 commit comments