The simulation manager is responsible for starting simulation processes and shutting them down.
It is able to start pure Python simulators in-process (by importing and instantiating them), to start external simulation processes and to connect to already running simulators and manage access to them.
Start the simulator sim_name based on the configuration im world.sim_config, give it the ID sim_id and pass the parameters of the dict sim_params to it.
The sim config is a dictionary with one entry for every simulator. The entry itself tells mosaik how to start the simulator:
{
'ExampleSimA': {
'python': 'example_sim.mosaik:ExampleSim',
},
'ExampleSimB': {
'cmd': 'example_sim %(addr)s',
'cwd': '.',
},
'ExampleSimC': {
'connect': 'host:port',
},
}
ExampleSimA is a pure Python simulator. Mosaik will import the module example_sim.mosaik and instantiate the class ExampleSim to start the simulator.
ExampleSimB would be started by executing the command example_sim and passing the network address of mosaik das command line argument. You can optionally specify a current working directory. It defaults to ..
ExampleSimC can not be started by mosaik, so mosaik tries to connect to it.
The function returns a mosaik_api.Simulator instance.
It raises a SimulationError if the simulator could not be started.
Return a SimProxy instance.
Import and instantiate the Python simulator sim_name based on its config entry conf.
Return a LocalProcess instance.
Raise a ScenarioError if the simulator cannot be instantiated.
Start a new process for simulator sim_name based on its config entry conf.
Return a RemoteProcess instance.
Raise a ScenarioError if the simulator cannot be instantiated.
Connect to the already running simulator sim_name based on its config entry conf.
Return a RemoteProcess instance.
Raise a ScenarioError if the simulator cannot be instantiated.
Simple proxy/facade for in-process simulators.
Stop the simulator behind the proxy.
The default implementation does nothing.
Proxy for internal simulators.
Yield a triggered event but do nothing else.
Proxy for external simulator processes.
Send a stop message to the process represented by this proxy and wait for it to terminate.
Return the data for the requested attributes attrs.
Attributes is a dict of (fully qualified) entity IDs mapping to lists of attribute names ({'sid/eid': ['attr1', 'attrs']}).
The return value is a dict mapping the input entity IDs to data dictionaries mapping attribute names to there respective values.
Return the current simulation progress from sim_progress.
Get a list of entities for entities.
An entity may either be the string 'sim_id/entity_id' or just 'entity_id'. If the latter is the case, use self.sim_id to identify the entiy.
The return value is a dict mapping 'sim_id/entity_id' to sorted lists of tuples ('sim_id/entity_id', entity_type).