Arbitrary API calls to simulators.

Issue #26 resolved
Stefan Scherfke
created an issue

It may be cool if we could call arbitrary functions in a simulator from our scenario defintion. These calls would technically be the same as init(), create(), step() and get_data() but not formally specified. Thus, if something goes wrong with these calls, its the user’s fault. :-)

A use-case for this is the mosaik-hdf5: It would be nice if we could send static data to it while we create the scenario.

Possible implementations:

# (1)
hdf5 = world.start('HDF5', ...)
hdf5.call('custom_method', spam='eggs')

# (2)
hdf5 = world.start('HDF5', ...)
hdf5.custom_method(spam='eggs')

(1)

Pros: - Makes it very explicit that we gonna do some magic now. - Model name call would be forbidden to prevent name clashes with the call() method of the model factory.

Cons: - Little more typing

(2) Pros: - Pythonic – we just call a method of our simulator

Cons: - More possible name clashes. Optional functions may not be named like models. - Confusion: Did I just create a model instance or call a method of the simulator? - More implicit then (1)

Comments (1)

  1. Log in to comment