Skip to content

Commit

Permalink
"previous" operator support in C simulation runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
gossen authored and OpenModelica-Hudson committed Aug 31, 2015
1 parent 9fa1b91 commit d9175e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
14 changes: 2 additions & 12 deletions Compiler/Template/CodegenC.tpl
Expand Up @@ -338,7 +338,7 @@ template functionSystemsSynchronous(list<SubPartition> subPartitions, String mod
let systs = subPartitions |> subPartition hasindex i =>
match subPartition
case SUBPARTITION(__) then
functionEquationsSynchronous(i, listAppend(equations, removedEquations), modelNamePrefix)
functionEquationsSynchronous(i, vars, listAppend(equations, removedEquations), modelNamePrefix)
; separator = "\n"
let cases = subPartitions |> subPartition hasindex i =>
let name = 'functionEquationsSynchronous_system<%i%>'
Expand Down Expand Up @@ -372,7 +372,7 @@ template functionSystemsSynchronous(list<SubPartition> subPartitions, String mod

end functionSystemsSynchronous;

template functionEquationsSynchronous(Integer i, list<SimEqSystem> equations, String modelNamePrefix)
template functionEquationsSynchronous(Integer i, list<tuple<SimCodeVar.SimVar, Boolean>> vars, list<SimEqSystem> equations, String modelNamePrefix)
::=
let &varDecls = buffer ""
let &eqfuncs = buffer ""
Expand All @@ -386,7 +386,6 @@ template functionEquationsSynchronous(Integer i, list<SimEqSystem> equations, St
int i;
<%addRootsTempArray()%>
<%varDecls%>
<%fncalls%>
Expand All @@ -396,15 +395,6 @@ template functionEquationsSynchronous(Integer i, list<SimEqSystem> equations, St
>>
end functionEquationsSynchronous;

template prevVarSynchronous(Integer i, SimVar var)
::=
match var
case SIMVAR(arrayCref=SOME(c), aliasvar=NOALIAS()) then
'$P$CLKPRE<%cref(c)%> = <%cref(c)%>;'
case SIMVAR(aliasvar=NOALIAS()) then
'$P$CLKPRE<%cref(name)%> = <%cref(name)%>;'
end prevVarSynchronous;

template simulationFile_exo(SimCode simCode, String guid)
"External Objects"
::=
Expand Down
2 changes: 2 additions & 0 deletions Compiler/Template/CodegenCFunctions.tpl
Expand Up @@ -5276,6 +5276,8 @@ template daeExpCall(Exp call, Context context, Text &preExp, Text &varDecls, Tex
error(sourceInfo(), 'Code generation does not support der(<%printExpStr(exp)%>)')
case CALL(path=IDENT(name="pre"), expLst={arg}) then
daeExpCallPre(arg, context, preExp, varDecls, &auxFunction)
case CALL(path=IDENT(name="previous"), expLst={arg as CREF(__)}) then
'$P$CLKPRE<%cref(arg.componentRef)%>'
// a $_start is used to get get start value of a variable
case CALL(path=IDENT(name="$_start"), expLst={arg}) then
daeExpCallStart(arg, context, preExp, varDecls, &auxFunction)
Expand Down

0 comments on commit d9175e1

Please sign in to comment.