Skip to content

Commit b7707ea

Browse files
committed
Add num_values to have a configurable amount of iterations
Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent 08ee2b4 commit b7707ea

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/timeseries/mock_microgrid.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,16 @@ class MockMicrogrid: # pylint: disable=too-many-instance-attributes
5353

5454
_microgrid: MockMicrogridClient
5555

56-
def __init__(self, grid_side_meter: bool, sample_rate_s: float = 0.01):
57-
"""Create a new instance."""
56+
def __init__(
57+
self, grid_side_meter: bool, num_values: int = 2000, sample_rate_s: float = 0.01
58+
):
59+
"""Create a new instance.
60+
61+
Args:
62+
grid_side_meter: whether the main meter should be on the grid side or not.
63+
num_values: number of values to generate for each component.
64+
sample_rate_s: sample rate in seconds.
65+
"""
5866
self._components: Set[Component] = set(
5967
[
6068
Component(1, ComponentCategory.GRID),
@@ -64,6 +72,7 @@ def __init__(self, grid_side_meter: bool, sample_rate_s: float = 0.01):
6472
self._connections: Set[Connection] = set([Connection(1, 4)])
6573
self._id_increment = 0
6674
self._grid_side_meter = grid_side_meter
75+
self._num_values = num_values
6776
self._sample_rate_s = sample_rate_s
6877

6978
self._connect_to = self.grid_id
@@ -106,7 +115,7 @@ async def start(
106115
async def _comp_data_send_task(
107116
self, comp_id: int, make_comp_data: Callable[[int, datetime], ComponentData]
108117
) -> None:
109-
for value in range(1, 2000):
118+
for value in range(1, self._num_values + 1):
110119
timestamp = datetime.now(tz=timezone.utc)
111120
val_to_send = value + int(comp_id / 10)
112121
# for inverters with component_id > 100, send only half the messages.

0 commit comments

Comments
 (0)