Jack
Jack

Reputation: 1242

How to use openmodelica compiler in CLI?

I am trying to use OpenModelica compiler(omc) in the CLI, so I use the Terminalprovided in OMEdit. I tried to debug Modelica.Blocks.Examples.PID_Controller, but it seems omc couldn't find this model.

en

So I duplicated the PID_Controller model and put into a folder, then switched working directory in the CLI. At this time, omc could access the model, but it couldn't find the base model of Modelica.Icon.Example, I am guessing that omc doesn't have access to the Modelica Standard Library(MSL) loaded in the OMEdit.

My question is how to let omc load the MSL correctly.

enter image description here

Upvotes: 1

Views: 1109

Answers (1)

Adrian Pop
Adrian Pop

Reputation: 4231

-d are debug flags used in general by the developers

If you want to use omc from command line the easiest is to use .mos scripts:

The script: c:\writable\directory\script.mos

loadModel(Modelica); getErrorString(); // load the Modelica Standard Library (MSL)
simulate(Modelica.Blocks.Examples.PID_Controller); getErrorString(); // simulate a model
plotAll(); getErroString(); // plot all variables

Then from the command line, go to a directory where you can generate some output:

cd c:\writable\directory\
omc script.mos

See all the available API (the commands you can put in a mos script) here: https://build.openmodelica.org/Documentation/OpenModelica.Scripting.html

Upvotes: 3

Related Questions