Skip to content

Commit

Permalink
ScenarioControlEnv: Stop running simulation in "reset" if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
andreArtelt committed Jan 14, 2025
1 parent 3372ee0 commit df8024d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions epyt_flow/gym/scenario_control_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ def reset(self) -> Union[tuple[ScadaData, bool], ScadaData]:
Current SCADA data (i.e. sensor readings).
"""
if self._scenario_sim is not None:
# Abort current simulation if any is runing
try:
next(self._sim_generator)
self._sim_generator.send(True)
except StopIteration:
pass

# Close scenario
self._scenario_sim.close()

self._scenario_sim = ScenarioSimulator(
Expand Down

0 comments on commit df8024d

Please sign in to comment.