Skip to content

Commit

Permalink
- added tranformModelFMU to scripting commands
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22914 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Willi Braun committed Oct 24, 2014
1 parent f107cb6 commit 5766264
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
13 changes: 13 additions & 0 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -2259,6 +2259,19 @@ external "builtin";
annotation(preferredView="text");
end importFMU;

function 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\");"
input TypeName className "the class that should translated";
input String version := "1.0" "The output directory for imported FMU files. <default> will put the files to current working directory.";
input String fileNamePrefix := "<default>" "fileNamePrefix. <default> = \"className\"";
output String generatedFileName "Returns the full path of the generated FMU.";
external "builtin";
annotation(preferredView="text");
end translateModelFMU;

function 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], [stepSize], [tolerance], [method], [fileNamePrefix], [options], [outputFormat], [variableFilter], [measureTime], [cflags], [simflags])
Expand Down
2 changes: 2 additions & 0 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -1322,6 +1322,8 @@ algorithm
case (cache,env,"translateModelFMU", {Values.CODE(Absyn.C_TYPENAME(className)),Values.STRING(str1),Values.STRING(filenameprefix)},st,_)
equation
true = FMI.checkFMIVersion(str1);
str = Absyn.pathString(className);
filenameprefix = Util.if_(filenameprefix ==& "<default>", str, filenameprefix);
filenameprefix = Util.stringReplaceChar(filenameprefix,".","_");
defaulSimOpt = buildSimulationOptionsFromModelExperimentAnnotation(st, className, filenameprefix, SOME(defaultSimulationOptions));
simSettings = convertSimulationOptionsToSimCode(defaulSimOpt);
Expand Down
4 changes: 2 additions & 2 deletions Compiler/Script/StaticScript.mo
Expand Up @@ -322,13 +322,13 @@ public function elabCallInteractive "This function elaborates the functions defi
(cache,Expression.makePureBuiltinCall("translateModelCPP",
{DAE.CODE(Absyn.C_TYPENAME(className),DAE.T_UNKNOWN_DEFAULT),filenameprefix},DAE.T_STRING_DEFAULT),DAE.PROP(recordtype,DAE.C_VAR()),SOME(st));

case (cache,env,Absyn.CREF_IDENT(name = "translateModelFMU"),{Absyn.CREF(componentRef = cr)},args,impl,SOME(st),pre,_)
case (cache,env,Absyn.CREF_IDENT(name = "translateModelFMU"),{Absyn.CREF(componentRef = cr), fmuversion, filenameprefix},args,impl,SOME(st),pre,_)
equation
className = Absyn.crefToPath(cr);
cname_str = Absyn.pathString(className);
(cache,fmuversion) = Static.getOptionalNamedArg(cache,env, SOME(st), impl, "version",
DAE.T_STRING_DEFAULT, args, DAE.SCONST("1.0"),pre,info);
(cache,filenameprefix) = Static.getOptionalNamedArg(cache,env, SOME(st), impl, "fileNamePrefix",
(cache, filenameprefix) = Static.getOptionalNamedArg(cache,env, SOME(st), impl, "fileNamePrefix",
DAE.T_STRING_DEFAULT, args, DAE.SCONST(cname_str),pre,info);
recordtype =
DAE.T_COMPLEX(ClassInf.RECORD(Absyn.IDENT("SimulationObject")),
Expand Down

0 comments on commit 5766264

Please sign in to comment.