1 About OMPython ................................................................................................................ 3 1.1 Features of OMPython................................................................................................... 3 2 Pre-requisites ....................................................................................................................... 4 3 Using OMPython API .......................................................................................................... 5 3.1 Test commands.............................................................................................................. 5 3.2 Import as Library ........................................................................................................... 5 3.2.1 Retrieve results from nested dictionaries................................................................. 6 3.2.2 Set values to nested dictionaries ............................................................................. 7 3.2.3 Example ................................................................................................................. 8 4 The OMPython API ............................................................................................................. 9 4.1 Implementation ............................................................................................................. 9 4.1.1 Client ..................................................................................................................... 9 4.1.2 Parser ..................................................................................................................... 9 5 Examples ........................................................................................................................... 14 5.1 Import as Library ......................................................................................................... 14 5.2 Test Commands ........................................................................................................... 16 6 List of Commands.............................................................................................................. 17 6.1 Additional resources .................................................................................................... 43
1 About OMPython
OMPython OpenModelica Python Interface is a free, open source, highly portable Python based interactive session handler for Modelica scripting. It provides the modeler with components for creating a complete Modelica modeling, compilation and simulation environment based on the latest OpenModelica library standard available. OMPython is architectured to combine both the solving strategy and model building. So domain experts (people writing the models) and computational engineers (people writing the solver code) can work on one unified tool that is industrially viable for optimization of Modelica models, while offering a flexible platform for algorithm development and research. OMPython v1.0 is not a standalone package, it depends upon the OpenModelica installation. OMPython v1.0 is implemented in Python using the OmniORB and OmniORBpy high performance CORBA ORBs for Python and it supports the Modelica Standard Library version 3.2 that is included in the latest OpenModelica (version 1.8.1) installation.
1.1 Features of OMPython
OMPython provides user friendly features like,
Interactive session handling, parsing, interpretation of commands and Modelica expressions for evaluation, simulation, plotting, etc. Interface to the latest OpenModelica API calls. Optimized parser results that give control over every element of the output. Helper functions to allow manipulation on Nested dictionaries. Easy access to the library and testing of OpenModelica commands.
2 Pre-requisites
- OpenModelica1.8.1
OMPython is bundled with OpenModelica from the nightly build revision 11480 and up.
http://www.openmodelica.org/index.php/download
- Python 2.7
http://www.python.org/download/
3 Using OMPython API
The third party library of OMPython can be created by changing directory to,
This will install the OMPython library into your Python.xy/Lib/site-packages
Now OMPython can be imported and used within Python. 3.1 Test commands
To test the command outputs, simply import the OMPython library from Python and execute the run() method of OMPython.
The module allows you to iteratively send commands to the OMC server and display their output.
For example:
C:\>python >>> import OMPython >>> OMPython.run()
>>
Full example:
C:\>python >>> import OMPython >>> OMPython.run()
>>loadModel(Modelica) True 3.2 Import as Library
To use the module from within another python program, simply import OMPython from within the using program.
Make use of the execute() function of the OMPython library to send commands to the OMC server.
For example:
answer = OMPython.execute(cmd)
Full example:
# test.py import OMPython cmds = ["loadModel(Modelica)", "model test end test;", "loadFile(\"C:/OpenModelica1.8.1/testmodels/BouncingBall.mo\")", "getIconAnnotation(Modelica.Electrical.Analog.Basic.Resistor)", "getElementsInfo(Modelica.Electrical.Analog.Basic.Resistor)", "simulate(BouncingBall)", "plot(h)"]
for cmd in cmds: answer = OMPython.execute(cmd) print "\nResult:\n%s"%answer
3.2.1 Retrieve results from nested dictionaries
Once the result is available from the OMPython.execute(), the OMPython.get() method can be used to retrieve and use specific values inside the dictionaries by simply querying the result dictionary with a string of nested dictionary names (keys).
The query should define the complete nested structure of the dictionary starting from its root.
Syntax:
OMPyt hon. get ( dict, "dotted.dict.structure")
For example:
OMPyt hon. execut e( "l oadModel ( Model i ca) ") r esul t = OMPyt hon. execut e( "get I conAnnot at i on( Model i ca. El ect r i cal . Anal og. Basi c. Resi st or ) ") inner = OMPython.get(result,'SET2.Elements.Line1.Properties')
Full example:
#test.py import OMPython
OMPython.execute("loadModel(Modelica)") result= OMPython.execute("getIconAnnotation(Modelica.Electrical.Analog.Basic.Resistor) ") inner = OMPython.get(result,'SET2.Elements.Line1.Properties') print "result of get is \n%s" %inner
3.2.2 Set values to nested dictionari es
New dictionaries can be added to the existing nested dictionary by using the, OMPyhton.set() method.
Syntax:
OMPyt hon. set ( di ct , "new. dot t ed. di ct . st r uct ur e", new_val ue)
Note: new_value can be any of the Python supported datatypes.
For example:
OMPyt hon. execut e( "l oadModel ( Model i ca) ") r esul t = OMPyt hon. execut e( "get I conAnnot at i on( Model i ca. El ect r i cal . Anal og. Basi c. Resi st or ) ") value = OMPython.set(result,"SET2.Elements.Line1.Properties.NEW", 1e-05)
The OMPython.set() method does not append dictionaries to the existing nest but creates new ones inside the existing. Design your query such that you don't overwrite the dictionaries if you dont intend to.
Full example:
#test.py import OMPython
OMPython.execute("loadModel(Modelica)") result = OMPython.execute("getIconAnnotation(Modelica.Electrical.Analog.Basic.Resistor) ") inner = OMPython.get(result,'SET2.Elements.Line1.Properties') print "result of get is \n%s" %inner value = OMPython.set(result,"SET2.Elements.Line1.Properties.NEW", [1,2,3]) print "Result:: \n%s" % OMPython.get(value,'SET2.Elements.Line1.Properties.NEW')
3.2.3 Example
4 The OMPython API 4.1 Implementation 4.1.1 Client
The OpenModelica-Python API Interface OMPython, attempts to mimic the OmShell's style of operations.
OMPython is designed to,
o Initialize the CORBA communication o Send commands to the Omc server via the CORBA interface o Receive the string results. o Use the Parser module to format the results o Return or display the results. 4.1.2 Parser
Since the results of OMC are retrieved in a String format over CORBA, some housekeeping has to be done to make sure the results are usable in Python easily.
The Parser is designed to do the following,
o Analyze the result string for categorical data. o Group each category under a category name o Type cast the data within these categories o Build a suitable data structure to hold these data so that the results can be easily accessed and used.
4.1.2.1 Understanding the Parsed output
Each command in OpenModelica produces a result that can be categorized according to the statistics of the pattern of data presented in the text. Grammar based parsers were found to be tedious to use because of the complexity of the patterns of data.
The parser just type casts the data without "curly brackets" to the appropriate data type and displays it as the result. For example: >>get Vect or i zat i onLi mi t ( ) 20
>>get Nt hI nher i t edCl ass( Model i ca. El ect r i cal . Anal og. Basi c. Resi st or , 1) Model i ca. El ect r i cal . Anal og. I nt er f aces. OnePor t
However, multiple data types packed within a pair of quotations is always treated as a full string.
For example:
>>get Model i caPat h( ) "C: / OpenModel i ca1. 8. 0/ l i b/ oml i br ar y"
4.1.2.1.1 The Dictionary data type in Python:
Dictionaries are found to be a useful datatype to pack data with different datatypes. Dictionaries in Python are indexed by Keys unlike the sequences, which are indexed by a range of numbers.
It is best to think of dictionaries as an unordered set of key:value pairs, with the requirement that the keys are always unique. The common operation on dictionaries is to store a value associated with a key and retrieve the value using the key. This provides us the flexibility of creating keys at runtime and accessing these values using their keys later. All data within the dictionary are stored inside a named dictionary. An empty dictionary is represented by a pair of braces {}.
From the reply of the OMC, the complicated result strings are usually the ones found within the curly braces, in order to make a meaningful categorization of the data within these brackets and to avoid the potential complexities due to creating Dynamic variables, we introduce the following notations that can be used within dictionaries,
SET Set Subset Element Results Values
4.1.2.1.2 SET
A SET (note the capital letters) is used to group data that belong to the first set of balanced curly brackets. According to the needed semantics of the results, a SET can contain Sets, Subsets, Elements, Values and Results. A SET can also be empty, denoted by {}. The SETs are named with an increasing index starting from 1(one). This feature was planned to eliminate the need for dynamic variable creation and having duplicate Keys. The SET belongs within the dictionary, result.
For example:
>>st r t ok( "abcbdef ", "b") {' SET1' : {' Val ues' : [ ' "a", "c", "def "' ] }}
The command st r t ok t okeni zes t he st r i ng "abcbdef " at ever y occur r ence of b and pr oduces a SET wi t h val ues "a", "c", "def ".
4.1.2.1.3 Set
A set is used to group all data within the a SET that is enclosed within a pair of balanced {}s. A Set can contain only Values and Elements. A set can also be empty, it can be depicted as {{}}, the outer brackets compose a SET, the inner brackets are the Set within the SET.
4.1.2.1.4 Subset
A Subset is a two-level deep set that is found within a SET. A subset can contain multiple Sets within its enclosure.
For example:
{SET1 {Subset1{Set1},{Set2},{Set3}}}
4.1.2.1.5 Element
Elements are the data which are grouped within a pair of Parenthesis ( ). As observed from the results string, elements have an element name that describes the data within them, so elements can be grouped by their names. Also, many elements have the same names, so they are indexed by increasing numbers starting from 1(one). Elements have the special property of having one or more Sets and Subsets within them. However, they are in turn enclosed within the SET.
The result contains, a SET with a Element named rec1 which has Properties which are Results (see below) of the element.
4.1.2.1.6 Results
Data that is related by the assignment operator "=", within the SETs are denoted as Results. These assignments cannot be assigned to their actual values unless they are related by a Name = Value relationship. So, they form the sub-dictionary called Results within the Element (for example). Then these values can be related by the key:value pair relationship.
Data within any or all of SETs, Sets, Elements and Subsets that are not assignments and separated by commas are grouped together into a list called "Values". The Values list may also be empty, due to Python's representation of a null string "" as {}. Although a Null string is still a Null value, sometimes it is possible to observe data grouped into Values to look like Sets within the Values list.
The simulate() command produces output that has no SET or Set data in it. Instead, for simplicity, it has two dictionaries namely, SimulationResults and SimulationOptions within the result dictionary.
For example:
OMPython.execute("simulate(BouncingBall)")
4.1.2.1.9 Record Constructs
The OpenModelica commands that produce output with Record constructs also do not have SET or Set data within them. The results of the output are packed within the RecordResults dictionary.
For example:
OMPython.execute("checkSettings()")
5 Examples
5.1 Import as Library
5.2 Test Commands
6 List of Commands
The following table contains brief descriptions about the commands that are available in the OpenModelica environment.
Name Description simulate Simulate model, optionally setting simulation values. Inputs: TypeName cl assName; Real st ar t Ti me; Real st opTi me; I nt eger number Of I nt er val s; Real out put I nt er val ; St r i ng met hod; Real t ol er ance; Real f i xedSt epSi ze; Outputs: Si mul at i onResul t si mRes; appendEnvir onmentVar Interface f unct i on appendEnvi r onment Var i nput St r i ng var ; i nput St r i ng val ue; out put St r i ng r esul t "r et ur ns \ "er r or \ " i f t he var i abl e coul d not be appended"; end appendEnvi r onment Var ;
basename Returns the base name (file part) of a file path. Similar to basename(3), but with the safety of Modelica strings. Interface f unct i on basename i nput St r i ng pat h; out put St r i ng basename; end basename;
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 Interface f unct i on cd i nput St r i ng newWor ki ngDi r ect or y = ""; out put St r i ng wor ki ngDi r ect or y; end cd;
checkAllMod elsRecursiv e Interface f unct i on checkAl l Model sRecur si ve i nput TypeName cl assName; i nput Bool ean checkPr ot ect ed = f al se "Checks al so pr ot ect ed cl asses i f t r ue"; out put St r i ng r esul t ; end checkAl l Model sRecur si ve;
checkModel Instantiate model, optimize equations, and report errors. Interface f unct i on checkModel i nput TypeName cl assName; out put St r i ng r esul t ; end checkModel ;
checkSettin gs Display some diagnostics Interface f unct i on checkSet t i ngs out put CheckSet t i ngsResul t r esul t ; end checkSet t i ngs;
clear Clears everything: symboltable and variables. Interface f unct i on cl ear out put Bool ean success; end cl ear ;
clearMessag es Clears the error buffer Interface f unct i on cl ear Messages out put Bool ean success; end cl ear Messages;
clearVariab les Clear all user defined variables. Interface f unct i on cl ear Var i abl es out put Bool ean success; end cl ear Var i abl es;
closeSimula tionResultF ile 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 Interface f unct i on cl oseSi mul at i onResul t Fi l e out put Bool ean success; end cl oseSi mul at i onResul t Fi l e
codeToStrin g Interface f unct i on codeToSt r i ng i nput Code cl assName; out put St r i ng st r i ng; end codeToSt r i ng;
compareSimu lationResul ts Compare simulation results Interface f unct i on compar eSi mul at i onResul t s i nput St r i ng f i l ename; i nput St r i ng r ef f i l ename; i nput St r i ng l ogf i l ename; i nput Real r ef Tol ; i nput Real absTol ; i nput St r i ng[ : ] var s; out put St r i ng r esul t ; end compar eSi mul at i onResul t s;
deleteFile Deletes a file with the given name Interface f unct i on del et eFi l e i nput St r i ng f i l eName; out put Bool ean success; end del et eFi l e;
dirname Returns the directory name of a file path. Similar to dirname(3), but with the safety of Modelica strings. Interface f unct i on di r name i nput St r i ng pat h; out put St r i ng di r name; end di r name;
dumpXMLDAE Interface f unct i on dumpXMLDAE i nput TypeName cl assName; i nput St r i ng t r ansl at i onLevel = "f l at "; i nput Bool ean addOr i gi nal I nci denceMat r i x = f al se; i nput Bool ean addSol vi ngI nf o = f al se; i nput Bool ean addMat hMLCode = f al se; i nput Bool ean dumpResi dual s = f al se; i nput St r i ng f i l eNamePr ef i x = "<def aul t >" "t hi s i s t he cl assName i n st r i ng f or mby def aul t "; i nput Bool ean st or eI nTemp = f al se; out put St r i ng r esul t [ 2] "Cont ent s, Message/ Fi l ename; why i s t hi s an ar r ay and not 2 out put ar gument s?"; end dumpXMLDAE;
Echo echo(false) disables Interactive output, echo(true) enables it again. Interface f unct i on echo i nput Bool ean set Echo; out put Bool ean newEcho; end echo;
generateCod e The input is a function name for which C-code is generated and compiled into a dll/so Interface f unct i on gener at eCode i nput TypeName cl assName; out put Bool ean success; end gener at eCode;
generateHea der Interface f unct i on gener at eHeader i nput St r i ng f i l eName; out put Bool ean success; end gener at eHeader ;
generateSep arateCode Interface f unct i on gener at eSepar at eCode out put Bool ean success; end gener at eSepar at eCode;
getAlgorith mCount Counts the number of Algorithmsections in a class Interface f unct i on get Al gor i t hmCount i nput TypeName cl ass_; out put I nt eger count ; end get Al gor i t hmCount ;
getAlgorith mItemsCount Counts the number of Algorithmitems in a class Interface f unct i on get Al gor i t hmI t emsCount i nput TypeName cl ass_; out put I nt eger count ; end get Al gor i t hmI t emsCount ;
getAnnotati onCount Counts the number of Annotation sections in a class Interface f unct i on get Annot at i onCount i nput TypeName cl ass_; out put I nt eger count ; end get Annot at i onCount ;
getAnnotati onVersion Interface f unct i on get Annot at i onVer si on out put St r i ng annot at i onVer si on; end get Annot at i onVer si on;
getAstAsCor baString Print the whole AST on the CORBA format for records, e.g. record Absyn.PROGRAM classes =..., within_ =..., globalBuildTimes =... end Absyn.PROGRAM; Interface f unct i on get Ast AsCor baSt r i ng i nput St r i ng f i l eName = "<i nt er act i ve>"; out put St r i ng r esul t "r et ur ns t he st r i ng i f f i l eName i s i nt er act i ve; el se i t r et ur ns ok or er r or dependi ng on i f wr i t i ng t he f i l e succeeded"; end get Ast AsCor baSt r i ng;
getClassCom ment Interface f unct i on get Cl assComment i nput TypeName cl ; out put St r i ng comment ; end get Cl assComment ;
getClassNam es Interface f unct i on get Cl assNames i nput TypeName cl ass_ = Code( Al l LoadedCl asses) ; i nput Bool ean r ecur si ve = f al se; i nput Bool ean qual i f i ed = f al se; i nput Bool ean sor t = f al se; i nput Bool ean bui l t i n = f al se "Li st al so bui l t i n cl asses i f t r ue"; i nput Bool ean showPr ot ect ed = f al se "Li st al so pr ot ect ed cl asses i f t r ue"; out put TypeName cl assNames[ : ] ; end get Cl assNames;
getClassesI nModelicaPa th Interface f unct i on get Cl assesI nModel i caPat h out put St r i ng cl assesI nModel i caPat h; end get Cl assesI nModel i caPat h;
getCompileC ommand Interface f unct i on get Compi l eCommand out put St r i ng compi l eCommand; end get Compi l eCommand;
getDocument ationAnnota tion Interface f unct i on get Document at i onAnnot at i on i nput TypeName cl ; out put St r i ng out [ 2] "{i nf o, r evi si on}"; end get Document at i onAnnot at i on;
getEnvironm entVar Interface f unct i on get Envi r onment Var i nput St r i ng var ; out put St r i ng val ue "r et ur ns empt y st r i ng on f ai l ur e"; end get Envi r onment Var ;
getEquation Count Counts the number of Equation sections in a class Interface f unct i on get Equat i onCount i nput TypeName cl ass_; out put I nt eger count ; end get Equat i onCount ;
getEquation ItemsCount Counts the number of Equation items in a class Interface f unct i on get Equat i onI t emsCount i nput TypeName cl ass_; out put I nt eger count ; end get Equat i onI t emsCount ; ounts the number of Equation items in a class getErrorStr ing [file.mo:n:n-n:n:b] Error: message Interface f unct i on get Er r or St r i ng out put St r i ng er r or St r i ng; end get Er r or St r i ng;
getImportCo unt Counts the number of Import sections in a class Interface f unct i on get I mpor t Count i nput TypeName cl ass_; out put I nt eger count ; end get I mpor t Count ;
getInitialA lgorithmCou nt Counts the number of Initial Algorithmsections in a class Interface f unct i on get I ni t i al Al gor i t hmCount i nput TypeName cl ass_; out put I nt eger count ; end get I ni t i al Al gor i t hmCount ;
getInitialA lgorithmIte msCount Counts the number of Initial Algorithmitems in a class Interface f unct i on get I ni t i al Al gor i t hmI t emsCount i nput TypeName cl ass_; out put I nt eger count ; end get I ni t i al Al gor i t hmI t emsCount ;
getInitialE quationCoun t Counts the number of Initial Equation sections in a class Interface f unct i on get I ni t i al Equat i onCount i nput TypeName cl ass_; out put I nt eger count ; end get I ni t i al Equat i onCount ;
getInitialE quationItem sCount Counts the number of Initial Equation items in a class Interface f unct i on get I ni t i al Equat i onI t emsCount i nput TypeName cl ass_; out put I nt eger count ; end get I ni t i al Equat i onI t emsCount ;
getInstalla tionDirecto ryPath This returns OPENMODELICAHOME if it is set; on some platforms the default path is returned if it is not set. Interface f unct i on get I nst al l at i onDi r ect or yPat h out put St r i ng i nst al l at i onDi r ect or yPat h; end get I nst al l at i onDi r ect or yPat h;
getLanguage Standard Interface f unct i on get LanguageSt andar d out put St r i ng out Ver si on; end get LanguageSt andar d;
getMessages String see getErrorString() Interface f unct i on get MessagesSt r i ng out put St r i ng messagesSt r i ng; end get MessagesSt r i ng;
getMessages StringInter {{[file.mo:n:n-n:n:b] Error: message, TRANSLATION, Error, code}} nal Interface f unct i on get MessagesSt r i ngI nt er nal out put Er r or Message[ : ] messagesSt r i ng; end get MessagesSt r i ngI nt er nal ;
getModelica Path See loadModel() for a description of what the MODELICAPATH is used for. Interface f unct i on get Model i caPat h out put St r i ng model i caPat h; end get Model i caPat h;
getNoSimpli fy Interface f unct i on get NoSi mpl i f y out put Bool ean noSi mpl i f y; end get NoSi mpl i f y;
getNthAlgor ithm Returns the Nth Algorithmsection Interface f unct i on get Nt hAl gor i t hm i nput TypeName cl ass_; i nput I nt eger i ndex; out put St r i ng r esul t ; end get Nt hAl gor i t hm;
getNthAlgor ithmItem Returns the Nth AlgorithmItem Interface f unct i on get Nt hAl gor i t hmI t em i nput TypeName cl ass_; i nput I nt eger i ndex; out put St r i ng r esul t ; end get Nt hAl gor i t hmI t em;
getNthAnnot ationString Returns the Nth Annotation section as string Interface f unct i on get Nt hAnnot at i onSt r i ng i nput TypeName cl ass_; i nput I nt eger i ndex; out put St r i ng r esul t ; end get Nt hAnnot at i onSt r i ng;
getNthEquat ion Returns the Nth Equation section Interface f unct i on get Nt hEquat i on i nput TypeName cl ass_; i nput I nt eger i ndex; out put St r i ng r esul t ; end get Nt hEquat i on;
getNthEquat ionItem Returns the Nth Equation Item Interface f unct i on get Nt hEquat i onI t em i nput TypeName cl ass_; i nput I nt eger i ndex; out put St r i ng r esul t ; end get Nt hEquat i onI t em;
getNthImpor t Returns the Nth Import as string Interface f unct i on get Nt hI mpor t i nput TypeName cl ass_; i nput I nt eger i ndex; out put St r i ng out [ 3] "{\ "Pat h\ ", \ "I d\ ", \ "Ki nd\ "}"; end get Nt hI mpor t ;
getNthIniti alAlgorithm Returns the Nth Initial Algorithmsection Interface f unct i on get Nt hI ni t i al Al gor i t hm i nput TypeName cl ass_; i nput I nt eger i ndex; out put St r i ng r esul t ; end get Nt hI ni t i al Al gor i t hm;
getNthIniti alAlgorithm Item Returns the Nth Initial AlgorithmItem Interface f unct i on get Nt hI ni t i al Al gor i t hmI t em i nput TypeName cl ass_; i nput I nt eger i ndex; out put St r i ng r esul t ; end get Nt hI ni t i al Al gor i t hmI t em;
getNthIniti alEquation Returns the Nth Initial Equation section Interface f unct i on get Nt hI ni t i al Equat i on i nput TypeName cl ass_; i nput I nt eger i ndex; out put St r i ng r esul t ; end get Nt hI ni t i al Equat i on;
getNthIniti alEquationI tem Returns the Nth Initial Equation Item Interface f unct i on get Nt hI ni t i al Equat i onI t em i nput TypeName cl ass_; i nput I nt eger i ndex; out put St r i ng r esul t ; end get Nt hI ni t i al Equat i onI t em; ns the Nth Initial Equation Item getOrderCon nections Interface f unct i on get Or der Connect i ons out put Bool ean or der Connect i ons; end get Or der Connect i ons;
getPackages Interface f unct i on get Packages i nput TypeName cl ass_ = Code( Al l LoadedCl asses) ; out put TypeName cl assNames[ : ] ; end get Packages;
getPlotSile nt Interface f unct i on get Pl ot Si l ent out put Bool ean pl ot Si l ent ; end get Pl ot Si l ent ;
getSettings Interface f unct i on get Set t i ngs out put St r i ng set t i ngs; end get Set t i ngs;
getShowAnno tations Interface f unct i on get ShowAnnot at i ons out put Bool ean show; end get ShowAnnot at i ons;
getSourceFi le Interface f unct i on get Sour ceFi l e i nput TypeName cl ass_; out put St r i ng f i l ename "empt y on f ai l ur e"; end get Sour ceFi l e;
getTempDire ctoryPath Interface f unct i on get TempDi r ect or yPat h out put St r i ng t empDi r ect or yPat h; end get TempDi r ect or yPat h;
getVectoriz ationLimit Interface f unct i on get Vect or i zat i onLi mi t out put I nt eger vect or i zat i onLi mi t ; end get Vect or i zat i onLi mi t ;
getVersion Returns the version of the Modelica compiler Interface f unct i on get Ver si on i nput TypeName cl = Code( OpenModel i ca) ; out put St r i ng ver si on; end get Ver si on;
help Display the OpenModelica help text Interface f unct i on hel p out put St r i ng hel pText ; end hel p;
iconv The iconv() function converts one multibyte characters fromone character set to another. See man (3) iconv for more information. Interface f unct i on i conv i nput St r i ng st r i ng; i nput St r i ng f r om; i nput St r i ng t o = "UTF- 8"; out put St r i ng r esul t ; end i conv;
importFMU Imports the Functional Mockup Unit Example command: importFMU("A.fmu"); Interface f unct i on i mpor t FMU i nput St r i ng f i l ename "t he f mu f i l e name"; i nput St r i ng wor kdi r = ". / " "The out put di r ect or y f or i mpor t ed FMU f i l es. <def aul t > wi l l put t he f i l es t o cur r ent wor ki ng di r ect or y. "; out put Bool ean success "Ret ur ns t r ue on success"; end i mpor t FMU;
instantiate Model Instantiate model, resulting in a .mof file of flattened Modelica. Interface f unct i on i nst ant i at eModel i nput TypeName cl assName; out put St r i ng r esul t ; end i nst ant i at eModel ;
isModel Returns true if the given class has restriction model. Interface f unct i on i sModel i nput TypeName cl ; out put Bool ean b; end i sModel ;
isPackage Returns true if the given class is a package. Interface f unct i on i sPackage i nput TypeName cl ; out put Bool ean b; end i sPackage;
isPartial Returns true if the given class is partial. Interface f unct i on i sPar t i al i nput TypeName cl ; out put Bool ean b; end i sPar t i al ;
list Pretty-prints a class definition. Syntax list( Model i ca. Mat h. si n) list( Model i ca. Mat h. si n, i nt er f aceOnl y=t r ue) Interface f unct i on l i st i nput TypeName cl ass_ = Code( Al l LoadedCl asses) ; i nput Bool ean i nt er f aceOnl y = f al se; i nput Bool ean shor t Onl y = f al se "onl y shor t cl ass def i ni t i ons"; out put St r i ng cont ent s; end l i st ;
listVariabl es Lists the names of the active variables in the scripting environment. Interface f unct i on l i st Var i abl es out put TypeName var i abl es[ : ] ; end l i st Var i abl es;
loadFile load file (*.mo) and merge it with the loaded AST Interface f unct i on l oadFi l e i nput St r i ng f i l eName; out put Bool ean success; end l oadFi l e;
loadFileInt eractive Interface f unct i on l oadFi l eI nt er act i ve i nput St r i ng f i l ename; out put TypeName names[ : ] ; end l oadFi l eI nt er act i ve;
loadFileInt eractiveQua lified Interface f unct i on l oadFi l eI nt er act i veQual i f i ed i nput St r i ng f i l ename; out put TypeName names[ : ] ; end l oadFi l eI nt er act i veQual i f i ed;
loadModel Loads a Modelica library. Syntax loadModel( Model i ca) loadModel( Model i ca, {"3. 2"}) Interface f unct i on l oadModel i nput TypeName cl assName; i nput St r i ng[ : ] pr i or i t yVer si on = {"def aul t "}; out put Bool ean success; end l oadModel ;
loadString Parses the data and merges the resulting AST with the loaded AST. If a filename is given, it is used to provide error-messages as if the string was read in binary format froma file with the same name. The file is converted to UTF-8 fromthe given character set.
Interface f unct i on l oadSt r i ng i nput St r i ng dat a; i nput St r i ng f i l ename = "<i nt er act i ve>"; i nput St r i ng encodi ng = "UTF- 8"; out put Bool ean success; end l oadSt r i ng;
parseFile Interface f unct i on par seFi l e i nput St r i ng f i l ename; out put TypeName names[ : ] ; end par seFi l e;
parseString Interface f unct i on par seSt r i ng i nput St r i ng dat a; i nput St r i ng f i l ename = "<i nt er act i ve>"; out put TypeName names[ : ] ; end par seSt r i ng;
plot Launches a plot window using OMPlot. Returns true on success. Don't require sendData support.
Example command sequences: simulate(A);plot({x,y,z}); simulate(A);plot(x, externalWindow=true); simulate(A,fileNamePrefix="B");simulate(C);plot(z,"B.mat",legend=false);
Interface f unct i on pl ot i nput Var i abl eNames var s "The var i abl es you want t o pl ot "; i nput Bool ean ext er nal Wi ndow = f al se "Opens t he pl ot i n a new pl ot wi ndow"; i nput St r i ng f i l eName = "<def aul t >" "The f i l ename cont ai ni ng t he var i abl es. <def aul t > wi l l r ead t he l ast si mul at i on r esul t "; i nput St r i ng t i t l e = "Pl ot by OpenModel i ca" "Thi s t ext wi l l be used as t he di agr amt i t l e. "; i nput Bool ean l egend = t r ue "Det er mi nes whet her or not t he var i abl e l egend i s shown. "; i nput Bool ean gr i d = t r ue "Det er mi nes whet her or not a gr i d i s shown i n t he di agr am. "; i nput Bool ean l ogX = f al se "Det er mi nes whet her or not t he hor i zont al axi s i s l ogar i t hmi cal l y scal ed. "; i nput Bool ean l ogY = f al se "Det er mi nes whet her or not t he ver t i cal axi s i s l ogar i t hmi cal l y scal ed. "; i nput St r i ng xLabel = "t i me" "Thi s t ext wi l l be used as t he hor i zont al l abel i n t he di agr am. "; i nput St r i ng yLabel = "" "Thi s t ext wi l l be used as t he ver t i cal l abel i n t he di agr am. "; i nput Real xRange[ 2] = {0. 0, 0. 0} "Det er mi nes t he hor i zont al i nt er val t hat i s vi si bl e i n t he di agr am. {0, 0} wi l l sel ect a sui t abl e r ange. "; i nput Real yRange[ 2] = {0. 0, 0. 0} "Det er mi nes t he ver t i cal i nt er val t hat i s vi si bl e i n t he di agr am. {0, 0} wi l l sel ect a sui t abl e r ange. "; out put Bool ean success "Ret ur ns t r ue on success"; out put St r i ng[ : ] r esul t "Ret ur ns l i st i . e {\ "_omc_Pl ot Resul t \ ", \ "<f i l eName>\ ", \ "<t i t l e>\ ", \ "<l egend>\ ", \ "<g r i d>\ ", \ "<Pl ot Type>\ ", \ "<l ogX>\ ", \ "<l ogY>\ ", \ "<xLabel >\ ", \ "<yLabe l >\ ", \ "<xRange>\ ", \ "<yRange>\ ", \ "<Pl ot Var i abl es>\ "}"; end pl ot ;
plot2 Uses the J ava-based plot window (ptplot.jar) to launch a plot, similar to the plot() command. This command accepts fewer options, but works even when OpenModelica was not compiled with sendData support.
Example command sequences: simulate(A);plot2({x,y}); simulate(A,fileNamePrefix="B");simulate(C);plot2(x,"B.mat");
Interface f unct i on pl ot 2 i nput Var i abl eNames var s; i nput St r i ng f i l eName = "<def aul t >"; out put Bool ean success "Ret ur ns t r ue on success"; end pl ot 2;
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,"B.mat"); Interface f unct i on pl ot Al l i nput Bool ean ext er nal Wi ndow = f al se "Opens t he pl ot i n a new pl ot wi ndow"; i nput St r i ng f i l eName = "<def aul t >" "The f i l ename cont ai ni ng t he var i abl es. <def aul t > wi l l r ead t he l ast si mul at i on r esul t "; i nput St r i ng t i t l e = "Pl ot by OpenModel i ca" "Thi s t ext wi l l be used as t he di agr amt i t l e. "; i nput Bool ean l egend = t r ue "Det er mi nes whet her or not t he var i abl e l egend i s shown. "; i nput Bool ean gr i d = t r ue "Det er mi nes whet her or not a gr i d i s shown i n t he di agr am. "; i nput Bool ean l ogX = f al se "Det er mi nes whet her or not t he hor i zont al axi s i s l ogar i t hmi cal l y scal ed. "; i nput Bool ean l ogY = f al se "Det er mi nes whet her or not t he ver t i cal axi s i s l ogar i t hmi cal l y scal ed. "; i nput St r i ng xLabel = "t i me" "Thi s t ext wi l l be used as t he hor i zont al l abel i n t he di agr am. "; i nput St r i ng yLabel = "" "Thi s t ext wi l l be used as t he ver t i cal l abel i n t he di agr am. "; i nput Real xRange[ 2] = {0. 0, 0. 0} "Det er mi nes t he hor i zont al i nt er val t hat i s vi si bl e i n t he di agr am. {0, 0} wi l l sel ect a sui t abl e r ange. "; i nput Real yRange[ 2] = {0. 0, 0. 0} "Det er mi nes t he ver t i cal i nt er val t hat i s vi si bl e i n t he di agr am. {0, 0} wi l l sel ect a sui t abl e r ange. "; out put Bool ean success "Ret ur ns t r ue on success"; out put St r i ng[ : ] r esul t "Ret ur ns l i st i . e {\ "_omc_Pl ot Resul t \ ", \ "<f i l eName>\ ", \ "<t i t l e>\ ", \ "<l egend>\ ", \ "<g r i d>\ ", \ "<Pl ot Type>\ ", \ "<l ogX>\ ", \ "<l ogY>\ ", \ "<xLabel >\ ", \ "<yLabe l >\ ", \ "<xRange>\ ", \ "<yRange>\ ", \ "<Pl ot Var i abl es>\ "}"; end pl ot Al l ;
plotParamet ric Launches a plotParametric window using OMPlot. Returns true on success. Don't require sendData support.
Example command sequences: simulate(A);plotParametric2(x,y); simulate(A);plotParametric2(x,y, externalWindow=true);
Interface f unct i on pl ot Par amet r i c i nput Var i abl eName xVar i abl e; i nput Var i abl eName yVar i abl e; i nput Bool ean ext er nal Wi ndow = f al se "Opens t he pl ot i n a new pl ot wi ndow"; i nput St r i ng f i l eName = "<def aul t >" "The f i l ename cont ai ni ng t he var i abl es. <def aul t > wi l l r ead t he l ast si mul at i on r esul t "; i nput St r i ng t i t l e = "Pl ot by OpenModel i ca" "Thi s t ext wi l l be used as t he di agr amt i t l e. "; i nput Bool ean l egend = t r ue "Det er mi nes whet her or not t he var i abl e l egend i s shown. "; i nput Bool ean gr i d = t r ue "Det er mi nes whet her or not a gr i d i s shown i n t he di agr am. "; i nput Bool ean l ogX = f al se "Det er mi nes whet her or not t he hor i zont al axi s i s l ogar i t hmi cal l y scal ed. "; i nput Bool ean l ogY = f al se "Det er mi nes whet her or not t he ver t i cal axi s i s l ogar i t hmi cal l y scal ed. "; i nput St r i ng xLabel = "t i me" "Thi s t ext wi l l be used as t he hor i zont al l abel i n t he di agr am. "; i nput St r i ng yLabel = "" "Thi s t ext wi l l be used as t he ver t i cal l abel i n t he di agr am. "; i nput Real xRange[ 2] = {0. 0, 0. 0} "Det er mi nes t he hor i zont al i nt er val t hat i s vi si bl e i n t he di agr am. {0, 0} wi l l sel ect a sui t abl e r ange. "; i nput Real yRange[ 2] = {0. 0, 0. 0} "Det er mi nes t he ver t i cal i nt er val t hat i s vi si bl e i n t he di agr am. {0, 0} wi l l sel ect a sui t abl e r ange. "; out put Bool ean success "Ret ur ns t r ue on success"; out put St r i ng[ : ] r esul t "Ret ur ns l i st i . e {\ "_omc_Pl ot Resul t \ ", \ "<f i l eName>\ ", \ "<t i t l e>\ ", \ "<l egend>\ ", \ "<g r i d>\ ", \ "<Pl ot Type>\ ", \ "<l ogX>\ ", \ "<l ogY>\ ", \ "<xLabel >\ ", \ "<yLabe l >\ ", \ "<xRange>\ ", \ "<yRange>\ ", \ "<Pl ot Var i abl es>\ "}"; end pl ot Par amet r i c;
plotParamet ric2 Plots the y-variables as a function of the x-variable.
Example command sequences: simulate(A);plotParametric2(x,y); simulate(A,fileNamePrefix="B");simulate(C);plotParametric2(x,{y1,y2,y3},"B.mat");
Interface f unct i on pl ot Par amet r i c2 i nput Var i abl eName xVar i abl e; i nput Var i abl eNames yVar i abl es; i nput St r i ng f i l eName = "<def aul t >"; out put Bool ean success "Ret ur ns t r ue on success"; end pl ot Par amet r i c2;
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. Interface f unct i on r eadFi l e i nput St r i ng f i l eName; out put St r i ng cont ent s; end r eadFi l e;
readFileNoN umeric Returns the contents of the file, with anything resembling a (real) number stripped out, and at the end adding: Filter count fromnumber domain: n. This should probably be changed to multiple outputs; the filtered string and an integer. Does anyone use this API call? Interface f unct i on r eadFi l eNoNumer i c i nput St r i ng f i l eName; out put St r i ng cont ent s; end r eadFi l eNoNumer i c;
readFilePos tprocessLin eDirective Searches lines for the #modelicaLine directive. If it is found, all lines up until the next #modelicaLine or #endModelicaLine are put on a single file, following a #line linenumber "filename" line. This causes GCC to output an executable that we can set breakpoints in and debug. Note: You could use a stack to keep track of start/end of #modelicaLine and match themup. But this is not really desirable since that will cause extra breakpoints for the same line (you would get breakpoints before and after each case if you break on a match-expression, etc).
Interface f unct i on r eadFi l ePost pr ocessLi neDi r ect i ve i nput St r i ng f i l eName; out put St r i ng out ; end r eadFi l ePost pr ocessLi neDi r ect i ve;
readFileSho wLineNumber s Prefixes each line in the file with <n>:, where n is the line number. Note: Scales O(n^2) Interface f unct i on r eadFi l eShowLi neNumber s i nput St r i ng f i l eName; out put St r i ng out ; end r eadFi l eShowLi neNumber s;
readSimulat ionResult Reads a result file, returning a matrix corresponding to the variables and size given. Interface f unct i on r eadSi mul at i onResul t i nput St r i ng f i l ename; i nput Var i abl eNames var i abl es; i nput I nt eger si ze = 0 "0=r ead any si ze. . . I f t he si ze i s not t he same as t he r esul t - f i l e, t hi s f unct i on f ai l s"; out put Real r esul t [ : , : ] ; end r eadSi mul at i onResul t ;
readSimulat ionResultSi ze The number of intervals that are present in the output file Interface f unct i on r eadSi mul at i onResul t Si ze i nput St r i ng f i l eName; out put I nt eger sz; end r eadSi mul at i onResul t Si ze;
readSimulat ionResultVa rs Returns the variables in the simulation file; you can use val() and plot() commands using these names Interface f unct i on r eadSi mul at i onResul t Var s i nput St r i ng f i l eName; out put St r i ng[ : ] var s; end r eadSi mul at i onResul t Var s;
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) =>{" ipsumdolor ","ipsum","dolor"} This means if you have n groups, you want maxMatches=n+1 Interface f unct i on r egex i nput St r i ng st r ; i nput St r i ng r e; i nput I nt eger maxMat ches = 1 "The maxi mum number of mat ches t hat wi l l be r et ur ned"; i nput Bool ean ext ended = t r ue "Use POSI X ext ended or r egul ar synt ax"; i nput Bool ean caseI nsensi t i ve = f al se; out put I nt eger numMat ches "- 1 i s an er r or , 0 means no mat ch, el se r et ur ns a number 1. . maxMat ches"; out put St r i ng mat chedSubst r i ngs[ maxMat ches] "unmat ched st r i ngs ar e r et ur ned as empt y"; end r egex;
regexBool Returns true if the string matches the regular expression regularFile Exists 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. Interface f unct i on r egul ar Fi l eExi st s i nput St r i ng f i l eName; out put Bool ean exi st s; end r egul ar Fi l eExi st s;
reopenStand ardStream Interface f unct i on r eopenSt andar dSt r eam i nput St andar dSt r eam_st r eam; i nput St r i ng f i l ename; out put Bool ean success; end r eopenSt andar dSt r eam;
runScript Runs the mos-script specified by the filename. Interface f unct i on r unScr i pt i nput St r i ng f i l eName "*. mos"; out put St r i ng r esul t ; end r unScr i pt ;
Save Interface f unct i on save i nput TypeName cl assName; out put Bool ean success; end save;
saveAll Save the entire loaded AST to file Interface f unct i on saveAl l i nput St r i ng f i l eName; out put Bool ean success; end saveAl l ;
saveModel Save class definition in a file. Interface f unct i on saveModel i nput St r i ng f i l eName; i nput TypeName cl assName; out put Bool ean success; end saveModel ;
saveTotalMo del Save total class definition into file of a class. Inputs: St r i ng f i l eName; TypeName cl assName Outputs: Bool ean r es; Interface f unct i on saveTot al Model i nput St r i ng f i l eName; i nput TypeName cl assName; out put Bool ean success; end saveTot al Model ;
saveTotalSC ode Interface f unct i on saveTot al SCode i nput St r i ng f i l eName; i nput TypeName cl assName; out put Bool ean success; end saveTot al SCode;
setAnnotati onVersion Interface f unct i on set Annot at i onVer si on i nput St r i ng annot at i onVer si on; out put Bool ean success; end set Annot at i onVer si on;
setCXXCompi ler Interface f unct i on set CXXCompi l er i nput St r i ng compi l er ; out put Bool ean success; end set CXXCompi l er ;
setClassCom ment Interface f unct i on set Cl assComment i nput TypeName cl ass_; i nput St r i ng f i l ename; out put Bool ean success; end set Cl assComment ;
setCommandL ineOptions The input is a regular command-line flag given to OMC, e.g. +d=failtrace or +g=MetaModelica Interface f unct i on set CommandLi neOpt i ons i nput St r i ng opt i on; out put Bool ean success; end set CommandLi neOpt i ons;
setCompileC ommand Interface f unct i on set Compi l eCommand i nput St r i ng compi l eCommand; out put Bool ean success; end set Compi l eCommand;
setCompiler Interface f unct i on set Compi l er i nput St r i ng compi l er ; out put Bool ean success; end set Compi l er ;
setCompiler Flags Interface f unct i on set Compi l er Fl ags i nput St r i ng compi l er Fl ags; out put Bool ean success; end set Compi l er Fl ags;
setCompiler Path Interface f unct i on set Compi l er Pat h i nput St r i ng compi l er Pat h; out put Bool ean success; end set Compi l er Pat h;
setDebugFla gs example input: failtrace,-noevalfunc Interface f unct i on set DebugFl ags i nput St r i ng debugFl ags; out put Bool ean success; end set DebugFl ags;
setEnvironm entVar Interface f unct i on set Envi r onment Var i nput St r i ng var ; i nput St r i ng val ue; out put Bool ean success; end set Envi r onment Var ;
setIndexRed uctionMetho d example input: dummyDerivative Interface f unct i on set I ndexReduct i onMet hod i nput St r i ng met hod; out put Bool ean success; end set I ndexReduct i onMet hod;
setInstalla tionDirecto ryPath Sets the OPENMODELICAHOME environment variable. Use this method instead of setEnvironmentVar Interface f unct i on set I nst al l at i onDi r ect or yPat h i nput St r i ng i nst al l at i onDi r ect or yPat h; out put Bool ean success; end set I nst al l at i onDi r ect or yPat h;
setLanguage Standard Interface f unct i on set LanguageSt andar d i nput St r i ng i nVer si on; out put Bool ean success; end set LanguageSt andar d;
setLinker Interface f unct i on set Li nker i nput St r i ng l i nker ; out put Bool ean success; end set Li nker ;
setLinkerFl ags Interface f unct i on set Li nker Fl ags i nput St r i ng l i nker Fl ags; out put Bool ean success; end set Li nker Fl ags;
setModelica Path See loadModel() for a description of what the MODELICAPATH is used for. Interface f unct i on set Model i caPat h i nput St r i ng model i caPat h; out put Bool ean success; end set Model i caPat h;
setNoSimpli fy Interface f unct i on set NoSi mpl i f y i nput Bool ean noSi mpl i f y; out put Bool ean success; end set NoSi mpl i f y;
setOrderCon nections Interface f unct i on set Or der Connect i ons i nput Bool ean or der Connect i ons; out put Bool ean success; end set Or der Connect i ons;
setPastOptM odules example input: lateInline,inlineArrayEqn,removeSimpleEquations Interface f unct i on set Past Opt Modul es i nput St r i ng modul es; out put Bool ean success; end set Past Opt Modul es;
setPlotComm and Interface f unct i on set Pl ot Command i nput St r i ng pl ot Command; out put Bool ean success; end set Pl ot Command;
setPlotSile nt Interface f unct i on set Pl ot Si l ent i nput Bool ean si l ent ; out put Bool ean success; end set Pl ot Si l ent ;
setPreOptMo dules example input: removeFinalParameters,removeSimpleEquations,expandDerOperator Interface f unct i on set Pr eOpt Modul es i nput St r i ng modul es; out put Bool ean success; end set Pr eOpt Modul es;
setShowAnno tations Interface f unct i on set ShowAnnot at i ons i nput Bool ean show; out put Bool ean success; end set ShowAnnot at i ons;
setSourceFi le Interface f unct i on set Sour ceFi l e i nput TypeName cl ass_; i nput St r i ng f i l ename; out put Bool ean success; end set Sour ceFi l e;
setTempDire ctoryPath Interface f unct i on set TempDi r ect or yPat h i nput St r i ng t empDi r ect or yPat h; out put Bool ean success; end set TempDi r ect or yPat h;
setVectoriz ationLimit Interface f unct i on set Vect or i zat i onLi mi t i nput I nt eger vect or i zat i onLi mi t ; out put Bool ean success; end set Vect or i zat i onLi mi t ;
solveLinear System 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. Interface f unct i on sol veLi near Syst em i nput Real [ si ze( B, 1) , si ze( B, 1) ] A; i nput Real [ : ] B; i nput Li near Syst emSol ver sol ver = Li near Syst emSol ver . dgesv; i nput I nt eger [ : ] i sI nt = {- 1} "l i st of i ndi ces t hat ar e i nt eger s"; out put Real [ si ze( B, 1) ] X; out put I nt eger i nf o; end sol veLi near Syst em;
strictRMLCh eck Checks if any loaded function Interface f unct i on st r i ct RMLCheck out put St r i ng message "empt y i f t her e was no pr obl em"; end st r i ct RMLCheck;
stringRepla ce Interface f unct i on st r i ngRepl ace i nput St r i ng st r ; i nput St r i ng sour ce; i nput St r i ng t ar get ; out put St r i ng r es; end st r i ngRepl ace;
Strtok Splits the strings at the places given by the token, for example: strtok("abcbdef","b") =>{"a","c","def"} Interface f unct i on st r t ok i nput St r i ng st r i ng; i nput St r i ng t oken; out put St r i ng[ : ] st r i ngs; end st r t ok;
System Similar to system(3). Executes the given command in the systemshell. Interface f unct i on syst em i nput St r i ng cal l St r "St r i ng t o cal l : bash - c $cal l St r "; out put I nt eger r et val "Ret ur n val ue of t he syst emcal l ; usual l y 0 on success"; end syst em;
translateGr aphics Interface f unct i on t r ansl at eGr aphi cs i nput TypeName cl assName; out put St r i ng r esul t ; end t r ansl at eGr aphi cs;
typeNameStr ing Interface f unct i on t ypeNameSt r i ng i nput TypeName cl ; out put St r i ng out ; end t ypeNameSt r i ng;
typeNameStr ings Interface f unct i on t ypeNameSt r i ngs i nput TypeName cl ; out put St r i ng out [ : ] ; end t ypeNameSt r i ngs;
typeOf Interface f unct i on t ypeOf i nput Var i abl eName var i abl eName; out put St r i ng r esul t ; end t ypeOf ;
uriToFilena me Handles modelica:// and file:// URI's. The result is an absolute path on the local system. The result depends on the current MODELICAPATH. Returns the empty string on failure. Interface f unct i on ur i ToFi l ename i nput St r i ng ur i ; out put St r i ng f i l ename; end ur i ToFi l ename;
Val Works on the filename pointed to by the scripting variable currentSimulationResult. The result is the value of the variable at a certain time point. For parameters, any time may be given. For variables the startTime<=time<=stopTime needs to hold. On error, nan (Not a Number) is returned and the error buffer contains the message. Interface f unct i on val i nput Var i abl eName var ; i nput Real t i me; out put Real val At Ti me; end val ;
verifyCompi ler Interface f unct i on ver i f yCompi l er out put Bool ean compi l er Wor ks; end ver i f yCompi l er ;
visualize
Uses the 3D visualization package, SimpleVisual.mo, to visualize the model. See chapter 3.4 (3D Animation) of the OpenModelica SystemDocumentation for more details. Writes the visulizations objects into the file "model_name.visualize" Don't require sendData support.
Interface f unct i on vi sual i ze i nput TypeName cl assName; i nput Bool ean ext er nal Wi ndow = f al se " Opens t he vi sual i ze i n a new wi ndow"; i nput St r i ng f i l eName = "<def aul t >" "The f i l ename cont ai ni ng t he var i abl es. <def aul t > wi l l r ead t he l ast si mul at i on r esul t "; out put Bool ean success "Ret ur ns t r ue on success"; end vi sual i ze;
writeFile Write the data to file. Returns true on success. Interface f unct i on wr i t eFi l e i nput St r i ng f i l eName; i nput St r i ng dat a; i nput Bool ean append = f al se; out put Bool ean success; end wr i t eFi l e;
6.1 Additi onal resources
For a list of OMC APIs with their syntax and examples, read the document