Skip to content

Commit

Permalink
- Make +orderConnections=false work as intended.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15307 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Feb 25, 2013
1 parent 07b9c81 commit 4617f01
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions Compiler/FrontEnd/ConnectUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2603,7 +2603,7 @@ algorithm

case (Connect.SET(ty = Connect.EQU(), elements = eql), _, _, _)
equation
// here we do some overcosntrained connection breaking
// here we do some overconstrained connection breaking
eql = ConnectionGraph.removeBrokenConnects(eql, inConnected, inBroken);
dae = generateEquEquations(eql);
then
Expand Down Expand Up @@ -2656,6 +2656,7 @@ algorithm
ConnectorElement e1, e2;
list<DAE.Element> eq;
String str;
Boolean order_conn;

case {} then DAEUtil.emptyDae;

Expand All @@ -2664,8 +2665,10 @@ algorithm
case ((e1 as Connect.CONNECTOR_ELEMENT(name = x, source = x_src)) ::
(e2 as Connect.CONNECTOR_ELEMENT(name = y, source = y_src)) :: rest_el)
equation
e1 = Util.if_(Config.orderConnections(), e1, e2);
order_conn = Config.orderConnections();
e1 = Util.if_(order_conn, e1, e2);
DAE.DAE(eq) = generateEquEquations(e1 :: rest_el);
(x, y) = Util.swap(shouldFlipEquEquation(x, x_src, order_conn), x, y);
src = DAEUtil.mergeSources(x_src, y_src);
src = DAEUtil.addElementSourceConnectOpt(src, SOME((x, y)));
then
Expand All @@ -2682,6 +2685,28 @@ algorithm
end matchcontinue;
end generateEquEquations;

protected function shouldFlipEquEquation
"If the flag +orderConnections=false is used, then we should keep the order of
the connector elements as they occur in the connection (if possible). In that
case we check if the cref of the first argument to the first connection
stored in the element source is a prefix of the connector element cref. If
it isn't, indicate that we should flip the generated equation."
input DAE.ComponentRef inLhsCref;
input DAE.ElementSource inLhsSource;
input Boolean inShouldOrder;
output Boolean outShouldFlip;
algorithm
outShouldFlip := matchcontinue(inLhsCref, inLhsSource, inShouldOrder)
local
DAE.ComponentRef lhs;

case (_, DAE.SOURCE(connectEquationOptLst = SOME((lhs, _)) :: _), false)
then not ComponentReference.crefPrefixOf(lhs, inLhsCref);

else false;
end matchcontinue;
end shouldFlipEquEquation;

protected function generateFlowEquations
"Generating equations from a flow connection set is a little trickier that
from a non-flow set. Only one equation is generated, but it has to consider
Expand Down

0 comments on commit 4617f01

Please sign in to comment.