Skip to content

Commit

Permalink
Deprecate translateModelFMU (#10866)
Browse files Browse the repository at this point in the history
- Use buildModelFMU instead of translateModelFMU
- Skip documentation generation for depreacted API functions
  • Loading branch information
AnHeuermann committed Jun 20, 2023
1 parent 1f6cb03 commit e074f85
Show file tree
Hide file tree
Showing 96 changed files with 121 additions and 105 deletions.
7 changes: 4 additions & 3 deletions OMCompiler/Compiler/FrontEnd/ModelicaBuiltin.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2478,7 +2478,8 @@ annotation(preferredView="text");
end importFMUModelDescription;

function translateModelFMU
"translates a modelica model into a Functional Mockup Unit.
"Deprecated: 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\");"
Expand All @@ -2489,7 +2490,7 @@ The only required argument is the className, while all others have some default
input Boolean includeResources = false "include Modelica based resources via loadResource or not";
output String generatedFileName "Returns the full path of the generated FMU.";
external "builtin";
annotation(preferredView="text");
annotation(preferredView="text", version="Deprecated");
end translateModelFMU;

function buildModelFMU
Expand Down Expand Up @@ -2956,7 +2957,7 @@ public function compareSimulationResults "compares simulation results."
input String[:] vars = fill("",0);
output String[:] result;
external "builtin";
annotation(preferredView="text");
annotation(preferredView="text", version="Deprecated");
end compareSimulationResults;

public function deltaSimulationResults "calculates the sum of absolute errors."
Expand Down
7 changes: 4 additions & 3 deletions OMCompiler/Compiler/NFFrontEnd/NFModelicaBuiltin.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2731,7 +2731,8 @@ annotation(preferredView="text");
end importFMUModelDescription;

function translateModelFMU
"translates a modelica model into a Functional Mockup Unit.
"Deprecated: 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\");"
Expand All @@ -2742,7 +2743,7 @@ The only required argument is the className, while all others have some default
input Boolean includeResources = false "include Modelica based resources via loadResource or not";
output String generatedFileName "Returns the full path of the generated FMU.";
external "builtin";
annotation(preferredView="text");
annotation(preferredView="text", version="Deprecated");
end translateModelFMU;

function buildModelFMU
Expand Down Expand Up @@ -3209,7 +3210,7 @@ public function compareSimulationResults "compares simulation results."
input String[:] vars = fill("",0);
output String[:] result;
external "builtin";
annotation(preferredView="text");
annotation(preferredView="text", version="Deprecated");
end compareSimulationResults;

public function deltaSimulationResults "calculates the sum of absolute errors."
Expand Down
1 change: 1 addition & 0 deletions OMCompiler/Compiler/Script/CevalScriptBackend.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,7 @@ algorithm
case ("translateModelFMU", Values.CODE(Absyn.C_TYPENAME(className))::Values.STRING(str1)::Values.STRING(str2)::Values.STRING(filenameprefix)::_)
algorithm
Error.addMessage(Error.DEPRECATED_API_CALL, {"translateModelFMU", "buildModelFMU"});
(outCache, ret_val) := buildModelFMU(outCache, inEnv, className, str1, str2, filenameprefix, true);
then
ret_val;
Expand Down
2 changes: 1 addition & 1 deletion OMCompiler/SimulationRuntime/fmi/export/fmi1/model_fmu.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
loadModel(Modelica); getErrorString();
loadModel(ModelicaServices); getErrorString();
loadFile("@OMC_MODELDIR@/@OMC_MODELNAME@.mo");
translateModelFMU(@OMC_MODELNAME@);
buildModelFMU(@OMC_MODELNAME@);
15 changes: 14 additions & 1 deletion doc/UsersGuide/interface.mos
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,20 @@ algorithm
out := out + sum(\" \" + l + \"\\n\" for l in OpenModelica.Scripting.strtok(s, \"\\n\")) + \" \\n\";
end if;
end reSTInterface;

function isDeprecatedVersion
input OpenModelica.Scripting.TypeName cl;
output Boolean deprecated;
protected
String version = OpenModelica.Scripting.getVersion(cl);
algorithm
if stringEq(version, \"Deprecated\") then
deprecated := true;
else
deprecated := false;
end if;
end isDeprecatedVersion;
");
getErrorString();

writeFile("interface.inc", sum(reSTInterface(cl) for cl guard isFunction(cl) and not isPartial(cl) and not regexBool(typeNameString(cl), "Internal") in getClassNames(OpenModelica.Scripting, sort=true, recursive=true)));getErrorString();
writeFile("interface.inc", sum(reSTInterface(cl) for cl guard isFunction(cl) and not isPartial(cl) and not isDeprecatedVersion(cl) and not regexBool(typeNameString(cl), "Internal") in getClassNames(OpenModelica.Scripting, sort=true, recursive=true)));getErrorString();
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
loadModel(Modelica, {"3.2.3"}); getErrorString();
setCommandLineOptions("+simCodeTarget=Cpp"); getErrorString();
loadFile("CoupledClutches.mo"); getErrorString();
translateModelFMU(CoupledClutches, version="1.0"); getErrorString();
buildModelFMU(CoupledClutches, version="1.0"); getErrorString();

setCommandLineOptions("+simCodeTarget=C"); getErrorString();
importFMU("CoupledClutches.fmu"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
loadModel(Modelica, {"3.2.2"}); getErrorString();
setCommandLineOptions("+simCodeTarget=Cpp"); getErrorString();
loadFile("cranes.mo"); getErrorString();
translateModelFMU(cranes.crane, version="1.0"); getErrorString();
buildModelFMU(cranes.crane, version="1.0"); getErrorString();

setCommandLineOptions("+simCodeTarget=C"); getErrorString();
//importFMU("cranes_crane.fmu", "<default>", 6, false, true); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ equation
der(y2) = y1;
end DIC;
");
translateModelFMU(DIC, version="1.0"); getErrorString();
buildModelFMU(DIC, version="1.0"); getErrorString();

loadModel(Modelica, {"3.2.3"}); getErrorString();
setCommandLineOptions("+simCodeTarget=C"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

loadModel(Modelica, {"3.2.1"}); getErrorString();
setCommandLineOptions("+simCodeTarget=Cpp"); getErrorString();
translateModelFMU(Modelica.Fluid.Examples.BranchingDynamicPipes, version="1.0"); getErrorString();
buildModelFMU(Modelica.Fluid.Examples.BranchingDynamicPipes, version="1.0"); getErrorString();

setCommandLineOptions("+simCodeTarget=C"); getErrorString();
importFMU("Modelica_Fluid_Examples_BranchingDynamicPipes.fmu"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
loadModel(Modelica, {"3.2.3"}); getErrorString();
setCommandLineOptions("+simCodeTarget=Cpp"); getErrorString();
loadFile("CoupledClutches.mo"); getErrorString();
translateModelFMU(CoupledClutches, version = "2.0"); getErrorString();
buildModelFMU(CoupledClutches, version = "2.0"); getErrorString();

setCommandLineOptions("+simCodeTarget=C"); getErrorString();
importFMU("CoupledClutches.fmu"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ setCommandLineOptions("+simCodeTarget=Cpp"); getErrorString();
setCommandLineOptions("+d=disableDirectionalDerivatives"); getErrorString();

loadFile("../1.0/cranes.mo"); getErrorString();
translateModelFMU(cranes.crane, version="2.0"); getErrorString();
buildModelFMU(cranes.crane, version="2.0"); getErrorString();

//importFMU("cranes.crane.fmu", "<default>", 6, false, true); getErrorString();
importFMU("cranes.crane.fmu", "<default>"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ equation
der(y2) = y1;
end DIC;
");
translateModelFMU(DIC, version = "2.0"); getErrorString();
buildModelFMU(DIC, version = "2.0"); getErrorString();

loadModel(Modelica, {"3.2.3"}); getErrorString();
importFMU("DIC.fmu"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ end LocalIOs;
");
getErrorString();

translateModelFMU(LocalIOs.System, version="2.0"); getErrorString();
buildModelFMU(LocalIOs.System, version="2.0"); getErrorString();

// unzip to console, quiet, extra quiet
system("unzip -cqq LocalIOs.System.fmu modelDescription.xml | grep -v guid | grep -v generationDateAndTime | grep -v generationTool > modelDescription.tmp.xml");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ end SolveOneNonlinearEquationTest;
");
getErrorString();

translateModelFMU(SolveOneNonlinearEquationTest, version = "2.0"); getErrorString();
buildModelFMU(SolveOneNonlinearEquationTest, version = "2.0"); getErrorString();
loadModel(Modelica, {"3.2.3"}); getErrorString();
importFMU("SolveOneNonlinearEquationTest.fmu"); getErrorString();
loadFile("SolveOneNonlinearEquationTest_me_FMU.mo"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ equation
end ArrayEquationsTest;
"); getErrorString();

translateModelFMU(ArrayEquationsTest, version = "2.0"); getErrorString();
buildModelFMU(ArrayEquationsTest, version = "2.0"); getErrorString();

// unzip to console, quiet, extra quiet
system("unzip -cqq ArrayEquationsTest.fmu modelDescription.xml | grep -v guid | grep -v generationDateAndTime | grep -v generationTool > modelDescription.tmp.xml");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ getErrorString();
// enable directional derivatives
setCommandLineOptions("-d=-disableDirectionalDerivatives"); getErrorString();

translateModelFMU(CSTRModel, version="2.0"); getErrorString();
buildModelFMU(CSTRModel, version="2.0"); getErrorString();

// unzip to console, quiet, extra quiet
system("unzip -cqq CSTRModel.fmu modelDescription.xml | grep -v guid | grep -v generationDateAndTime | grep -v generationTool > modelDescription.tmp.xml");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ end SubClocks;
");
getErrorString();

translateModelFMU(SubClocks, version="2.0");
buildModelFMU(SubClocks, version="2.0");
getErrorString();

// unzip to console, quiet, extra quiet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ getErrorString();
// enable directional derivatives
setCommandLineOptions("-d=-disableDirectionalDerivatives"); getErrorString();

translateModelFMU(TableTest, version="2.0"); getErrorString();
buildModelFMU(TableTest, version="2.0"); getErrorString();

importFMU("TableTest.fmu"); getErrorString();
loadFile("TableTest_me_FMU.mo"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ getErrorString();
// enable directional derivatives
setCommandLineOptions("-d=-disableDirectionalDerivatives"); getErrorString();

translateModelFMU(DrumBoilerModel, version="2.0"); getErrorString();
buildModelFMU(DrumBoilerModel, version="2.0"); getErrorString();

// unzip to console, quiet, extra quiet
system("unzip -cqq DrumBoilerModel.fmu modelDescription.xml | grep -v guid | grep -v generationDateAndTime | grep -v generationTool > modelDescription.tmp.xml");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ model MatrixIOTest
end MatrixIOTest;
"); getErrorString();

translateModelFMU(MatrixIOTest, version = "2.0"); getErrorString();
buildModelFMU(MatrixIOTest, version = "2.0"); getErrorString();
loadModel(Modelica, {"3.2.3"}); getErrorString();
importFMU("MatrixIOTest.fmu"); getErrorString();
loadFile("MatrixIOTest_me_FMU.mo"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ end SIDTest;
");
getErrorString();

translateModelFMU(SIDTest, version="2.0");
buildModelFMU(SIDTest, version="2.0");
getErrorString();

// unzip to console, quiet, extra quiet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ equation
y1 = sum(x1);
end ArrayEquationsTest;");

translateModelFMU(ArrayEquationsTest, version = "2.0"); getErrorString();
buildModelFMU(ArrayEquationsTest, version = "2.0"); getErrorString();

// unzip to console, quiet, extra quiet
system("unzip -cqq ArrayEquationsTest.fmu modelDescription.xml > ArrayEquationsTest_tmp.xml"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ loadModel(Modelica, {"3.2.3"}); getErrorString();
setDebugFlags("hpcom,hardcodedStartValues"); getErrorString();
setCommandLineOptions("+simCodeTarget=Cpp +n=1 +hpcomCode=openmp +hpcomScheduler=level"); getErrorString();
loadFile("CoupledClutches.mo"); getErrorString();
translateModelFMU(CoupledClutches); getErrorString();
buildModelFMU(CoupledClutches); getErrorString();

clearDebugFlags(); getErrorString();
setCommandLineOptions("+simCodeTarget=C"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ loadModel(Modelica, {"3.2.3"}); getErrorString();
setDebugFlags("hpcom,hardcodedStartValues"); getErrorString();
setCommandLineOptions("+simCodeTarget=Cpp +n=2 +hpcomCode=openmp +hpcomScheduler=list"); getErrorString();
loadFile("CoupledClutches.mo"); getErrorString();
translateModelFMU(CoupledClutches); getErrorString();
buildModelFMU(CoupledClutches); getErrorString();


setCommandLineOptions("+simCodeTarget=C"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ loadModel(Modelica, {"3.2.3"}); getErrorString();
setDebugFlags("hpcom,hardcodedStartValues"); getErrorString();
setCommandLineOptions("+simCodeTarget=Cpp +n=2 +hpcomCode=openmp +hpcomScheduler=level"); getErrorString();
loadFile("cranes.mo"); getErrorString();
translateModelFMU(cranes.crane); getErrorString();
buildModelFMU(cranes.crane); getErrorString();

setCommandLineOptions("+simCodeTarget=C"); getErrorString();
clearDebugFlags(); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ loadModel(Modelica, {"3.2.3"}); getErrorString();
setDebugFlags("hpcom"); getErrorString();
setCommandLineOptions("+simCodeTarget=Cpp +n=2 +hpcomCode=openmp +hpcomScheduler=level"); getErrorString();
loadFile("cranes.mo"); getErrorString();
translateModelFMU(cranes.crane); getErrorString();
buildModelFMU(cranes.crane); getErrorString();

//importFMU("cranes_crane.fmu", "<default>", 6); getErrorString();
//importFMU("cranes_crane.fmu"); getErrorString();
Expand Down
2 changes: 1 addition & 1 deletion testsuite/openmodelica/cruntime/msvc/BouncingBall.mos
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ equation

end BouncingBallFMI20;
"); getErrorString();
translateModelFMU(BouncingBallFMI20, version = "2.0"); getErrorString();
buildModelFMU(BouncingBallFMI20, version = "2.0"); getErrorString();
importFMU("BouncingBallFMI20.fmu"); getErrorString();
loadFile("BouncingBallFMI20_me_FMU.mo"); getErrorString();
simulate(BouncingBallFMI20_me_FMU, stopTime=3.0); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ loadString("model Pendulum
extends Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum;
end Pendulum;"); getErrorString();
setCommandLineOptions("--fmiFlags=s:cvode"); getErrorString();
translateModelFMU(Pendulum, version = "2.0", fmuType="me_cs"); getErrorString();
buildModelFMU(Pendulum, version = "2.0", fmuType="me_cs"); getErrorString();

// Check _flags.json for simulation flags
system("unzip -cqq Pendulum.fmu resources/Pendulum_flags.json > Pendulum_flags_static.json"); getErrorString();
Expand Down
10 changes: 5 additions & 5 deletions testsuite/openmodelica/fmi/CoSimulation/2.0/FmuExportFlags.mos
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ end BouncingBallFMI20;

// Don't generate simulation settings file
setCommandLineOptions("--fmiFlags=none"); getErrorString();
translateModelFMU(BouncingBallFMI20, version = "2.0", fmuType="cs"); getErrorString();
buildModelFMU(BouncingBallFMI20, version = "2.0", fmuType="cs"); getErrorString();

system("unzip -cqq BouncingBallFMI20.fmu resources/BouncingBallFMI20_flags.json > BouncingBallFMI20_flags.json"); getErrorString();

// Generate default simulation settings file
setCommandLineOptions("--fmiFlags=default"); getErrorString();
translateModelFMU(BouncingBallFMI20, version = "2.0", fmuType="cs"); getErrorString();
buildModelFMU(BouncingBallFMI20, version = "2.0", fmuType="cs"); getErrorString();

system("unzip -cqq BouncingBallFMI20.fmu resources/BouncingBallFMI20_flags.json > BouncingBallFMI20_flags.json"); getErrorString();
readFile("BouncingBallFMI20_flags.json"); getErrorString();

// Comandline options for simflags
setCommandLineOptions("--fmiFlags=s:cvode,nls:homotopy,yourFlagName:here"); getErrorString();
translateModelFMU(BouncingBallFMI20, version = "2.0", fmuType="cs"); getErrorString();
buildModelFMU(BouncingBallFMI20, version = "2.0", fmuType="cs"); getErrorString();

system("unzip -cqq BouncingBallFMI20.fmu resources/BouncingBallFMI20_flags.json > BouncingBallFMI20_flags.json"); getErrorString();
readFile("BouncingBallFMI20_flags.json"); getErrorString();
Expand All @@ -54,14 +54,14 @@ writeFile("exampleFlags.json",
}"); getErrorString();

setCommandLineOptions("--fmiFlags=exampleFlags.json"); getErrorString();
translateModelFMU(BouncingBallFMI20, version = "2.0", fmuType="cs"); getErrorString();
buildModelFMU(BouncingBallFMI20, version = "2.0", fmuType="cs"); getErrorString();

system("unzip -cqq BouncingBallFMI20.fmu resources/BouncingBallFMI20_flags.json > BouncingBallFMI20_flags.json"); getErrorString();
readFile("BouncingBallFMI20_flags.json"); getErrorString();

// Give file with simflags as absolute path
setCommandLineOptions("--fmiFlags=" + realpath(".") + "/exampleFlags.json"); getErrorString();
translateModelFMU(BouncingBallFMI20, version = "2.0", fmuType="cs"); getErrorString();
buildModelFMU(BouncingBallFMI20, version = "2.0", fmuType="cs"); getErrorString();

system("unzip -cqq BouncingBallFMI20.fmu resources/BouncingBallFMI20_flags.json > BouncingBallFMI20_flags.json"); getErrorString();
readFile("BouncingBallFMI20_flags.json"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ equation
end fmi_interpolation_01;
"); getErrorString();

translateModelFMU(fmi_interpolation_01, fmuType="cs"); getErrorString();
buildModelFMU(fmi_interpolation_01, fmuType="cs"); getErrorString();

//unzip to console, quiet, extra quiet
system("unzip -cqq fmi_interpolation_01.fmu modelDescription.xml > fmi_interpolation_01_tmp.xml"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ equation
end stiffProblem;
"); getErrorString();
setCommandLineOptions("-d=newInst --fmiFlags=s:cvode"); getErrorString();
translateModelFMU(stiffProblem, version = "2.0", fmuType="me_cs"); getErrorString();
buildModelFMU(stiffProblem, version = "2.0", fmuType="me_cs"); getErrorString();

// Check _flags.json for simulation flags
system("unzip -cqq stiffProblem.fmu resources/stiffProblem_flags.json > stiffProblem_flags_dynamic.json"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ val(y4, 10);
val(Q, 10);
val(QI, 10);

translateModelFMU(BooleanNetwork1, version="1.0"); getErrorString();
buildModelFMU(BooleanNetwork1, version="1.0"); getErrorString();

importFMU("BooleanNetwork1.fmu"); getErrorString();
loadFile("BooleanNetwork1_me_FMU.mo"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
setCFlags(getCFlags() + " -g"); getErrorString();
loadFile("BouncingBall.mo"); getErrorString();

if ""==translateModelFMU(BouncingBall, version="1.0") then
if ""==buildModelFMU(BouncingBall, version="1.0") then
print(getErrorString());
exit(1);
end if;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

loadModel(Modelica, {"3.2.3"}); getErrorString();
loadFile("CoupledClutches.mo"); getErrorString();
translateModelFMU(CoupledClutches, version="1.0"); getErrorString();
buildModelFMU(CoupledClutches, version="1.0"); getErrorString();

importFMU("CoupledClutches.fmu"); getErrorString();
loadFile("CoupledClutches_me_FMU.mo"); getErrorString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

loadFile("EnumerationTest.mo");
//instantiateModel(EnumerationTest);
translateModelFMU(EnumerationTest, version="1.0");
buildModelFMU(EnumerationTest, version="1.0");
getErrorString();

importFMU("EnumerationTest.fmu"); getErrorString();
Expand Down

0 comments on commit e074f85

Please sign in to comment.