Changeset 15307


Ignore:
Timestamp:
2013-02-25T13:37:18+01:00 (11 years ago)
Author:
perost
Message:
  • Make +orderConnections=false work as intended.
Location:
trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/FrontEnd/ConnectUtil.mo

    r14813 r15307  
    26042604    case (Connect.SET(ty = Connect.EQU(), elements = eql), _, _, _)
    26052605      equation
    2606         // here we do some overcosntrained connection breaking
     2606        // here we do some overconstrained connection breaking
    26072607        eql = ConnectionGraph.removeBrokenConnects(eql, inConnected, inBroken);
    26082608        dae = generateEquEquations(eql);
     
    26572657      list<DAE.Element> eq;
    26582658      String str;
     2659      Boolean order_conn;
    26592660
    26602661    case {} then DAEUtil.emptyDae;
     
    26652666          (e2 as Connect.CONNECTOR_ELEMENT(name = y, source = y_src)) :: rest_el)
    26662667      equation
    2667         e1 = Util.if_(Config.orderConnections(), e1, e2);
     2668        order_conn = Config.orderConnections();
     2669        e1 = Util.if_(order_conn, e1, e2);
    26682670        DAE.DAE(eq) = generateEquEquations(e1 :: rest_el);
     2671        (x, y) = Util.swap(shouldFlipEquEquation(x, x_src, order_conn), x, y);
    26692672        src = DAEUtil.mergeSources(x_src, y_src);
    26702673        src = DAEUtil.addElementSourceConnectOpt(src, SOME((x, y)));
     
    26832686end generateEquEquations;
    26842687
     2688protected function shouldFlipEquEquation
     2689  "If the flag +orderConnections=false is used, then we should keep the order of
     2690   the connector elements as they occur in the connection (if possible). In that
     2691   case we check if the cref of the first argument to the first connection
     2692   stored in the element source is a prefix of the connector element cref. If
     2693   it isn't, indicate that we should flip the generated equation."
     2694  input DAE.ComponentRef inLhsCref;
     2695  input DAE.ElementSource inLhsSource;
     2696  input Boolean inShouldOrder;
     2697  output Boolean outShouldFlip;
     2698algorithm
     2699  outShouldFlip := matchcontinue(inLhsCref, inLhsSource, inShouldOrder)
     2700    local
     2701      DAE.ComponentRef lhs;
     2702
     2703    case (_, DAE.SOURCE(connectEquationOptLst = SOME((lhs, _)) :: _), false)
     2704      then not ComponentReference.crefPrefixOf(lhs, inLhsCref);
     2705
     2706    else false;
     2707  end matchcontinue;
     2708end shouldFlipEquEquation;
     2709   
    26852710protected function generateFlowEquations
    26862711  "Generating equations from a flow connection set is a little trickier that
  • trunk/testsuite/flattening/modelica/connectors/Makefile

    r14813 r15307  
    2929ConnectInnerOuter2.mo \
    3030ConnectInnerOuter3.mo \
     31ConnectionOrder1.mo \
     32ConnectionOrder2.mo \
    3133ConnectorComponents.mo \
    3234ConnectorIllegal.mo \
Note: See TracChangeset for help on using the changeset viewer.