Functions

Exchange of simulation data between different components of NRP Core is performed by user-defined Functions. They are Python functions that live inside of the NRP Core main process. Three types of Functions are currently supported:

Simulation time and iteration number

It is possible to get access to the current simulation time and iteration number in all Functions. Both of these values can be acquired by adding a proper decorator to the Python function definition, for example:

@SimulationIteration(keyword="sim_iter")
@SimulationTime(keyword="sim_time")
@StatusFunction()
def status_function(sim_iter, sim_time):
    # sim_iter will contain current iteration number, starting at 0
    # sim_time will contain current simulation time in nanoseconds
    pass

The SimulationIteration decorator will return the current iteration number, starting at 0. The SimulationTime decorator will return the current simulation time in nanoseconds. Both of these decorators require a single argument, which is the name (keyword) under which it is going to be accessible in the Python function. The same keyword must be added as the function parameter.