hbp_nrp_commons.simulation_lifecycle module

This package defines the simulation lifecycle such as used in the NRP

class SimulationLifecycle(synchronization_topic, initial_state='created')[source]

Bases: object

Defines the lifecycle of a simulation

accept_command(command)[source]

Accepts the given command for the simulation lifecycle

Parameters

command – the command that should be activated

fail(state_change)[source]

Gets called when the simulation fails

Parameters

state_change – The state change that caused the simulation to fail

final_states = ['stopped', 'failed']
initialize(state_change)[source]

Gets called when the simulation should be initialized

Parameters

state_change – The state change that caused the simulation to initialize

pause(state_change)[source]

Gets called when the simulation needs to be paused

Parameters

state_change – The state change that caused the simulation to pause

reset(state_change)[source]

Gets called when the simulation is reset

Parameters

state_change – The state change that caused the simulation to reset

static set_silent(state_change)[source]
Specifies that the given state change should not be propagated to other synchronized

lifecycles

Parameters

state_change – The state change that should not be propagated

shutdown(shutdown_event)[source]

Shuts down this simulation lifecycle instance

Parameters

shutdown_event – The event that caused the shutdown

start(state_change)[source]

Gets called when the simulation needs to be started

Parameters

state_change – The state change that caused the simulation to start

states = ['created', 'paused', 'started', 'stopped', 'halted', 'failed']
stop(state_change)[source]

Gets called when the simulation needs to be stopped

Parameters

state_change – The state change that caused the simulation to stop