Skip to content

ModelicaSystem does not show plot window #144

@bilderbuchi

Description

@bilderbuchi

I am trying to plot results using the ModelicaSystem API, but the plot window is not shown.
This is on Windows, using OMPython master and a recent OM nightly(OpenModelica v1.18.0-dev.beta1 (64-bit)).

Based on examples from the documentation, using the omc API works, it shows a plot window (the sleep is just there so that the window does not immediately disappear when the script is finished):

from OMPython import OMCSessionZMQ
omc = OMCSessionZMQ()
cmds = [
  'loadFile(getInstallationDirectoryPath() + "/share/doc/omc/testmodels/BouncingBall.mo")',
  "simulate(BouncingBall)",
  "plot(h)"
  ]
for cmd in cmds:
  answer = omc.sendExpression(cmd)
  print("\n{}:\n{}".format(cmd, answer))
from time import sleep
sleep(5)

Doing the same thing (I hope?!) with the ModelicaSystem API does not show a window:

from time import sleep

from OMPython import OMCSessionZMQ
omc = OMCSessionZMQ()
model_path=omc.sendExpression("getInstallationDirectoryPath()") + "/share/doc/omc/testmodels/"
from OMPython import ModelicaSystem
mod=ModelicaSystem(model_path + "BouncingBall.mo","BouncingBall")
mod.simulate()
print('now plot ')
mod.sendExpression('plot(h)')
print(mod.requestApi('getErrorString'))
print('done, now sleep')
sleep(5)

output (notice: nothing in the error string):

LOG_SUCCESS       | info    | The initialization finished successfully without homotopy method.
LOG_SUCCESS       | info    | The simulation finished successfully.
now plot

done, now sleep

I tried to find out what's going wrong, but couldn't find anything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions