Skip to content

Commit

Permalink
- Added XML code generation for Scalar variable type- min and max att…
Browse files Browse the repository at this point in the history
…ributes

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@13936 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Alachew Mengist committed Nov 17, 2012
1 parent e1a595a commit e528f23
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions Compiler/Template/CodegenXML.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ case SIMVAR(__) then
let variableCategory = variableCategoryXml(varKind)
<<
<ScalarVariable name="<%crefStrXml(name)%>" <%description%> valueReference="<%valueReference%>" variability="<%variability%>" causality="<%caus%>" alias="<%alias%>">
<%ScalarVariableTypeXml(type_,unit,displayUnit,initialValue,isFixed)%>
<%ScalarVariableTypeXml(type_,unit,displayUnit, minValue, maxValue, initialValue,isFixed)%>
<QualifiedName>
<%qualifiedNamePartXml(name)%>
</QualifiedName>
Expand Down Expand Up @@ -230,12 +230,12 @@ template variableCategoryXml(VarKind varKind)
else error(sourceInfo(), "Unexpected simVarTypeName varKind")
end variableCategoryXml;

template ScalarVariableTypeXml(DAE.Type type_, String unit, String displayUnit, Option<DAE.Exp> initialValue, Boolean isFixed)
template ScalarVariableTypeXml(DAE.Type type_, String unit, String displayUnit, Option<DAE.Exp> minValue, Option<DAE.Exp> maxValue, Option<DAE.Exp> initialValue, Boolean isFixed)
"Generates XML code for ScalarVariable Type file."
::=
match type_
case T_INTEGER(__) then '<Integer <%ScalarVariableTypeCommonAttributeXml(initialValue,isFixed)%>/>'
case T_REAL(__) then '<Real <%ScalarVariableTypeCommonAttributeXml(initialValue,isFixed)%> <%ScalarVariableTypeRealAttributeXml(unit,displayUnit)%>/>'
case T_INTEGER(__) then '<Integer <%ScalarVariableTypeCommonAttributeXml(initialValue,isFixed)%>/> <%ScalarVariableTypeMinAttribute(minValue)%> <%ScalarVariableTypeMaxAttribute(maxValue)%>'
case T_REAL(__) then '<Real <%ScalarVariableTypeCommonAttributeXml(initialValue,isFixed)%> <%ScalarVariableTypeMinAttribute(minValue)%> <%ScalarVariableTypeMaxAttribute(maxValue)%> <%ScalarVariableTypeRealAttributeXml(unit,displayUnit)%>/>'
case T_BOOL(__) then '<Boolean <%ScalarVariableTypeCommonAttributeXml(initialValue,isFixed)%>/>'
case T_STRING(__) then '<String <%ScalarVariableTypeCommonAttributeXml(initialValue,isFixed)%>/>'
case T_ENUMERATION(__) then '<Real <%ScalarVariableTypeCommonAttributeXml(initialValue,isFixed)%>/>'
Expand All @@ -249,6 +249,20 @@ match initialValue
case SOME(exp) then 'start="<%initValXml(exp)%>" fixed="<%isFixed%>"'
end ScalarVariableTypeCommonAttributeXml;

template ScalarVariableTypeMinAttribute(Option<DAE.Exp> minValue)
"generates code for min attribute"
::=
match minValue
case SOME(exp) then 'min="<%initValXml(exp)%>"'
end ScalarVariableTypeMinAttribute;

template ScalarVariableTypeMaxAttribute(Option<DAE.Exp> maxValue)
"generates code for max attribute"
::=
match maxValue
case SOME(exp) then 'max="<%initValXml(exp)%>"'
end ScalarVariableTypeMaxAttribute;

template initValXml(Exp initialValue)
"Returns initial value of ScalarVariable."
::=
Expand Down

0 comments on commit e528f23

Please sign in to comment.