The final step in the process is to create a wrapper to allow easy programmatic control of OMC. I have posted a simple wrapper that provides the facilities required by the bouncing ball example here. It is not at the same level as the work by Ganeson et al. of course.
Using this wrapper, the bouncing ball example is much simpler than before, requiring only
import sys from omc import OMC omc = OMC() omc.connect() omc.clear() print omc._send_command("model test end test;") print omc.list_classes() print omc.load_file("/usr/share/doc/omc/testmodels/BouncingBall.mo") print omc.simulate("BouncingBall") print omc.plot("h")
Note that my wrapper doesn’t provide a specific method for directly injecting things like models. If it did, it would be a redirect to _send_command and so I’ve simply used that for this example.
With this fairly short third part, I will end the series here. Hopefully it provides a useful starting point for more complex projects.