Skip to content

Commit

Permalink
- Allocate and free the proper fmi version structures.
Browse files Browse the repository at this point in the history
- some test cases.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14547 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Dec 27, 2012
1 parent 9f327c4 commit b3c3c19
Show file tree
Hide file tree
Showing 6 changed files with 384 additions and 79 deletions.
7 changes: 4 additions & 3 deletions Compiler/Script/CevalScript.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1527,23 +1527,24 @@ algorithm
pd = System.pathDelimiter();
str1 = FMI.getFMIModelIdentifier(fmiInfo);
str2 = FMI.getFMIType(fmiInfo);
str3 = FMI.getFMIVersion(fmiInfo);
outputFile = stringAppendList({workdir,pd,str1,"_",str2,"_FMU.mo"});
filename_1 = Util.if_(b1,stringAppendList({workdir,pd,str1,"_",str2,"_FMU.mo"}),stringAppendList({str1,"_",str2,"_FMU.mo"}));
System.writeFile(outputFile, str);
/* Release FMI objects */
FMIExt.releaseFMIImport(SOME(fmiModelVariablesInstance), SOME(fmiInstance), SOME(fmiContext));
FMIExt.releaseFMIImport(SOME(fmiModelVariablesInstance), SOME(fmiInstance), SOME(fmiContext), str3);
then
(cache,Values.STRING(filename_1),st);

case (cache,env,"importFMU",{Values.STRING(filename),Values.STRING(workdir),Values.INTEGER(fmiLogLevel),Values.BOOL(b1), Values.BOOL(b2)},st,_)
case (cache,env,"importFMU",{Values.STRING(filename),Values.STRING(workdir),Values.INTEGER(fmiLogLevel),Values.BOOL(b1), Values.BOOL(b2), Values.BOOL(inputConnectors), Values.BOOL(outputConnectors)},st,_)
equation
false = System.regularFileExists(filename);
Error.clearMessages() "Clear messages";
Error.addMessage(Error.FILE_NOT_FOUND_ERROR, {filename});
then
(cache,Values.STRING(""),st);

case (cache,env,"importFMU",{Values.STRING(filename),Values.STRING(workdir),Values.INTEGER(fmiLogLevel),Values.BOOL(b1), Values.BOOL(b2)},st,_)
case (cache,env,"importFMU",{Values.STRING(filename),Values.STRING(workdir),Values.INTEGER(fmiLogLevel),Values.BOOL(b1), Values.BOOL(b2), Values.BOOL(inputConnectors), Values.BOOL(outputConnectors)},st,_)
then
(cache,Values.STRING(""),st);

Expand Down
1 change: 1 addition & 0 deletions Compiler/Template/CodegenFMU.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,7 @@ case FMIIMPORT(fmiInfo=INFO(__),fmiExperimentAnnotation=EXPERIMENTANNOTATION(__)
>>
end importFMU1ModelExchange;

/* Fix the FMI 2.0 code generation. The one below is just the copy of FMI 1.0. Also write the wrapper C files for it. */
template importFMU2ModelExchange(FmiImport fmi)
"Generates Modelica code for FMI Model Exchange version 2.0"
::=
Expand Down
11 changes: 11 additions & 0 deletions Compiler/Util/FMI.mo
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,15 @@ algorithm
end match;
end getFMIType;

public function getFMIVersion
input Info inFMIInfo;
output String fmiVersion;
algorithm
fmiVersion := match(inFMIInfo)
local
String version;
case (INFO(fmiVersion = version)) then version;
end match;
end getFMIVersion;

end FMI;
3 changes: 2 additions & 1 deletion Compiler/Util/FMIExt.mo
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public function releaseFMIImport
input Option<Integer> inFMIModelVariablesInstance "Stores a pointer. If it is declared as Integer, it is truncated to 32-bit.";
input Option<Integer> inFMIInstance "Stores a pointer. If it is declared as Integer, it is truncated to 32-bit.";
input Option<Integer> inFMIContext "Stores a pointer. If it is declared as Integer, it is truncated to 32-bit.";
external "C" FMIImpl__releaseFMIImport(inFMIModelVariablesInstance, inFMIInstance, inFMIContext) annotation(Library = {"omcruntime","fmilib"});
input String inFMIVersion;
external "C" FMIImpl__releaseFMIImport(inFMIModelVariablesInstance, inFMIInstance, inFMIContext, inFMIVersion) annotation(Library = {"omcruntime","fmilib"});
end releaseFMIImport;

end FMIExt;

0 comments on commit b3c3c19

Please sign in to comment.