Changes between Initial Version and Version 1 of Ticket #1203


Ignore:
Timestamp:
2015-03-18T15:04:13Z (10 years ago)
Author:
Per Östlund
Comment:

The example models contain some errors, but allowing for that this works now.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #1203

    • Property Cc perob88 removed
    • Property ComponentFrontend
    • Property Resolutionfixed
    • Property Status newclosed
  • TabularUnified Ticket #1203 – Description

    initial v1  
    11Consider the following set of definitions. It is somewhat similar to the media library building blocks.
     2{{{#!mo
     3partial package partialStuff
     4  constant Integer nz = 1;
     5end partialStuff;
     6 
     7package simpleStuff
     8  extends testPackage.partialStuff(nz = 2);
     9end simpleStuff;
     10 
     11class modelComponent
     12  replaceable package theStuff = testPackage.partialStuff;
     13  Real compVar;
     14equation
     15  compVar = theStuff.nz;
     16end modelComponent;
     17}}}
     18Now let's instatiate the following model
     19{{{#!mo
     20model myModel
     21  package theStuff = simpleStuff;
     22  modelComponent comp(redeclare package theStuff = theStuff);
     23end myModel;
     24}}}
     25This yields: OMC-ERROR: "Error: Class myModel.theStuff not found in scope modelComponent.theStuff.
    226
    3 partial package partialStuff \\
    4   constant Integer nz = 1; \\
    5 end partialStuff; \\
    6  \\
    7 package simpleStuff \\
    8   extends testPackage.partialStuff(nz = 2); \\
    9 end simpleStuff; \\
    10  \\
    11 class modelComponent \\
    12   replaceable package theStuff = testPackage.partialStuff; \\
    13   Real compVar; \\
    14 equation \\
    15   compVar = theStuff.nz; \\
    16 end modelComponent; \\
    17  \\
    18 Now let's instatiate the following model
     27Encapsulating everything inside another package:
     28{{{#!mo
     29package testPackage
     30...
     31...
     32...
     33...
     34end testPackage
     35}}}
     36followed by instantiateModel(testPackage.myModel) gives correct results.
    1937
    20 model myModel \\
    21   package theStuff = simpleStuff; \\
    22   modelComponent comp(redeclare package theStuff = theStuff); \\
     38A third variant where the only difference is another level of instantiation gives the wrong results but no compiler complaints...:
     39{{{#!mo
     40class myModel
     41  replaceable package theStuff = partialStuff;
     42  modelComponent comp(redeclare package theStuff = theStuff);
    2343end myModel;
    2444
    25 This yields: OMC-ERROR: "Error: Class myModel.theStuff not found in scope modelComponent.theStuff. \\
    26  \\
    27 Encapsulating everything inside another package: \\
    28 package testPackage \\
    29 ... \\
    30 ... \\
    31 ... \\
    32 ... \\
    33 end testPackage \\
    34  \\
    35 followed by instantiateModel(testPackage.myModel) gives correct results.
    36  \\
    37  \\
    38 A third variant where the only difference is another level of instantiation gives the wrong results but no compiler complaints...: \\
     45model myModel2
     46  myModel modelInst(redeclare package theStuff = simpleStuff);
     47end myModel2;
    3948
    40 
    41 class myModel \\
    42   replaceable package theStuff = partialStuff; \\
    43   modelComponent comp(redeclare package theStuff = theStuff); \\
    44 end myModel;
    45 
    46  model myModel2 \\
    47   myModel modelInst(redeclare package theStuff = simpleStuff); \\
    48 end myModel2; \\
    49  \\
    50 instantiateModel(myModel2) \\
    51 .. \\
    52 .. \\
    53 equation \\
    54   modelInst.comp.compVar = 1.0; \\
    55  \\
    56  \\
     49instantiateModel(myModel2)
     50..
     51..
     52equation
     53  modelInst.comp.compVar = 1.0;
     54}}}
    5755Here the problem is that compVar should be 2.0 instead of 1.0