Skip to content

Commit

Permalink
Fixed problem evaluating pre() function in the adevs backend
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14186 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
smiz committed Dec 1, 2012
1 parent 685e0cf commit b79b99a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Compiler/Template/CodegenAdevs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,17 @@ case SIMCODE(modelInfo = MODELINFO(vars = vars as SIMVARS(__))) then
// Switch the state event variables
for (int i = 0; i < numZeroCrossings(); i++)
if (state_event[i]) zc[i] = !zc[i];
for (int i = 0; i < numTimeEvents(); i++)
{
assert(samples[i] != NULL);
samples[i]->setEnabled(true);
}
calc_vars(q);
for (int i = 0; i < numTimeEvents(); i++)
{
samples[i]->update(timeValue,epsilon);
samples[i]->setEnabled(false);
}
save_vars(); // save the new state of the model
// Reinitialize state variables that need to be reinitialized
<%(vars.stateVars |> SIMVAR(__) => 'q[<%index%>]=<%cref(name)%>;') ;separator="\n"%>
Expand Down Expand Up @@ -670,8 +678,7 @@ case SIMCODE(modelInfo = MODELINFO(vars = vars as SIMVARS(__))) then
}
// Calculate the odes
<%allEqns(allEquations,whenClauses)%>
if (atEvent)
newEvents = check_for_new_events();
if (atEvent) newEvents = check_for_new_events();
if (reInit || newEvents)
{
save_vars();
Expand Down

0 comments on commit b79b99a

Please sign in to comment.