Skip to content

Commit

Permalink
- the number of event indicators should now be correct for c and c++ …
Browse files Browse the repository at this point in the history
…simulation runtime
  • Loading branch information
Marcus Walther committed Jul 27, 2015
1 parent d9b26e6 commit cbe8e9d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
12 changes: 1 addition & 11 deletions Compiler/Template/CodegenCppInit.tpl
Expand Up @@ -63,7 +63,7 @@ template fmiModelDescriptionAttributes(SimCode simCode, String guid)
let generationDateAndTime = CodegenFMUCommon.xsdateTime(getCurrentDateTime())
let variableNamingConvention = 'structured'
let numberOfContinuousStates = vi.numStateVars
let numberOfEventIndicators = eventIndicatorsLength(simCode)
let numberOfEventIndicators = CodegenFMUCommon.getNumberOfEventIndicators(simCode)
<<
fmiVersion="<%fmiVersion%>"
modelName="<%modelName%>"
Expand Down Expand Up @@ -231,15 +231,5 @@ template timeEventLength(SimCode simCode)
>>
end timeEventLength;

template eventIndicatorsLength(SimCode simCode)
::=
match simCode
case SIMCODE(modelInfo = MODELINFO(varInfo = vi as VARINFO(__))) then
let size = listLength(zeroCrossings)
<<
<%listLength(zeroCrossings)%>
>>
end eventIndicatorsLength;

annotation(__OpenModelica_Interface="backend");
end CodegenCppInit;
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenFMU1.tpl
Expand Up @@ -83,7 +83,7 @@ case SIMCODE(modelInfo = MODELINFO(varInfo = vi as VARINFO(__), vars = SIMVARS(s
let generationDateAndTime = xsdateTime(getCurrentDateTime())
let variableNamingConvention = 'structured'
let numberOfContinuousStates = if intEq(vi.numStateVars,1) then statesnumwithDummy(listStates) else vi.numStateVars
let numberOfEventIndicators = vi.numZeroCrossings
let numberOfEventIndicators = getNumberOfEventIndicators(simCode)
<<
fmiVersion="<%fmiVersion%>"
modelName="<%modelName%>"
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenFMU2.tpl
Expand Up @@ -95,7 +95,7 @@ case SIMCODE(modelInfo = MODELINFO(varInfo = vi as VARINFO(__), vars = SIMVARS(s
let generationTool= 'OpenModelica Compiler <%getVersionNr()%>'
let generationDateAndTime = xsdateTime(getCurrentDateTime())
let variableNamingConvention = 'structured'
let numberOfEventIndicators = vi.numZeroCrossings
let numberOfEventIndicators = getNumberOfEventIndicators(simCode)
<<
fmiVersion="<%fmiVersion%>"
modelName="<%modelName%>"
Expand Down
12 changes: 12 additions & 0 deletions Compiler/Template/CodegenFMUCommon.tpl
Expand Up @@ -435,6 +435,18 @@ match varKind
else "local"
end getCausality2Helper;

template getNumberOfEventIndicators(SimCode simCode)
"Get the number of event indicators, which depends on the selected code target (c or cpp)."
::=
match simCode
case SIMCODE(zeroCrossings = zeroCrossings, modelInfo = MODELINFO(varInfo = vi as VARINFO(__))) then
match Config.simCodeTarget()
case "Cpp" then listLength(zeroCrossings)
else vi.numZeroCrossings
end match
else ""
end getNumberOfEventIndicators;

template getInitialType(VarKind varKind, Option<DAE.Exp> initialValue, Causality c, Boolean isValueChangeable)
"Returns the Initial Attribute of ScalarVariable."
::=
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenFMUCpp.tpl
Expand Up @@ -238,7 +238,7 @@ case SIMCODE(modelInfo=MODELINFO(__)) then
#define MODEL_GUID "{<%guid%>}"

<%ModelDefineData(modelInfo)%>
#define NUMBER_OF_EVENT_INDICATORS <%CodegenCppInit.eventIndicatorsLength(simCode)%>
#define NUMBER_OF_EVENT_INDICATORS <%CodegenFMUCommon.getNumberOfEventIndicators(simCode)%>

<%if isFMIVersion20(FMUVersion) then
'#include "FMU2/FMU2Wrapper.cpp"'
Expand Down

0 comments on commit cbe8e9d

Please sign in to comment.