Skip to content

Commit

Permalink
- Added time Point value and index in XML code generation
Browse files Browse the repository at this point in the history
- Fixed XML code generation for Builtin functions

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14153 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Alachew Mengist committed Nov 29, 2012
1 parent 3e878e3 commit 1809490
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions Compiler/Template/CodegenXML.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ template variableCategoryXml(VarKind varKind)
case DUMMY_STATE(__) then "algebraic"
case DISCRETE(__) then "algebraic"
case PARAM(__) then "parameter"
case CONST(__) then "IndependentConstant"
case CONST(__) then "independentConstant"
else error(sourceInfo(), "Unexpected simVarTypeName varKind")
end variableCategoryXml;

Expand Down Expand Up @@ -1411,13 +1411,25 @@ template classAttributesXml(ClassAttributes classAttribute, SimCode simCode)
<opt:Value><%daeExpValueXml(exp, contextSimulationDiscrete, &preExp /*BUFC*/, &varDecls /*BUFD*/)%></opt:Value>
</opt:IntervalFinalTime>
>>
let timePointIndex = match startTimeE case SOME(exp) then
<<
<opt:Index><%daeExpValueXml(exp, contextSimulationDiscrete, &preExp /*BUFC*/, &varDecls /*BUFD*/)%></opt:Index>
>>
let timePointValue = match finalTimeE case SOME(exp) then
<<
<opt:Value><%daeExpValueXml(exp, contextSimulationDiscrete, &preExp /*BUFC*/, &varDecls /*BUFD*/)%></opt:Value>
>>
let constraints = match simCode case SIMCODE(modelInfo = MODELINFO(__)) then constraintsXml(constraints)
<<
<opt:Optimization>
<%objectiveFunction%>
<%objectiveIntegrand%>
<%startTime%>
<%finalTime%>
<opt:TimePoints>
<%timePointIndex%>
<%timePointValue%>
</opt:TimePoints>
<opt:pathConstraints>
<%constraints%>
</opt:pathConstraints>
Expand Down Expand Up @@ -3357,7 +3369,8 @@ template daeExpCallXml(Exp call, Context context, Text &preExp /*BUFP*/,

case exp as CALL(attr=attr as CALL_ATTR(__)) then
let argStr = (expLst |> exp => '<%daeExpXml(exp, context, &preExp /*BUFC*/, &varDecls /*BUFD*/)%>' ;separator="\n")
let builtinName ='<%dotPathXml(path)%>'
//let builtinName ='<%dotPathXml(path)%>'
let builtinFunctionName ='<%builtinFunctionNameXml(path)%>'
let funName = '<%underscorePathXml(path)%>'
let retType = if attr.builtin then (match attr.ty case T_NORETCALL(__) then ""
else expTypeModelicaXml(attr.ty))
Expand All @@ -3372,9 +3385,9 @@ template daeExpCallXml(Exp call, Context context, Text &preExp /*BUFP*/,
case CALL(attr=CALL_ATTR(tuple_=false)) then
if attr.builtin then
<<
<exp:<%builtinName%>>
<exp:<%builtinFunctionName%>>
<%argStr%>
</exp:<%builtinName%>>
</exp:<%builtinFunctionName%>>
>>
else
<<
Expand All @@ -3401,6 +3414,16 @@ template daeExpCallXml(Exp call, Context context, Text &preExp /*BUFP*/,
>>
end daeExpCallXml;

template builtinFunctionNameXml(Path path)
::=
match path
case IDENT(name="DIVISION") then 'Div'
case IDENT(name="ADDITION") then 'Add'
case IDENT(name="SUBTRACTION") then 'Sub'
case IDENT(name="POWER") then 'Pow'
else "Builtin Function is not yet implemented "
end builtinFunctionNameXml;

template daeExpTailCallXml(list<DAE.Exp> es, list<String> vs, Context context, Text &preExp, Text &varDecls)
::=
match es
Expand Down

0 comments on commit 1809490

Please sign in to comment.