OMJulia.API

Module OMJulia.API aims to provide a Julia interface to the OpenModelica scripting API. In contrast to sending the scripting api calls directly via sendExpression this API has a Julia-like interface and some level of error handling implemented. This means errors will throw Julia Exception OMJulia.API.ScriptingError instead of only printing to stdout.

Warn

Not all OMJulia.API functions are tested and some functions could have slightly different default values compared to the OpenModelica scripting API.

Instead of escaping strings yourself the API interface handles this for you:

sendExpression(omc, "loadFile(\"$(bouncingBallFile)\")")

becomes

API.loadFile(omc, bouncingBallFile)

Functions

OMJulia.API.buildModelMethod
buildModel(omc, className;
           startTime = 0.0,
           stopTime = 1.0,
           numberOfIntervals = 500,
           tolerance = 1e-6,
           method = "",
           fileNamePrefix = className,
           options = "",
           outputFormat = "mat",
           variableFilter = ".*",
           cflags = "",
           simflags = "")

Build Modelica model by generating C code and compiling it into an executable simulation. It does not run the simulation!

See OpenModelica scripting API buildModel.

source
OMJulia.API.buildModelFMUMethod
buildModelFMU(omc, className;
              version = "2.0",
              fmuType = "me",
              fileNamePrefix=className,
              platforms=["static"],
              includeResources = false)

Translates a modelica model into a Functional Mockup Unit. The only required argument is the className, while all others have some default values.

See OpenModelica scripting API buildModelFMU.

source
OMJulia.API.cdFunction
cd(omc, newWorkingDirectory="")

Change directory to the given path newWorkingDirectory (which may be either relative or absolute). Returns the new working directory on success or a message on failure. If the given path is the empty string, the function simply returns the current working directory.

See OpenModelica scripting API cd.

source
OMJulia.API.closeSimulationResultFileMethod
    closeSimulationResultFile(omc)

Closes the current simulation result file. Only needed by Windows. Windows cannot handle reading and writing to the same file from different processes. To allow OMEdit to make successful simulation again on the same file we must close the file after reading the Simulation Result Variables. Even OMEdit only use this API for Windows.

See OpenModelica scripting API closeSimulationResultFile.

source
OMJulia.API.simulateMethod
simulate(omc, className;
        startTime = 0.0,
        stopTime = nothing,
        numberOfIntervals = 500,
        tolerance = 1e-6,
        method = "",
        fileNamePrefix=className,
        options = "",
        outputFormat = "mat",
        variableFilter = ".*",
        cflags = "",
        simflags = "")

Simulates a modelica model by generating C code, build it and run the simulation executable.

See OpenModelica scripting API simulate.

source
OMJulia.API.ScriptingErrorType
ScriptingError <: Exception

OpenModelica scripting error with message msg and additional error string from getErrroString.

source