OpenModelica / OpenModelica

OpenModelica is an open-source Modelica-based modeling and simulation environment intended for industrial and academic usage.
https://openmodelica.org
Other
818 stars 305 forks source link

Usage of setCommandLineOptions vs. CompilerFlag and SimulationFlag #12711

Open olivleno opened 2 months ago

olivleno commented 2 months ago

Description

The scripting API docu is providing

setCommandLineOptions

with an explanation limited to:

"The input is a regular command-line flag given to OMC, e.g. -d=failtrace or -g=MetaModelica"

and no type definition of the function arguments

OMEdit has in the Settings Dialog:

Looking for flags one can find:

There seems to be no place where these terms are properly defined.

Steps to Reproduce

  1. Try to figure out how to use: setCommandLineOptions
  2. Search the scripting API docu
  3. scroll through 2000 lines of options
  4. Finally search for "LOG_ASSERT", as this is given in the OMEdit Options Dialog and find it under simulation flags
  5. Try the following:
sim_flags="-lv=-LOG_ASSERT"
OMJulia.API.setCommandLineOptions(omc, sim_flags) 

ERROR: Failed to set command line options "-lv=-LOG_ASSERT".
Error: Unknown option -lv.

Expected Behavior

Version and OS

Additional Context

The API is powerful but really hard to use.

casella commented 2 months ago

@olivleno you are right, this thing is a bit messy, we got used to it but it's unecessarily obscure to beginners. I tried to describe it in the user's guide, but probably this is not clear enough. Have you read that already?

There are indeed three sets of flags

I can try to improve the documentation, where would you suggest to discuss this in the User's Guide? I guess we should also explicitly explain the relationship between settings in OMEdit, setting when using the command line interface, and settings when using the scripting API, as well as OMPython/OMJulia/OMMatlab

olivleno commented 2 months ago

@casella thanks for the link. I must admit that I did not read this section of the user's guide. I was looking for this type of information in the context of the scripting API. Unfortunately these terms are used as if they were self-explaining. As it cannot be expected that a documentation is read top to bottom I would appreciate if these terms were introduced in the first sentence of the respective section, e.g. Translation Flags and Simulation Flags.

Other places like scripting api or OMJulia.API.setCommandLineOptions could then link to these definitions or simply add a few words.

Generally speaking the api docu is very sparse. It's basically repeating the function signature without explanations of its purpose.

olivleno commented 2 months ago

I see very big potential in having this scripting api. Giving a good introduction on how to use it in practice, including which console or tool to use, how to choose/set the work directory, which environment variables/modelica path are needed, e.g., to report a bug as reproducible mos script would be a good starting point.

Second, the scripting functions must contain at least on explaining sentence that is more than the repetition of the name of the function.

casella commented 1 month ago

@olivleno I agree with all your comments. I can't take care of that now, please come back to me in September and we'll try to improve this substantially.

casella commented 1 month ago

See also #12712