Skip to content

Commit

Permalink
move wait period to the request getter
Browse files Browse the repository at this point in the history
  • Loading branch information
RHammond2 committed Sep 15, 2023
1 parent a709162 commit 8e3409e
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions wombat/core/service_equipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@ def get_next_request(self):
simpy.resources.store.FilterStoreGet
The next ``RepairRequest`` to be processed.
"""
# Avoid requests for the same system and therefore a timing collision
seconds_to_wait, *_ = (
self.env.random_generator.integers(low=0, high=10, size=1) / 3600.0
)
yield self.env.timeout(seconds_to_wait)

if self.settings.method == "turbine":
return self.manager.get_request_by_system(self.settings.capability)
if self.settings.method == "severity":
Expand Down Expand Up @@ -1647,12 +1653,6 @@ def run_scheduled_in_situ(self) -> Generator[Process, None, None]:
)
)

# Avoid requests for the same system and therefore a timing collision
seconds_to_wait, *_ = (
self.env.random_generator.integers(low=0, high=10, size=1) / 3600.0
)
yield self.env.timeout(seconds_to_wait)

request = self.get_next_request()
if request is None:
if not self.at_port:
Expand Down Expand Up @@ -1745,12 +1745,6 @@ def run_unscheduled_in_situ(self) -> Generator[Process, None, None]:
return

while True and self.env.now < charter_end_env_time:
# Avoid requests for the same system and therefore a timing collision
seconds_to_wait, *_ = (
self.env.random_generator.integers(low=0, high=10, size=1) / 3600.0
)
yield self.env.timeout(seconds_to_wait)

request = self.get_next_request()
if request is None:
yield self.env.process(
Expand Down Expand Up @@ -1835,12 +1829,6 @@ def run_unscheduled_in_situ(self) -> Generator[Process, None, None]:
)
)

# Avoid requests for the same system and therefore a timing collision
seconds_to_wait, *_ = (
self.env.random_generator.integers(low=0, high=10, size=1) / 3600.0
)
yield self.env.timeout(seconds_to_wait)

request = self.get_next_request()
if request is None:
yield self.env.process(
Expand Down

0 comments on commit 8e3409e

Please sign in to comment.