Skip to content

Commit

Permalink
* NEW: Changed default max_site, max_cycles, sleep_time
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis-chambers committed Jun 3, 2024
1 parent 055aab0 commit aa64852
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
9 changes: 3 additions & 6 deletions src/iotdevicesimulator/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class SensorSite:
topic_prefix: Prefixes the sensor topic.
"""

cycle: int | None = 0
cycle: int = 0
"""Current cycle."""

max_cycles: int = 1
max_cycles: int = 0
"""Maximum number of data transfer cycles before shutting down."""

sleep_time: int = 30
sleep_time: int = 60
"""Time to sleep for each time data is sent."""

site_id: str
Expand Down Expand Up @@ -92,9 +92,6 @@ def __init__(self, site_id: str,*, sleep_time: int|None=None,
if topic_prefix is not None:
self.topic_prefix = str(topic_prefix)

if topic_prefix is not None:
self.topic_prefix = str(topic_prefix)

self._instance_logger.info(f"Initialised Site: {repr(self)}")

def __repr__(self):
Expand Down
14 changes: 7 additions & 7 deletions src/iotdevicesimulator/swarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ class CosmosSwarm:
_instance_logger: logging.Logger
"""Logger handle used by instance."""

max_cycles: int = 1
max_cycles: int = 0
"""Maximum number of data transfer cycles before shutting down."""

max_sites: int = 5
max_sites: int = 0
"""Maximum number of sites allowed to be instantiated."""

sleep_time: int = 30
sleep_time: int = 60
"""Time to sleep for each time data is sent."""

sites: List[SensorSite]
Expand All @@ -55,7 +55,7 @@ class CosmosSwarm:
query: CosmosQuery
"""Query run in database."""

topic_prefix: str = None
topic_prefix: str | None = None
"""Adds prefix to sensor topic."""

def __len__(self):
Expand Down Expand Up @@ -252,9 +252,9 @@ async def _get_oracle(
@staticmethod
def _init_sites(
site_ids: List[str],
sleep_time: int = 10,
max_cycles: int = 3,
max_sites: int = 0,
sleep_time: int | None = None,
max_cycles: int | None = None,
max_sites: int | None = None,
swarm_logger: logging.Logger | None = None,
delay_start: bool = False,
topic_prefix: str | None = None,
Expand Down

0 comments on commit aa64852

Please sign in to comment.