hbp_nrp_simserver.server.nrp_core_wrapper module¶
A Wrapper for NrpCore clients instances making it amenable to be controlled interactively. It adds cooperative execution via thread synchronization and checks on simulation timeouts
-
exception
hbp_nrp_simserver.server.nrp_core_wrapper.
NRPSimulationTimeout
[source]¶ Bases:
Exception
Raised by NrpCoreWrapped.run_loop when as simulation timeout has been reached
-
exception
hbp_nrp_simserver.server.nrp_core_wrapper.
NRPStopExecution
[source]¶ Bases:
Exception
Raised by NrpCoreWrapped.run_loop when called in a stopped state
-
class
hbp_nrp_simserver.server.nrp_core_wrapper.
NrpCoreWrapper
(nrp_core_class: Type[nrp_client.NrpCore], sim_id: str, exp_config_file: str, exp_config: types.SimpleNamespace, paused_event: threading.Event, stopped_event: threading.Event)[source]¶ Bases:
object
-
NRP_CORE_DEFAULT_ADDRESS_PORT
= 'localhost:5345'¶
-
property
max_timesteps
¶ return: configured timeout / configured timestep as int
-
property
real_time
¶ ” :return: The wall-clock elapsed execution time in secs as a float
-
run_loop
(num_iterations: int = 1, json_data: Optional[str] = None) → Optional[dict][source]¶ Ask to advance the simulation of num_iterations timesteps.
In the case such number of iterations will result in the timeout being reached, an NRPSimulationTimeout exception will be raised; the simulation won’t be advanced.
See nrp_client.NrpCore.run_loop for further details.
- Raises
NRPSimulationTimeout – if running for num_iterations will exceed the configured simulation timeout (i.e. curr_timestep + num_iterations > max_timestep)
NRPStopExecution – when stopped_event is set.
- Returns
same as NrpCore.run_loop, i.e any JSON data passed in the response or None
-
property
simulation_time
¶ ” :return: the simulation time in seconds as a float
-
property
simulation_time_remaining
¶ ” :return: the simulation time remaining until the configured timeout in seconds as a float
-