.OpenModelica.Scripting

Contents

Name Description
CheckSettingsResult
Internal
checkSettings Display some diagnostics.
loadFile load file (*.mo) and merge it with the loaded AST.
loadFiles load files (*.mo) and merges them with the loaded AST.
loadEncryptedPackage
reloadClass reloads the file associated with the given (loaded class)
loadString Parses 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.
parseString
parseFile
loadFileInteractiveQualified
loadFileInteractive
system Similar to system(3). Executes the given command in the system shell.
system_parallel Similar to system(3). Executes the given commands in the system shell, in parallel if omc was compiled using OpenMP.
saveAll save the entire loaded AST to file.
help display the OpenModelica help text.
clear Clears everything: symboltable and variables.
clearProgram Clears loaded .
clearVariables Clear all user defined variables.
generateHeader
generateSeparateCode
generateSeparateCodeDependencies
generateSeparateCodeDependenciesMakefile
getLinker
setLinker
getLinkerFlags
setLinkerFlags
getCompiler CC
setCompiler CC
setCFlags CFLAGS
getCFlags CFLAGS
getCXXCompiler CXX
setCXXCompiler CXX
verifyCompiler
setCompilerPath
getCompileCommand
setCompileCommand
setPlotCommand
getSettings
setTempDirectoryPath
getTempDirectoryPath Returns the current user temporary directory location.
getEnvironmentVar Returns the value of the environment variable.
setEnvironmentVar
appendEnvironmentVar Appends a variable to the environment variables list.
setInstallationDirectoryPath Sets the OPENMODELICAHOME environment variable. Use this method instead of setEnvironmentVar.
getInstallationDirectoryPath This returns OPENMODELICAHOME if it is set; on some platforms the default path is returned if it is not set.
setModelicaPath The Modelica Library Path - MODELICAPATH in the language specification; OPENMODELICALIBRARY in OpenModelica.
getModelicaPath Get the Modelica Library Path.
setCompilerFlags
setDebugFlags example input: failtrace,-noevalfunc
clearDebugFlags Resets all debug flags to their default values.
setPreOptModules example input: removeFinalParameters,removeSimpleEquations,expandDerOperator
setCheapMatchingAlgorithm example input: 3
getMatchingAlgorithm
getAvailableMatchingAlgorithms
setMatchingAlgorithm example input: omc
getIndexReductionMethod
getAvailableIndexReductionMethods
setIndexReductionMethod example input: dynamicStateSelection
setPostOptModules example input: lateInline,inlineArrayEqn,removeSimpleEquations.
getTearingMethod
getAvailableTearingMethods
setTearingMethod example input: omcTearing
setCommandLineOptions The input is a regular command-line flag given to OMC, e.g. -d=failtrace or -g=MetaModelica
getCommandLineOptions Returns all command line options who have non-default values as a list of strings. The format of the strings is '--flag=value --flag2=value2'.
getConfigFlagValidOptions Returns the list of valid options for a string config flag, and the description strings for these options if available
clearCommandLineOptions Resets all command-line flags to their default values.
getVersion Returns the version of the Modelica compiler.
regularFileExists
directoryExists
stat
readFile The 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.
writeFile Write the data to file. Returns true on success.
compareFilesAndMove
compareFiles
alarm
regex Sets 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
regexBool Returns true if the string matches the regular expression.
testsuiteFriendlyName
readFileNoNumeric Returns 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?
getErrorString Returns the current error message. [file.mo:n:n-n:n:b] Error: message
getMessagesString see 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
clearMessages Clears the error buffer.
runScript Runs the mos-script specified by the filename.
echo echo(false) disables Interactive output, echo(true) enables it again.
getClassesInModelicaPath MathCore-specific or not? Who knows!
getAnnotationVersion Returns the current annotation version.
setAnnotationVersion Sets the annotation version.
getNoSimplify Returns true if noSimplify flag is set.
setNoSimplify Sets the noSimplify flag.
getVectorizationLimit
setVectorizationLimit
getDefaultOpenCLDevice Returns the id for the default OpenCL device to be used.
setDefaultOpenCLDevice Sets the default OpenCL device to be used.
setShowAnnotations
getShowAnnotations
setOrderConnections Sets the orderConnection flag.
getOrderConnections Returns true if orderConnections flag is set.
setLanguageStandard Sets the Modelica Language Standard.
getLanguageStandard Returns the current Modelica Language Standard in use.
getAstAsCorbaString Print the whole AST on the CORBA format for records, e.g. record Absyn.PROGRAM classes = ..., within_ = ..., globalBuildTimes = ... end Absyn.PROGRAM;
cd change 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.
mkdir create directory of given path (which may be either relative or absolute) returns true if directory was created or already exists.
copy copies the source file to the destined directory. Returns true if the file has been copied.
remove removes a file or directory of given path (which may be either relative or absolute).
checkModel Checks a model and returns number of variables and equations.
checkAllModelsRecursive Checks all models recursively and returns number of variables and equations.
typeOf
instantiateModel Instantiates the class and returns the flat Modelica code.
buildOpenTURNSInterface generates wrapper code for OpenTURNS
runOpenTURNSPythonScript runs OpenTURNS with the given python script returning the log file
generateCode The input is a function name for which C-code is generated and compiled into a dll/so
loadModel Loads the Modelica Standard Library.
deleteFile Deletes a file with the given name.
saveModel
saveTotalModel
save
saveTotalSCode
translateGraphics
codeToString
dumpXMLDAE Outputs the DAE system corresponding to a specific model.
convertUnits
getDerivedUnits
listVariables Lists the names of the active variables in the scripting environment.
strtok Splits the strings at the places given by the token, for example: strtok("abcbdef","b") => {"a","c","def"} strtok("abcbdef","cd") => {"ab","ef"}
stringSplit Splits the string at the places given by the character
stringReplace
escapeXML
ExportKind
list Lists the contents of the given class, or all loaded classes.
listFile Lists the contents of the file given by the class.
DiffFormat
diffModelicaFileListings Creates diffs of two strings corresponding to Modelica files
exportToFigaro
inferBindings
generateVerificationScenarios
rewriteBlockCall Function for property modeling, transforms block calls into instantiations for a loaded model
realpath Get full path name of file or directory name
uriToFilename
getLoadedLibraries
LinearSystemSolver
solveLinearSystem Solve A*X = B, using dgesv or lp_solve (if any variable in X is integer) Returns for solver dgesv: info>0: Singular for element i. info<0: Bad input. For solver lp_solve: ???
StandardStream
reopenStandardStream
importFMU Imports the Functional Mockup Unit Example command: importFMU("A.fmu");
importFMUModelDescription Imports modelDescription.xml Example command: importFMUModelDescription("A.xml");
translateModelFMU 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");
buildModelFMU 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: buildModelFMU(className, version="2.0");
buildEncryptedPackage
simulate simulates 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);
buildModel builds 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: simulate(A);
buildLabel builds Lable.
reduceTerms reduce terms.
moveClass Moves 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.
moveClassToTop Moves a class to the top of its enclosing class. Returns true if the move was successful, otherwise false.
moveClassToBottom Moves a class to the bottom of its enclosing class. Returns true if the move was successful, otherwise false.
copyClass Copies a class within the same level
linearize creates a model with symbolic linearization matrixes
optimize optimize 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);
getSourceFile Returns the filename of the class.
setSourceFile
isShortDefinition returns true if the definition is a short class definition
setClassComment Sets the class comment.
getClassNames Returns the list of class names defined in the class.
getUsedClassNames Returns the list of class names used in the total program defined by the class.
getPackages Returns the list of packages defined in the class.
basePlotFunction Extending 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.
plot Launches a plot window using OMPlot.
plotAll Works 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");
plotParametric Launches a plotParametric window using OMPlot. Returns true on success. Example command sequences: simulate(A);plotParametric(x,y); simulate(A);plotParametric(x,y, externalWindow=true);
readSimulationResult Reads a result file, returning a matrix corresponding to the variables and size given.
readSimulationResultSize The number of intervals that are present in the output file.
readSimulationResultVars Returns the variables in the simulation file; you can use val() and plot() commands using these names.
filterSimulationResults
compareSimulationResults compares simulation results.
deltaSimulationResults calculates the sum of absolute errors.
diffSimulationResults compares simulation results.
diffSimulationResultsHtml
checkTaskGraph Checks if the given taskgraph has the same structure as the reference taskgraph and if all attributes are set correctly.
checkCodeGraph Checks if the given taskgraph has the same structure as the graph described in the codefile.
val Return the value of a variable at a given time in the simulation results
closeSimulationResultFile 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.
addClassAnnotation
getParameterNames
getParameterValue
getComponentModifierNames
getComponentModifierValue
getComponentModifierValues
getInstantiatedParametersAndValues
removeComponentModifiers
removeExtendsModifiers
getConnectionCount Counts the number of connect equation in a class.
getNthConnection Returns the Nth connection. Example command: getNthConnection(A) => {"from", "to", "comment"}
getAlgorithmCount Counts the number of Algorithm sections in a class.
getNthAlgorithm Returns the Nth Algorithm section.
getInitialAlgorithmCount Counts the number of Initial Algorithm sections in a class.
getNthInitialAlgorithm Returns the Nth Initial Algorithm section.
getAlgorithmItemsCount Counts the number of Algorithm items in a class.
getNthAlgorithmItem Returns the Nth Algorithm Item.
getInitialAlgorithmItemsCount Counts the number of Initial Algorithm items in a class.
getNthInitialAlgorithmItem Returns the Nth Initial Algorithm Item.
getEquationCount Counts the number of Equation sections in a class.
getNthEquation Returns the Nth Equation section.
getInitialEquationCount Counts the number of Initial Equation sections in a class.
getNthInitialEquation Returns the Nth Initial Equation section.
getEquationItemsCount Counts the number of Equation items in a class.
getNthEquationItem Returns the Nth Equation Item.
getInitialEquationItemsCount Counts the number of Initial Equation items in a class.
getNthInitialEquationItem Returns the Nth Initial Equation Item.
getAnnotationCount Counts the number of Annotation sections in a class.
getNthAnnotationString Returns the Nth Annotation section as string.
getImportCount Counts the number of Import sections in a class.
getNthImport Returns the Nth Import as string.
iconv The iconv() function converts one multibyte characters from one character set to another. See man (3) iconv for more information.
getDocumentationAnnotation Returns the documentaiton annotation defined in the class.
setDocumentationAnnotation
getTimeStamp
stringTypeName
stringVariableName
typeNameString
typeNameStrings
getClassComment Returns the class comment.
dirname
basename
getClassRestriction
isType
isPackage
isClass
isRecord
isBlock
isFunction
isPartial
isModel
isConnector
isOptimization
isEnumeration
isOperator
isOperatorRecord
isOperatorFunction
isProtectedClass
getBuiltinType
setInitXmlStartValue
ngspicetoModelica Converts ngspice netlist to Modelica code. Modelica file is created in the same directory as netlist file.
getInheritedClasses
getComponentsTest
isExperiment
getSimulationOptions
getAnnotationNamedModifiers
getAnnotationModifierValue
classAnnotationExists Check if annotation exists
getBooleanClassAnnotation Check if annotation exists and returns its value
extendsFrom returns true if the given class extends from the given base class
loadModelica3D
searchClassNames Searches for the class name in the all the loaded classes. Example command: searchClassNames("ground"); searchClassNames("ground", true);
getAvailableLibraries
getUses
getDerivedClassModifierNames Returns the derived class modifier names. Example command: type Resistance = Real(final quantity="Resistance",final unit="Ohm"); getDerivedClassModifierNames(Resistance) => {"quantity","unit"}
getDerivedClassModifierValue Returns 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
Experimental

Generated at 2018-12-12T02:36:32Z by OpenModelicaOpenModelica 1.14.0~dev-8-g9eb6d39 using GenerateDoc.mos