Skip to content

Commit

Permalink
- implement elsewhen part of whenequations for tplmode
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5274 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Apr 7, 2010
1 parent bf298af commit c7babf5
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions Compiler/SimCode.mo
Expand Up @@ -1863,13 +1863,13 @@ algorithm
whenEq :=
matchcontinue (eqs, index)
local
DAELow.WhenEquation eq;
DAELow.WhenEquation eq,eq1;
list<DAELow.Equation> restEqs;
Integer eqindex;
case ((DAELow.WHEN_EQUATION(whenEquation = eq as DAELow.WHEN_EQ(index=eqindex))) :: restEqs, index)
case ((DAELow.WHEN_EQUATION(whenEquation = eq)) :: restEqs, index)
equation
true = eqindex == index;
then SOME(eq);
eq1 = findWhenEquation1(eq,index);
then SOME(eq1);
case (_ :: restEqs, index)
equation
whenEq = findWhenEquation(restEqs, index);
Expand All @@ -1879,6 +1879,36 @@ algorithm
end matchcontinue;
end findWhenEquation;

protected function findWhenEquation1
"function: findWhenEquation1
Helper function to findWhenEquation."
input DAELow.WhenEquation inWEqn;
input Integer inInteger;
output DAELow.WhenEquation outWEqn;
algorithm
outWEqn := matchcontinue (inWEqn,inInteger)
local
Integer wc_ind,index;
DAELow.WhenEquation weqn,we,we1;

case(weqn as DAELow.WHEN_EQ(index = wc_ind,elsewhenPart = NONE()),index)
equation
(index == wc_ind) = true;
then
weqn;
case(weqn as DAELow.WHEN_EQ(index = wc_ind,elsewhenPart = SOME(we)),index)
equation
(index == wc_ind) = true;
then
weqn;
case(weqn as DAELow.WHEN_EQ(index = wc_ind,elsewhenPart = SOME(we)),index)
equation
we1 = findWhenEquation1(we,index);
then
we1;
end matchcontinue;
end findWhenEquation1;

protected function whenClauseToSimWhenClause
input DAELow.WhenClause whenClause;
input Option<DAELow.WhenEquation> whenEq;
Expand Down

0 comments on commit c7babf5

Please sign in to comment.