.OpenModelica.Scripting

Contents

NameDescription
CheckSettingsResult
Internal
checkSettingsDisplay some diagnostics.
loadFileload file (*.mo) and merge it with the loaded AST.
loadFilesload files (*.mo) and merges them with the loaded AST.
parseEncryptedPackage
loadEncryptedPackage
reloadClassreloads the file associated with the given (loaded class)
loadStringParses the data and merges the resulting AST with ithe loaded AST. If a filename is given, it is used to provide error-messages as if the string was read in binary format from a file with the same name. The file is converted to UTF-8 from the given character set. When merge is true the classes cNew in the file will be merged with the already loaded classes cOld in the following way: 1. get all the inner class definitions from cOld that were loaded from a different file than itself 2. append all elements from step 1 to class cNew public list NOTE: Encoding is deprecated as *ALL* strings are now UTF-8 encoded.
loadClassContentStringLoads class elements from a string and inserts them into the given loaded class.
parseString
parseFile
loadFileInteractiveQualified
loadFileInteractive
systemSimilar to system(3). Executes the given command in the system shell.
system_parallelSimilar to system(3). Executes the given commands in the system shell, in parallel if omc was compiled using OpenMP.
saveAllsave the entire loaded AST to file.
helpdisplay the OpenModelica help text.
clearClears everything: symboltable and variables.
clearProgramClears loaded .
clearVariablesClear all user defined variables.
generateHeader
generateJuliaHeader
generateSeparateCode
generateSeparateCodeDependencies
generateSeparateCodeDependenciesMakefile
getLinker
setLinker
getLinkerFlags
setLinkerFlags
getCompilerCC
setCompilerCC
setCFlagsCFLAGS
getCFlagsCFLAGS
getCXXCompilerCXX
setCXXCompilerCXX
verifyCompiler
setCompilerPath
getCompileCommand
setCompileCommand
setPlotCommand
getSettings
setTempDirectoryPath
getTempDirectoryPathReturns the current user temporary directory location.
getEnvironmentVarReturns the value of the environment variable.
setEnvironmentVar
appendEnvironmentVarAppends a variable to the environment variables list.
setInstallationDirectoryPathSets the OPENMODELICAHOME environment variable. Use this method instead of setEnvironmentVar.
getInstallationDirectoryPathThis returns OPENMODELICAHOME if it is set; on some platforms the default path is returned if it is not set.
setModelicaPathThe Modelica Library Path - MODELICAPATH in the language specification; OPENMODELICALIBRARY in OpenModelica.
getModelicaPathGet the Modelica Library Path.
getHomeDirectoryPathThis returns the path to user HOME directory.
setCompilerFlags
enableNewInstantiation
disableNewInstantiation
setDebugFlagsexample input: failtrace,-noevalfunc
clearDebugFlagsResets all debug flags to their default values.
setPreOptModulesexample input: removeFinalParameters,removeSimpleEquations,expandDerOperator
setCheapMatchingAlgorithmexample input: 3
getMatchingAlgorithm
getAvailableMatchingAlgorithms
setMatchingAlgorithmexample input: omc
getIndexReductionMethod
getAvailableIndexReductionMethods
setIndexReductionMethodexample input: dynamicStateSelection
setPostOptModulesexample input: lateInline,inlineArrayEqn,removeSimpleEquations.
getTearingMethod
getAvailableTearingMethods
setTearingMethodexample input: omcTearing
setCommandLineOptionsThe input is a regular command-line flag given to OMC, e.g. -d=failtrace or -g=MetaModelica
getCommandLineOptionsReturns all command line options who have non-default values as a list of strings. The format of the strings is '--flag=value --flag2=value2'.
getConfigFlagValidOptionsReturns the list of valid options for a string config flag, and the description strings for these options if available
clearCommandLineOptionsResets all command-line flags to their default values.
getVersionReturns the version of the Modelica compiler.
regularFileExists
directoryExists
stat
readFileThe contents of the given file are returned. Note that if the function fails, the error message is returned as a string instead of multiple output or similar.
writeFileWrite the data to file. Returns true on success.
compareFilesAndMove
compareFiles
alarm
regexSets the error buffer and returns -1 if the regex does not compile. The returned result is the same as POSIX regex(): The first value is the complete matched string The rest are the substrings that you wanted. For example: regex(lorem," \([A-Za-z]*\) \([A-Za-z]*\) ",maxMatches=3) => {" ipsum dolor ","ipsum","dolor"} This means if you have n groups, you want maxMatches=n+1
regexBoolReturns true if the string matches the regular expression.
testsuiteFriendlyName
readFileNoNumericReturns the contents of the file, with anything resembling a (real) number stripped out, and at the end adding: Filter count from number domain: n. This should probably be changed to multiple outputs; the filtered string and an integer. Does anyone use this API call?
getErrorStringReturns the current error message. [file.mo:n:n-n:n:b] Error: message
getMessagesStringsee getErrorString()
SourceInfo
ErrorKind
ErrorLevel
ErrorMessage
getMessagesStringInternal{{[file.mo:n:n-n:n:b] Error: message, TRANSLATION, Error, code}} if unique = true (the default) only unique messages will be shown
countMessages
clearMessagesClears the error buffer.
runScriptRuns the mos-script specified by the filename.
echoecho(false) disables Interactive output, echo(true) enables it again.
getClassesInModelicaPathMathCore-specific or not? Who knows!
getAnnotationVersionReturns the current annotation version.
setAnnotationVersionSets the annotation version.
getNoSimplifyReturns true if noSimplify flag is set.
setNoSimplifySets the noSimplify flag.
getVectorizationLimit
setVectorizationLimit
getDefaultOpenCLDeviceReturns the id for the default OpenCL device to be used.
setDefaultOpenCLDeviceSets the default OpenCL device to be used.
setShowAnnotations
getShowAnnotations
setOrderConnectionsSets the orderConnection flag.
getOrderConnectionsReturns true if orderConnections flag is set.
setLanguageStandardSets the Modelica Language Standard.
getLanguageStandardReturns the current Modelica Language Standard in use.
getAstAsCorbaStringPrint the whole AST on the CORBA format for records, e.g. record Absyn.PROGRAM classes = ..., within_ = ..., globalBuildTimes = ... end Absyn.PROGRAM;
cdchange directory to the given path (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.
mkdircreate directory of given path (which may be either relative or absolute) returns true if directory was created or already exists.
copycopies the source file to the destination file. Returns true if the file has been copied.
removeremoves a file or directory of given path (which may be either relative or absolute).
checkModelChecks a model and returns number of variables and equations.
checkAllModelsRecursiveChecks all models recursively and returns number of variables and equations.
typeOf
instantiateModelInstantiates the class and returns the flat Modelica code.
generateCodeThe input is a function name for which C-code is generated and compiled into a dll/so
loadModelLoads the Modelica Standard Library.
deleteFileDeletes a file with the given name.
saveModel
saveTotalModelSave the className model in a single file, together with all the other classes that it depends upon, directly and indirectly. This file can be later reloaded with the loadFile() API function, which loads className and all the other needed classes into memory. This is useful to allow third parties to run a certain model (e.g. for debugging) without worrying about all the library dependencies. Please note that SaveTotal file is not a valid Modelica .mo file according to the specification, and cannot be loaded in OMEdit - it can only be loaded with loadFile().
saveTotalModelDebugSaves the className model in a single file, together with all other classes that it depends on. This function uses a naive heuristic based on which identifiers are used and might save things which are not actually used, and is meant to be used in cases where the normal saveTotalModel fails.
save
saveTotalSCode
translateGraphics
codeToString
dumpXMLDAEOutputs the DAE system corresponding to a specific model.
convertUnits
getDerivedUnits
listVariablesLists the names of the active variables in the scripting environment.
strtokSplits the strings at the places given by the token, for example: strtok("abcbdef","b") => {"a","c","def"} strtok("abcbdef","cd") => {"ab","ef"}
stringSplitSplits the string at the places given by the character
stringReplace
escapeXML
ExportKind
listLists the contents of the given class, or all loaded classes.
listFileLists the contents of the file given by the class.
DiffFormat
diffModelicaFileListingsCreates diffs of two strings corresponding to Modelica files
exportToFigaro
inferBindings
generateVerificationScenarios
rewriteBlockCallFunction for property modeling, transforms block calls into instantiations for a loaded model
realpathGet full path name of file or directory name
uriToFilename
getLoadedLibraries
solveLinearSystemSolve A*X = B using dgesv. Returns for solver dgesv: info>0: Singular for element i. info<0: Bad input.
StandardStream
reopenStandardStream
importFMUImports the Functional Mockup Unit Example command: importFMU("A.fmu");
importFMUModelDescriptionImports modelDescription.xml Example command: importFMUModelDescription("A.xml");
translateModelFMUDeprecated: Use buildModelFMU instead. Translates a modelica model into a Functional Mockup Unit. The only required argument is the className, while all others have some default values. Example command: translateModelFMU(className, version="2.0");
buildModelFMUtranslates a modelica model into a Functional Mockup Unit. The only required argument is the className, while all others have some default values. Example command: buildModelFMU(className, version="2.0");
buildEncryptedPackage
simulatesimulates a modelica model by generating c code, build it and run the simulation executable. The only required argument is the className, while all others have some default values. simulate(className, [startTime], [stopTime], [numberOfIntervals], [tolerance], [method], [fileNamePrefix], [options], [outputFormat], [variableFilter], [cflags], [simflags]) Example command: simulate(A);
translateModelTranslates a modelica model into C code without building it.
buildModelbuilds a modelica model by generating c code and build it. It does not run the code! The only required argument is the className, while all others have some default values. simulate(className, [startTime], [stopTime], [numberOfIntervals], [tolerance], [method], [fileNamePrefix], [options], [outputFormat], [variableFilter], [cflags], [simflags]) Example command: buildModel(A);
buildLabelbuilds Label.
reduceTermsreduce terms.
moveClassMoves a class up or down depending on the given offset, where a positive offset moves the class down and a negative offset up. The offset is truncated if the resulting index is outside the class list. It retains the visibility of the class by adding public/protected sections when needed, and merges sections of the same type if the class is moved from a section it was alone in. Returns true if the move was successful, otherwise false.
moveClassToTopMoves a class to the top of its enclosing class. Returns true if the move was successful, otherwise false.
moveClassToBottomMoves a class to the bottom of its enclosing class. Returns true if the move was successful, otherwise false.
copyClassCopies a class within the same level
linearizecreates a model with symbolic linearization matrices
optimizeoptimize a modelica/optimica model by generating c code, build it and run the optimization executable. The only required argument is the className, while all others have some default values. simulate(className, [startTime], [stopTime], [numberOfIntervals], [stepSize], [tolerance], [fileNamePrefix], [options], [outputFormat], [variableFilter], [cflags], [simflags]) Example command: simulate(A);
getSourceFileReturns the filename of the class.
setSourceFile
isShortDefinitionreturns true if the definition is a short class definition
setClassCommentSets the class comment.
getClassNamesReturns the list of class names defined in the class.
getUsedClassNamesReturns the list of class names used in the total program defined by the class.
getPackagesReturns the list of packages defined in the class.
getAllSubtypeOfReturns the list of all classes that extend from className given a parentClass where the lookup for className should start
basePlotFunctionExtending this does not seem to work at the moment. A real shame; functions below are copy-paste and all need to be updated if the interface changes.
plotLaunches a plot window using OMPlot.
plotAllWorks in the same way as plot(), but does not accept any variable names as input. Instead, all variables are part of the plot window. Example command sequences: simulate(A);plotAll(); simulate(A);plotAll(externalWindow=true); simulate(A,fileNamePrefix="B");simulate(C);plotAll(x,fileName="B.mat");
plotParametricLaunches a plotParametric window using OMPlot. Returns true on success. Example command sequences: simulate(A);plotParametric(x,y); simulate(A);plotParametric(x,y, externalWindow=true);
readSimulationResultReads a result file, returning a matrix corresponding to the variables and size given.
readSimulationResultSizeThe number of intervals that are present in the output file.
readSimulationResultVarsReturns the variables in the simulation file; you can use val() and plot() commands using these names.
filterSimulationResults
compareSimulationResultscompares simulation results.
deltaSimulationResultscalculates the sum of absolute errors.
diffSimulationResultscompares simulation results.
diffSimulationResultsHtml
checkTaskGraphChecks if the given taskgraph has the same structure as the reference taskgraph and if all attributes are set correctly.
checkCodeGraphChecks if the given taskgraph has the same structure as the graph described in the codefile.
valReturn the value of a variable at a given time in the simulation results
closeSimulationResultFileCloses 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.
addClassAnnotation
getParameterNames
getParameterValue
getComponentModifierNames
getComponentModifierValue
getComponentModifierValues
removeComponentModifiers
getElementModifierNames
setComponentModifierValue
setElementModifierValue
getElementModifierValue
getElementModifierValues
removeElementModifiers
setExtendsModifierValue
getElementAnnotation
setElementAnnotation
setElementType
getInstantiatedParametersAndValues
removeExtendsModifiers
updateConnection
updateConnectionAnnotation
updateConnectionNames
getConnectionCountCounts the number of connect equation in a class.
getNthConnectionReturns the Nth connection. Example command: getNthConnection(A) => {"from", "to", "comment"}
getConnectionListreturns an array of all connections including those within loops
getAlgorithmCountCounts the number of Algorithm sections in a class.
getNthAlgorithmReturns the Nth Algorithm section.
getInitialAlgorithmCountCounts the number of Initial Algorithm sections in a class.
getNthInitialAlgorithmReturns the Nth Initial Algorithm section.
getAlgorithmItemsCountCounts the number of Algorithm items in a class.
getNthAlgorithmItemReturns the Nth Algorithm Item.
getInitialAlgorithmItemsCountCounts the number of Initial Algorithm items in a class.
getNthInitialAlgorithmItemReturns the Nth Initial Algorithm Item.
getEquationCountCounts the number of Equation sections in a class.
getNthEquationReturns the Nth Equation section.
getInitialEquationCountCounts the number of Initial Equation sections in a class.
getNthInitialEquationReturns the Nth Initial Equation section.
getEquationItemsCountCounts the number of Equation items in a class.
getNthEquationItemReturns the Nth Equation Item.
getInitialEquationItemsCountCounts the number of Initial Equation items in a class.
getNthInitialEquationItemReturns the Nth Initial Equation Item.
getAnnotationCountCounts the number of Annotation sections in a class.
getNthAnnotationStringReturns the Nth Annotation section as string.
getImportCountCounts the number of Import sections in a class.
getMMfileTotalDependencies
getImportedNamesReturns the prefix paths of all imports in a class.
getNthImportReturns the Nth Import as string.
iconvThe iconv() function converts one multibyte characters from one character set to another. See man (3) iconv for more information.
getDocumentationAnnotationReturns the documentaiton annotation defined in the class.
setDocumentationAnnotation
getTimeStamp
stringTypeName
stringVariableName
typeNameString
typeNameStrings
getClassCommentReturns the class comment.
dirname
basename
getClassRestriction
isType
isPackage
isClass
isRecord
isBlock
isFunction
isPartial
isReplaceable
isRedeclare
isModel
isConnector
isOptimization
isEnumeration
isOperator
isOperatorRecord
isOperatorFunction
isProtectedClass
getBuiltinType
setInitXmlStartValue
ngspicetoModelicaConverts ngspice netlist to Modelica code. Modelica file is created in the same directory as netlist file.
getInheritedClasses
getComponentsTestreturns an array of records with information about the components of the given class
isExperiment
getSimulationOptions
getAnnotationNamedModifiers
getAnnotationModifierValue
classAnnotationExistsCheck if annotation exists
getBooleanClassAnnotationCheck if annotation exists and returns its value
extendsFromreturns true if the given class extends from the given base class
loadModelica3D
searchClassNamesSearches for the class name in the all the loaded classes. Example command: searchClassNames("ground"); searchClassNames("ground", true);
getAvailableLibraries
getAvailableLibraryVersions
installPackage
updatePackageIndex
upgradeInstalledPackages
getAvailablePackageVersions
getAvailablePackageConversionsTo
getAvailablePackageConversionsFrom
getUses
getConversionsFromVersions
getDerivedClassModifierNamesReturns the derived class modifier names. Example command: type Resistance = Real(final quantity="Resistance",final unit="Ohm"); getDerivedClassModifierNames(Resistance) => {"quantity","unit"}
getDerivedClassModifierValueReturns the derived class modifier value. Example command: type Resistance = Real(final quantity="Resistance",final unit="Ohm"); getDerivedClassModifierValue(Resistance, unit); => " = "Ohm"" getDerivedClassModifierValue(Resistance, quantity); => " = "Resistance""
generateEntryPoint
numProcessors
runScriptParallel
exit
threadWorkFailed
getMemorySize
GC_gcollect_and_unmap
GC_expand_hp
GC_set_max_heap_size
GC_PROFSTATS
GC_get_prof_stats
checkInterfaceOfPackages
sortStrings
getClassInformation
getTransitions
addTransition
deleteTransition
updateTransition
getInitialStates
addInitialState
deleteInitialState
updateInitialState
generateScriptingAPI
runConversionScript
convertPackageToLibrary
getModelInstanceDumps a model instance as a JSON string.
getModelInstanceAnnotationDumps the annotation of a model using the same JSON format as getModelInstance, optionally filtering out only certain parts.
modifierToJSONParses a modifier given as a string and dumps it as JSON.
storeAST
restoreAST
qualifyPath
oms_system
oms_causality
oms_signal_type
oms_solver
oms_tlm_domain
oms_tlm_interpolation
oms_fault_type
loadOMSimulatorloads the OMSimulator DLL from default path
unloadOMSimulatorfree the OMSimulator instances
oms_addBus
oms_addConnection
oms_addConnector
oms_addConnectorToBus
oms_addConnectorToTLMBus
oms_addDynamicValueIndicator
oms_addEventIndicator
oms_addExternalModel
oms_addSignalsToResults
oms_addStaticValueIndicator
oms_addSubModel
oms_addSystem
oms_addTimeIndicator
oms_addTLMBus
oms_addTLMConnection
oms_compareSimulationResults
oms_copySystem
oms_delete
oms_deleteConnection
oms_deleteConnectorFromBus
oms_deleteConnectorFromTLMBus
oms_export
oms_exportDependencyGraphs
oms_exportSnapshot
oms_extractFMIKind
oms_getBoolean
oms_getFixedStepSize
oms_getInteger
oms_getModelState
oms_getReal
oms_getSolver
oms_getStartTime
oms_getStopTime
oms_getSubModelPath
oms_getSystemType
oms_getTolerance
oms_getVariableStepSize
oms_faultInjection
oms_importFile
oms_importSnapshot
oms_initialize
oms_instantiate
oms_list
oms_listUnconnectedConnectors
oms_loadSnapshot
oms_newModel
oms_removeSignalsFromResults
oms_rename
oms_reset
oms_RunFile
oms_setBoolean
oms_setCommandLineOption
oms_setFixedStepSize
oms_setInteger
oms_setLogFile
oms_setLoggingInterval
oms_setLoggingLevel
oms_setReal
oms_setRealInputDerivative
oms_setResultFile
oms_setSignalFilter
oms_setSolver
oms_setStartTime
oms_setStopTime
oms_setTempDirectory
oms_setTLMPositionAndOrientation
oms_setTLMSocketData
oms_setTolerance
oms_setVariableStepSize
oms_setWorkingDirectory
oms_simulate
oms_stepUntil
oms_terminate
oms_getVersionReturns the version of the OMSimulator.
Experimental

Generated at 2024-12-03T19:25:34Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos