diff --git a/sw/utility/simulation.py b/sw/utility/simulation.py index cd08690..b0b7fe8 100644 --- a/sw/utility/simulation.py +++ b/sw/utility/simulation.py @@ -153,7 +153,6 @@ class Simulator: if the number of target frame errors has been reached """ if self._curr_num_frame_errors >= self._target_frame_errors: - # TODO: Properly handle the multiple decoders self._BERs[self._current_decoder_index] \ .append(self._curr_num_bit_errors / (self._curr_num_iterations * self._n)) @@ -256,6 +255,7 @@ class SimulationManager: signal.signal(signal.SIGINT, self._exit_gracefully) signal.signal(signal.SIGTERM, self._exit_gracefully) + signal.signal(signal.SIGHUP, self._exit_gracefully) # # Functions relating to the pausing and restarting of simulations @@ -266,7 +266,10 @@ class SimulationManager: return os.path.isfile(self._sim_state_filepath) def load_unfinished(self): - """Load the state of an unfinished simulation its savefile.""" + """Load the state of an unfinished simulation its savefile. + + Warning: This function deletes the savefile after loading. + """ assert self.unfinished_simulation_present() self._logger.info("Loading saved simulation state") @@ -274,6 +277,8 @@ class SimulationManager: with open(self._sim_state_filepath, "rb") as file: self._simulator = pickle.load(file) + os.remove(self._sim_state_filepath) + # TODO: Make sure old state is overwritten def _save_state(self) -> None: """Write the state of the currently configured simulation to a savefile.""" @@ -296,6 +301,8 @@ class SimulationManager: self._simulator.stop() self._save_state() + exit() + # # Functions responsible for the actual simulation #