Skip to content

Commit

Permalink
- Added FMI version settings.
Browse files Browse the repository at this point in the history
- Allows exporting version 2 FMUs.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@24066 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Jan 16, 2015
1 parent 9e1f945 commit a36a7d7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Compiler/Template/CodegenFMU.tpl
Expand Up @@ -85,7 +85,7 @@ case SIMCODE(__) then
<<
<?xml version="1.0" encoding="UTF-8"?>
<%
if stringEq(FMUVersion, "2.0") then fmi2ModelDescription(simCode,guid)
if isFMIVersion20(FMUVersion) then fmi2ModelDescription(simCode,guid)
else fmiModelDescription(simCode,guid)
%>
>>
Expand Down Expand Up @@ -404,7 +404,7 @@ template TypeDefinitionType(DAE.Type type_, String FMUVersion)
::=
match type_
case T_ENUMERATION(__) then
if stringEq(FMUVersion, "2.0") then
if isFMIVersion20(FMUVersion) then
<<
<SimpleType name="<%Absyn.pathString2NoLeadingDot(path, ".")%>">
<Enumeration>
Expand Down Expand Up @@ -524,7 +524,7 @@ case SIMVAR(__) then
<<>>
else if stringEq(crefStr(name),"der($dummy)") then
<<>>
else if stringEq(FMUVersion, "2.0") then
else if isFMIVersion20(FMUVersion) then
<<
<!-- Index of variable = "<%getVariableIndex(simVar)%>" -->
<ScalarVariable
Expand Down Expand Up @@ -777,7 +777,7 @@ case SIMCODE(__) then
#include "<%fileNamePrefix%>_literals.h"
#include "simulation/solver/initialization/initialization.h"
#include "simulation/solver/events.h"
<%if stringEq(FMUVersion, "2.0") then
<%if isFMIVersion20(FMUVersion) then
'#include "fmu2_model_interface.h"'
else
'#include "fmu1_model_interface.h"'%>
Expand All @@ -788,7 +788,7 @@ case SIMCODE(__) then
void setStartValues(ModelInstance *comp);
void setDefaultStartValues(ModelInstance *comp);
<%if stringEq(FMUVersion, "2.0") then
<%if isFMIVersion20(FMUVersion) then
<<
void eventUpdate(ModelInstance* comp, fmi2EventInfo* eventInfo);
fmi2Real getReal(ModelInstance* comp, const fmi2ValueReference vr);
Expand Down Expand Up @@ -819,7 +819,7 @@ case SIMCODE(__) then
<%ModelDefineData(modelInfo)%>
// implementation of the Model Exchange functions
<%if stringEq(FMUVersion, "2.0") then
<%if isFMIVersion20(FMUVersion) then
'#define fmu2_model_interface_setupDataStruc <%symbolName(modelNamePrefix(simCode),"setupDataStruc")%>
#include "fmu2_model_interface.c"'
else
Expand All @@ -828,7 +828,7 @@ case SIMCODE(__) then
<%setDefaultStartValues(modelInfo)%>
<%setStartValues(modelInfo)%>
<%if stringEq(FMUVersion, "2.0") then
<%if isFMIVersion20(FMUVersion) then
<<
<%eventUpdateFunction2(simCode)%>
<%getRealFunction2(modelInfo)%>
Expand Down Expand Up @@ -1682,7 +1682,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
# /I - Include Directories
# /DNOMINMAX - Define NOMINMAX (does what it says)
# /TP - Use C++ Compiler
CFLAGS=/Od /ZI /EHa /fp:except /I"<%makefileParams.omhome%>/include/omc/c" <%if stringEq(FMUVersion, "2.0") then '/I"<%makefileParams.omhome%>/include/omc/c/fmi2"' else '/I"<%makefileParams.omhome%>/include/omc/c/fmi1"'%> /I. /DNOMINMAX /TP /DNO_INTERACTIVE_DEPENDENCY
CFLAGS=/Od /ZI /EHa /fp:except /I"<%makefileParams.omhome%>/include/omc/c" <%if isFMIVersion20(FMUVersion) then '/I"<%makefileParams.omhome%>/include/omc/c/fmi2"' else '/I"<%makefileParams.omhome%>/include/omc/c/fmi1"'%> /I. /DNOMINMAX /TP /DNO_INTERACTIVE_DEPENDENCY

# /ZI enable Edit and Continue debug info
CDFLAGS = /ZI
Expand Down Expand Up @@ -1759,7 +1759,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
PLATFORM = <%platformstr%>
PLAT34 = <%makefileParams.platform%>
CFLAGS=$(CFLAGS_BASED_ON_INIT_FILE) <%makefileParams.cflags%> <%match sopt case SOME(s as SIMULATION_SETTINGS(__)) then s.cflags /* From the simulate() command */%>
CPPFLAGS=-I"<%makefileParams.omhome%>/include/omc/c" <%if stringEq(FMUVersion, "2.0") then '-I"<%makefileParams.omhome%>/include/omc/c/fmi2"' else '-I"<%makefileParams.omhome%>/include/omc/c/fmi1"'%> -I. <%makefileParams.includes ; separator=" "%>
CPPFLAGS=-I"<%makefileParams.omhome%>/include/omc/c" <%if isFMIVersion20(FMUVersion) then '-I"<%makefileParams.omhome%>/include/omc/c/fmi2"' else '-I"<%makefileParams.omhome%>/include/omc/c/fmi1"'%> -I. <%makefileParams.includes ; separator=" "%>
LDFLAGS=-L"<%makefileParams.omhome%>/lib/omc" -Wl,-rpath,'<%makefileParams.omhome%>/lib/omc' -lSimulationRuntimeC -linteractive <%makefileParams.ldflags%> <%makefileParams.runtimelibs%> <%dirExtra%>
PERL=perl
MAINFILE=<%fileNamePrefix%>_FMU.c
Expand All @@ -1786,7 +1786,7 @@ template fmudeffile(SimCode simCode, String FMUVersion)
::=
match simCode
case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simulationSettingsOpt = sopt) then
if stringEq(FMUVersion, "2.0") then
if isFMIVersion20(FMUVersion) then
<<
EXPORTS
;***************************************************
Expand Down
5 changes: 5 additions & 0 deletions Compiler/Template/SimCodeTV.mo
Expand Up @@ -3373,6 +3373,11 @@ package FMI
output String fmiType;
end getFMIType;

function isFMIVersion20 "Checks if the FMI version is 2.0."
input String inFMUVersion;
output Boolean success;
end isFMIVersion20;

function getEnumerationTypeFromTypes
input list<TypeDefinitions> inTypeDefinitionsList;
input String inBaseType;
Expand Down

0 comments on commit a36a7d7

Please sign in to comment.